mirror of
https://gitee.com/dromara/RuoYi-Vue-Plus.git
synced 2026-09-21 02:25:56 +08:00
add 新增 StringUtils splitTo 与 splitList 方法 优化业务代码
This commit is contained in:
parent
b5bcdd2b0c
commit
e0ed43f3b5
@ -92,7 +92,7 @@ public class ServletUtils extends JakartaServletUtil {
|
|||||||
public static Map<String, String> getParamMap(ServletRequest request) {
|
public static Map<String, String> getParamMap(ServletRequest request) {
|
||||||
Map<String, String> params = new HashMap<>();
|
Map<String, String> params = new HashMap<>();
|
||||||
for (Map.Entry<String, String[]> entry : getParams(request).entrySet()) {
|
for (Map.Entry<String, String[]> entry : getParams(request).entrySet()) {
|
||||||
params.put(entry.getKey(), StringUtils.join(entry.getValue(), ","));
|
params.put(entry.getKey(), StringUtils.join(entry.getValue(), StringUtils.SEPARATOR));
|
||||||
}
|
}
|
||||||
return params;
|
return params;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -42,7 +42,7 @@ public class StreamUtils {
|
|||||||
* @return 拼接后的list
|
* @return 拼接后的list
|
||||||
*/
|
*/
|
||||||
public static <E> String join(Collection<E> collection, Function<E, String> function) {
|
public static <E> String join(Collection<E> collection, Function<E, String> function) {
|
||||||
return join(collection, function, ",");
|
return join(collection, function, StringUtils.SEPARATOR);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -1,6 +1,7 @@
|
|||||||
package com.ruoyi.common.core.utils;
|
package com.ruoyi.common.core.utils;
|
||||||
|
|
||||||
import cn.hutool.core.collection.CollUtil;
|
import cn.hutool.core.collection.CollUtil;
|
||||||
|
import cn.hutool.core.convert.Convert;
|
||||||
import cn.hutool.core.lang.Validator;
|
import cn.hutool.core.lang.Validator;
|
||||||
import cn.hutool.core.util.StrUtil;
|
import cn.hutool.core.util.StrUtil;
|
||||||
import lombok.AccessLevel;
|
import lombok.AccessLevel;
|
||||||
@ -19,6 +20,8 @@ import java.util.stream.Collectors;
|
|||||||
@NoArgsConstructor(access = AccessLevel.PRIVATE)
|
@NoArgsConstructor(access = AccessLevel.PRIVATE)
|
||||||
public class StringUtils extends org.apache.commons.lang3.StringUtils {
|
public class StringUtils extends org.apache.commons.lang3.StringUtils {
|
||||||
|
|
||||||
|
public static final String SEPARATOR = ",";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取参数不为空值
|
* 获取参数不为空值
|
||||||
*
|
*
|
||||||
@ -232,7 +235,7 @@ public class StringUtils extends org.apache.commons.lang3.StringUtils {
|
|||||||
/**
|
/**
|
||||||
* 数字左边补齐0,使之达到指定长度。注意,如果数字转换为字符串后,长度大于size,则只保留 最后size个字符。
|
* 数字左边补齐0,使之达到指定长度。注意,如果数字转换为字符串后,长度大于size,则只保留 最后size个字符。
|
||||||
*
|
*
|
||||||
* @param num 数字对象
|
* @param num 数字对象
|
||||||
* @param size 字符串指定长度
|
* @param size 字符串指定长度
|
||||||
* @return 返回数字的字符串格式,该字符串为指定长度。
|
* @return 返回数字的字符串格式,该字符串为指定长度。
|
||||||
*/
|
*/
|
||||||
@ -243,9 +246,9 @@ public class StringUtils extends org.apache.commons.lang3.StringUtils {
|
|||||||
/**
|
/**
|
||||||
* 字符串左补齐。如果原始字符串s长度大于size,则只保留最后size个字符。
|
* 字符串左补齐。如果原始字符串s长度大于size,则只保留最后size个字符。
|
||||||
*
|
*
|
||||||
* @param s 原始字符串
|
* @param s 原始字符串
|
||||||
* @param size 字符串指定长度
|
* @param size 字符串指定长度
|
||||||
* @param c 用于补齐的字符
|
* @param c 用于补齐的字符
|
||||||
* @return 返回指定长度的字符串,由原字符串左补齐或截取得到。
|
* @return 返回指定长度的字符串,由原字符串左补齐或截取得到。
|
||||||
*/
|
*/
|
||||||
public static String padl(final String s, final int size, final char c) {
|
public static String padl(final String s, final int size, final char c) {
|
||||||
@ -264,20 +267,49 @@ public class StringUtils extends org.apache.commons.lang3.StringUtils {
|
|||||||
return sb.toString();
|
return sb.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static <T> List<T> splitTo(String str, Function<? super Object, T> mapper) {
|
/**
|
||||||
if (isBlank(str)) {
|
* 切分字符串(分隔符默认逗号)
|
||||||
return List.of();
|
*
|
||||||
}
|
* @param str 被切分的字符串
|
||||||
return StrUtil.split(str, ",")
|
* @return 分割后的数据列表
|
||||||
.stream()
|
*/
|
||||||
.filter(Objects::nonNull)
|
public static List<String> splitList(String str) {
|
||||||
.map(mapper)
|
return splitTo(str, Convert::toStr);
|
||||||
.collect(Collectors.toList());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 切分字符串
|
||||||
|
*
|
||||||
|
* @param str 被切分的字符串
|
||||||
|
* @param separator 分隔符
|
||||||
|
* @return 分割后的数据列表
|
||||||
|
*/
|
||||||
|
public static List<String> splitList(String str, String separator) {
|
||||||
|
return splitTo(str, separator, Convert::toStr);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 切分字符串自定义转换(分隔符默认逗号)
|
||||||
|
*
|
||||||
|
* @param str 被切分的字符串
|
||||||
|
* @param mapper 自定义转换
|
||||||
|
* @return 分割后的数据列表
|
||||||
|
*/
|
||||||
|
public static <T> List<T> splitTo(String str, Function<? super Object, T> mapper) {
|
||||||
|
return splitTo(str, SEPARATOR, mapper);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 切分字符串自定义转换
|
||||||
|
*
|
||||||
|
* @param str 被切分的字符串
|
||||||
|
* @param separator 分隔符
|
||||||
|
* @param mapper 自定义转换
|
||||||
|
* @return 分割后的数据列表
|
||||||
|
*/
|
||||||
public static <T> List<T> splitTo(String str, String separator, Function<? super Object, T> mapper) {
|
public static <T> List<T> splitTo(String str, String separator, Function<? super Object, T> mapper) {
|
||||||
if (isBlank(str)) {
|
if (isBlank(str)) {
|
||||||
return List.of();
|
return new ArrayList<>(0);
|
||||||
}
|
}
|
||||||
return StrUtil.split(str, separator)
|
return StrUtil.split(str, separator)
|
||||||
.stream()
|
.stream()
|
||||||
|
|||||||
@ -1,5 +1,7 @@
|
|||||||
package com.ruoyi.common.excel.annotation;
|
package com.ruoyi.common.excel.annotation;
|
||||||
|
|
||||||
|
import com.ruoyi.common.core.utils.StringUtils;
|
||||||
|
|
||||||
import java.lang.annotation.*;
|
import java.lang.annotation.*;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -25,6 +27,6 @@ public @interface ExcelDictFormat {
|
|||||||
/**
|
/**
|
||||||
* 分隔符,读取字符串组内容
|
* 分隔符,读取字符串组内容
|
||||||
*/
|
*/
|
||||||
String separator() default ",";
|
String separator() default StringUtils.SEPARATOR;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -269,7 +269,7 @@ public class ExcelUtil {
|
|||||||
*/
|
*/
|
||||||
public static String convertByExp(String propertyValue, String converterExp, String separator) {
|
public static String convertByExp(String propertyValue, String converterExp, String separator) {
|
||||||
StringBuilder propertyString = new StringBuilder();
|
StringBuilder propertyString = new StringBuilder();
|
||||||
String[] convertSource = converterExp.split(",");
|
String[] convertSource = converterExp.split(StringUtils.SEPARATOR);
|
||||||
for (String item : convertSource) {
|
for (String item : convertSource) {
|
||||||
String[] itemArray = item.split("=");
|
String[] itemArray = item.split("=");
|
||||||
if (StringUtils.containsAny(propertyValue, separator)) {
|
if (StringUtils.containsAny(propertyValue, separator)) {
|
||||||
@ -298,7 +298,7 @@ public class ExcelUtil {
|
|||||||
*/
|
*/
|
||||||
public static String reverseByExp(String propertyValue, String converterExp, String separator) {
|
public static String reverseByExp(String propertyValue, String converterExp, String separator) {
|
||||||
StringBuilder propertyString = new StringBuilder();
|
StringBuilder propertyString = new StringBuilder();
|
||||||
String[] convertSource = converterExp.split(",");
|
String[] convertSource = converterExp.split(StringUtils.SEPARATOR);
|
||||||
for (String item : convertSource) {
|
for (String item : convertSource) {
|
||||||
String[] itemArray = item.split("=");
|
String[] itemArray = item.split("=");
|
||||||
if (StringUtils.containsAny(propertyValue, separator)) {
|
if (StringUtils.containsAny(propertyValue, separator)) {
|
||||||
|
|||||||
@ -89,8 +89,8 @@ public class PageQuery implements Serializable {
|
|||||||
// 兼容前端排序类型
|
// 兼容前端排序类型
|
||||||
isAsc = StringUtils.replaceEach(isAsc, new String[]{"ascending", "descending"}, new String[]{"asc", "desc"});
|
isAsc = StringUtils.replaceEach(isAsc, new String[]{"ascending", "descending"}, new String[]{"asc", "desc"});
|
||||||
|
|
||||||
String[] orderByArr = orderBy.split(",");
|
String[] orderByArr = orderBy.split(StringUtils.SEPARATOR);
|
||||||
String[] isAscArr = isAsc.split(",");
|
String[] isAscArr = isAsc.split(StringUtils.SEPARATOR);
|
||||||
if (isAscArr.length != 1 && isAscArr.length != orderByArr.length) {
|
if (isAscArr.length != 1 && isAscArr.length != orderByArr.length) {
|
||||||
throw new ServiceException("排序参数有误");
|
throw new ServiceException("排序参数有误");
|
||||||
}
|
}
|
||||||
|
|||||||
@ -53,7 +53,7 @@ public class TencentSmsTemplate implements SmsTemplate {
|
|||||||
throw new SmsException("模板ID不能为空");
|
throw new SmsException("模板ID不能为空");
|
||||||
}
|
}
|
||||||
SendSmsRequest req = new SendSmsRequest();
|
SendSmsRequest req = new SendSmsRequest();
|
||||||
Set<String> set = Arrays.stream(phones.split(",")).map(p -> "+86" + p).collect(Collectors.toSet());
|
Set<String> set = Arrays.stream(phones.split(StringUtils.SEPARATOR)).map(p -> "+86" + p).collect(Collectors.toSet());
|
||||||
req.setPhoneNumberSet(ArrayUtil.toArray(set, String.class));
|
req.setPhoneNumberSet(ArrayUtil.toArray(set, String.class));
|
||||||
if (CollUtil.isNotEmpty(param)) {
|
if (CollUtil.isNotEmpty(param)) {
|
||||||
req.setTemplateParamSet(ArrayUtil.toArray(param.values(), String.class));
|
req.setTemplateParamSet(ArrayUtil.toArray(param.values(), String.class));
|
||||||
|
|||||||
@ -30,7 +30,7 @@ public class FilterConfig {
|
|||||||
FilterRegistrationBean registration = new FilterRegistrationBean();
|
FilterRegistrationBean registration = new FilterRegistrationBean();
|
||||||
registration.setDispatcherTypes(DispatcherType.REQUEST);
|
registration.setDispatcherTypes(DispatcherType.REQUEST);
|
||||||
registration.setFilter(new XssFilter());
|
registration.setFilter(new XssFilter());
|
||||||
registration.addUrlPatterns(StringUtils.split(xssProperties.getUrlPatterns(), ","));
|
registration.addUrlPatterns(StringUtils.split(xssProperties.getUrlPatterns(), StringUtils.SEPARATOR));
|
||||||
registration.setName("xssFilter");
|
registration.setName("xssFilter");
|
||||||
registration.setOrder(FilterRegistrationBean.HIGHEST_PRECEDENCE);
|
registration.setOrder(FilterRegistrationBean.HIGHEST_PRECEDENCE);
|
||||||
Map<String, String> initParameters = new HashMap<>();
|
Map<String, String> initParameters = new HashMap<>();
|
||||||
|
|||||||
@ -25,7 +25,7 @@ public class XssFilter implements Filter {
|
|||||||
public void init(FilterConfig filterConfig) throws ServletException {
|
public void init(FilterConfig filterConfig) throws ServletException {
|
||||||
String tempExcludes = filterConfig.getInitParameter("excludes");
|
String tempExcludes = filterConfig.getInitParameter("excludes");
|
||||||
if (StringUtils.isNotEmpty(tempExcludes)) {
|
if (StringUtils.isNotEmpty(tempExcludes)) {
|
||||||
String[] url = tempExcludes.split(",");
|
String[] url = tempExcludes.split(StringUtils.SEPARATOR);
|
||||||
for (int i = 0; url != null && i < url.length; i++) {
|
for (int i = 0; url != null && i < url.length; i++) {
|
||||||
excludes.add(url[i]);
|
excludes.add(url[i]);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -212,7 +212,7 @@ public class GenTableColumn extends BaseEntity {
|
|||||||
if (StringUtils.isNotEmpty(value)) {
|
if (StringUtils.isNotEmpty(value)) {
|
||||||
Object startStr = value.subSequence(0, 1);
|
Object startStr = value.subSequence(0, 1);
|
||||||
String endStr = value.substring(1);
|
String endStr = value.substring(1);
|
||||||
sb.append("").append(startStr).append("=").append(endStr).append(",");
|
sb.append(StringUtils.EMPTY).append(startStr).append("=").append(endStr).append(StringUtils.SEPARATOR);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return sb.deleteCharAt(sb.length() - 1).toString();
|
return sb.deleteCharAt(sb.length() - 1).toString();
|
||||||
|
|||||||
@ -59,7 +59,7 @@ public class GenUtils {
|
|||||||
column.setHtmlType(GenConstants.HTML_INPUT);
|
column.setHtmlType(GenConstants.HTML_INPUT);
|
||||||
|
|
||||||
// 如果是浮点型 统一用BigDecimal
|
// 如果是浮点型 统一用BigDecimal
|
||||||
String[] str = StringUtils.split(StringUtils.substringBetween(column.getColumnType(), "(", ")"), ",");
|
String[] str = StringUtils.split(StringUtils.substringBetween(column.getColumnType(), "(", ")"), StringUtils.SEPARATOR);
|
||||||
if (str != null && str.length == 2 && Integer.parseInt(str[1]) > 0) {
|
if (str != null && str.length == 2 && Integer.parseInt(str[1]) > 0) {
|
||||||
column.setJavaType(GenConstants.TYPE_BIGDECIMAL);
|
column.setJavaType(GenConstants.TYPE_BIGDECIMAL);
|
||||||
}
|
}
|
||||||
@ -168,7 +168,7 @@ public class GenUtils {
|
|||||||
boolean autoRemovePre = GenConfig.getAutoRemovePre();
|
boolean autoRemovePre = GenConfig.getAutoRemovePre();
|
||||||
String tablePrefix = GenConfig.getTablePrefix();
|
String tablePrefix = GenConfig.getTablePrefix();
|
||||||
if (autoRemovePre && StringUtils.isNotEmpty(tablePrefix)) {
|
if (autoRemovePre && StringUtils.isNotEmpty(tablePrefix)) {
|
||||||
String[] searchList = StringUtils.split(tablePrefix, ",");
|
String[] searchList = StringUtils.split(tablePrefix, StringUtils.SEPARATOR);
|
||||||
tableName = replaceFirst(tableName, searchList);
|
tableName = replaceFirst(tableName, searchList);
|
||||||
}
|
}
|
||||||
return StringUtils.convertToCamelCase(tableName);
|
return StringUtils.convertToCamelCase(tableName);
|
||||||
|
|||||||
@ -225,7 +225,7 @@ public class VelocityUtils {
|
|||||||
*/
|
*/
|
||||||
public static String getDicts(GenTable genTable) {
|
public static String getDicts(GenTable genTable) {
|
||||||
List<GenTableColumn> columns = genTable.getColumns();
|
List<GenTableColumn> columns = genTable.getColumns();
|
||||||
Set<String> dicts = new HashSet<String>();
|
Set<String> dicts = new HashSet<>();
|
||||||
addDicts(dicts, columns);
|
addDicts(dicts, columns);
|
||||||
return StringUtils.join(dicts, ", ");
|
return StringUtils.join(dicts, ", ");
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,13 +1,13 @@
|
|||||||
package com.ruoyi.system.controller.system;
|
package com.ruoyi.system.controller.system;
|
||||||
|
|
||||||
import cn.dev33.satoken.annotation.SaCheckPermission;
|
import cn.dev33.satoken.annotation.SaCheckPermission;
|
||||||
import cn.hutool.core.util.ArrayUtil;
|
import cn.hutool.core.convert.Convert;
|
||||||
import com.ruoyi.common.log.annotation.Log;
|
|
||||||
import com.ruoyi.common.core.constant.UserConstants;
|
import com.ruoyi.common.core.constant.UserConstants;
|
||||||
import com.ruoyi.common.web.core.BaseController;
|
|
||||||
import com.ruoyi.common.core.domain.R;
|
import com.ruoyi.common.core.domain.R;
|
||||||
import com.ruoyi.common.log.enums.BusinessType;
|
|
||||||
import com.ruoyi.common.core.utils.StringUtils;
|
import com.ruoyi.common.core.utils.StringUtils;
|
||||||
|
import com.ruoyi.common.log.annotation.Log;
|
||||||
|
import com.ruoyi.common.log.enums.BusinessType;
|
||||||
|
import com.ruoyi.common.web.core.BaseController;
|
||||||
import com.ruoyi.system.domain.bo.SysDeptBo;
|
import com.ruoyi.system.domain.bo.SysDeptBo;
|
||||||
import com.ruoyi.system.domain.vo.SysDeptVo;
|
import com.ruoyi.system.domain.vo.SysDeptVo;
|
||||||
import com.ruoyi.system.service.ISysDeptService;
|
import com.ruoyi.system.service.ISysDeptService;
|
||||||
@ -50,7 +50,7 @@ public class SysDeptController extends BaseController {
|
|||||||
public R<List<SysDeptVo>> excludeChild(@PathVariable(value = "deptId", required = false) Long deptId) {
|
public R<List<SysDeptVo>> excludeChild(@PathVariable(value = "deptId", required = false) Long deptId) {
|
||||||
List<SysDeptVo> depts = deptService.selectDeptList(new SysDeptBo());
|
List<SysDeptVo> depts = deptService.selectDeptList(new SysDeptBo());
|
||||||
depts.removeIf(d -> d.getDeptId().equals(deptId)
|
depts.removeIf(d -> d.getDeptId().equals(deptId)
|
||||||
|| ArrayUtil.contains(StringUtils.split(d.getAncestors(), ","), deptId + ""));
|
|| StringUtils.splitList(d.getAncestors()).contains(Convert.toStr(deptId)));
|
||||||
return R.ok(depts);
|
return R.ok(depts);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -142,13 +142,13 @@ public class SysDeptServiceImpl implements ISysDeptService, DeptService {
|
|||||||
@Override
|
@Override
|
||||||
public String selectDeptNameByIds(String deptIds) {
|
public String selectDeptNameByIds(String deptIds) {
|
||||||
List<String> list = new ArrayList<>();
|
List<String> list = new ArrayList<>();
|
||||||
for (Long id : Arrays.stream(deptIds.split(",")).map(Long::parseLong).toList()) {
|
for (Long id : StringUtils.splitTo(deptIds, Convert::toLong)) {
|
||||||
SysDeptVo vo = SpringUtils.getAopProxy(this).selectDeptById(id);
|
SysDeptVo vo = SpringUtils.getAopProxy(this).selectDeptById(id);
|
||||||
if (ObjectUtil.isNotNull(vo)) {
|
if (ObjectUtil.isNotNull(vo)) {
|
||||||
list.add(vo.getDeptName());
|
list.add(vo.getDeptName());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return String.join(",", list);
|
return String.join(StringUtils.SEPARATOR, list);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -237,7 +237,7 @@ public class SysDeptServiceImpl implements ISysDeptService, DeptService {
|
|||||||
throw new ServiceException("部门停用,不允许新增");
|
throw new ServiceException("部门停用,不允许新增");
|
||||||
}
|
}
|
||||||
SysDept dept = BeanUtil.toBean(bo, SysDept.class);
|
SysDept dept = BeanUtil.toBean(bo, SysDept.class);
|
||||||
dept.setAncestors(info.getAncestors() + "," + dept.getParentId());
|
dept.setAncestors(info.getAncestors() + StringUtils.SEPARATOR + dept.getParentId());
|
||||||
return baseMapper.insert(dept);
|
return baseMapper.insert(dept);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -254,7 +254,7 @@ public class SysDeptServiceImpl implements ISysDeptService, DeptService {
|
|||||||
SysDept newParentDept = baseMapper.selectById(dept.getParentId());
|
SysDept newParentDept = baseMapper.selectById(dept.getParentId());
|
||||||
SysDept oldDept = baseMapper.selectById(dept.getDeptId());
|
SysDept oldDept = baseMapper.selectById(dept.getDeptId());
|
||||||
if (ObjectUtil.isNotNull(newParentDept) && ObjectUtil.isNotNull(oldDept)) {
|
if (ObjectUtil.isNotNull(newParentDept) && ObjectUtil.isNotNull(oldDept)) {
|
||||||
String newAncestors = newParentDept.getAncestors() + "," + newParentDept.getDeptId();
|
String newAncestors = newParentDept.getAncestors() + StringUtils.SEPARATOR + newParentDept.getDeptId();
|
||||||
String oldAncestors = oldDept.getAncestors();
|
String oldAncestors = oldDept.getAncestors();
|
||||||
dept.setAncestors(newAncestors);
|
dept.setAncestors(newAncestors);
|
||||||
updateDeptChildren(dept.getDeptId(), newAncestors, oldAncestors);
|
updateDeptChildren(dept.getDeptId(), newAncestors, oldAncestors);
|
||||||
|
|||||||
@ -100,7 +100,7 @@ public class SysMenuServiceImpl implements ISysMenuService {
|
|||||||
Set<String> permsSet = new HashSet<>();
|
Set<String> permsSet = new HashSet<>();
|
||||||
for (String perm : perms) {
|
for (String perm : perms) {
|
||||||
if (StringUtils.isNotEmpty(perm)) {
|
if (StringUtils.isNotEmpty(perm)) {
|
||||||
permsSet.addAll(Arrays.asList(perm.trim().split(",")));
|
permsSet.addAll(StringUtils.splitList(perm.trim()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return permsSet;
|
return permsSet;
|
||||||
@ -118,7 +118,7 @@ public class SysMenuServiceImpl implements ISysMenuService {
|
|||||||
Set<String> permsSet = new HashSet<>();
|
Set<String> permsSet = new HashSet<>();
|
||||||
for (String perm : perms) {
|
for (String perm : perms) {
|
||||||
if (StringUtils.isNotEmpty(perm)) {
|
if (StringUtils.isNotEmpty(perm)) {
|
||||||
permsSet.addAll(Arrays.asList(perm.trim().split(",")));
|
permsSet.addAll(StringUtils.splitList(perm.trim()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return permsSet;
|
return permsSet;
|
||||||
|
|||||||
@ -1,5 +1,6 @@
|
|||||||
package com.ruoyi.system.service.impl;
|
package com.ruoyi.system.service.impl;
|
||||||
|
|
||||||
|
import cn.hutool.core.convert.Convert;
|
||||||
import cn.hutool.core.io.IoUtil;
|
import cn.hutool.core.io.IoUtil;
|
||||||
import cn.hutool.core.util.ObjectUtil;
|
import cn.hutool.core.util.ObjectUtil;
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
@ -70,13 +71,13 @@ public class SysOssServiceImpl implements ISysOssService, OssService {
|
|||||||
@Override
|
@Override
|
||||||
public String selectUrlByIds(String ossIds) {
|
public String selectUrlByIds(String ossIds) {
|
||||||
List<String> list = new ArrayList<>();
|
List<String> list = new ArrayList<>();
|
||||||
for (Long id : Arrays.stream(ossIds.split(",")).map(Long::parseLong).toList()) {
|
for (Long id : StringUtils.splitTo(ossIds, Convert::toLong)) {
|
||||||
SysOssVo vo = SpringUtils.getAopProxy(this).getById(id);
|
SysOssVo vo = SpringUtils.getAopProxy(this).getById(id);
|
||||||
if (ObjectUtil.isNotNull(vo)) {
|
if (ObjectUtil.isNotNull(vo)) {
|
||||||
list.add(this.matchingUrl(vo).getUrl());
|
list.add(this.matchingUrl(vo).getUrl());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return String.join(",", list);
|
return String.join(StringUtils.SEPARATOR, list);
|
||||||
}
|
}
|
||||||
|
|
||||||
private LambdaQueryWrapper<SysOss> buildQueryWrapper(SysOssBo bo) {
|
private LambdaQueryWrapper<SysOss> buildQueryWrapper(SysOssBo bo) {
|
||||||
|
|||||||
@ -6,11 +6,11 @@ import cn.hutool.core.util.ObjectUtil;
|
|||||||
import com.baomidou.mybatisplus.core.conditions.Wrapper;
|
import com.baomidou.mybatisplus.core.conditions.Wrapper;
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||||
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
|
|
||||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
import com.ruoyi.common.core.constant.UserConstants;
|
import com.ruoyi.common.core.constant.UserConstants;
|
||||||
import com.ruoyi.common.core.utils.StreamUtils;
|
import com.ruoyi.common.core.utils.StreamUtils;
|
||||||
|
import com.ruoyi.common.core.utils.StringUtils;
|
||||||
import com.ruoyi.common.mybatis.core.page.PageQuery;
|
import com.ruoyi.common.mybatis.core.page.PageQuery;
|
||||||
import com.ruoyi.system.domain.SysRole;
|
import com.ruoyi.system.domain.SysRole;
|
||||||
import com.ruoyi.common.mybatis.core.page.TableDataInfo;
|
import com.ruoyi.common.mybatis.core.page.TableDataInfo;
|
||||||
@ -110,7 +110,7 @@ public class SysRoleServiceImpl implements ISysRoleService {
|
|||||||
Set<String> permsSet = new HashSet<>();
|
Set<String> permsSet = new HashSet<>();
|
||||||
for (SysRoleVo perm : perms) {
|
for (SysRoleVo perm : perms) {
|
||||||
if (ObjectUtil.isNotNull(perm)) {
|
if (ObjectUtil.isNotNull(perm)) {
|
||||||
permsSet.addAll(Arrays.asList(perm.getRoleKey().trim().split(",")));
|
permsSet.addAll(StringUtils.splitList(perm.getRoleKey().trim()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return permsSet;
|
return permsSet;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user