mirror of
				https://github.com/dromara/RuoYi-Vue-Plus.git
				synced 2025-11-04 16:23:42 +08:00 
			
		
		
		
	update 优化以逗号拼接元素
This commit is contained in:
		@@ -115,7 +115,7 @@ public class ServletUtils extends JakartaServletUtil {
 | 
			
		||||
    public static Map<String, String> getParamMap(ServletRequest request) {
 | 
			
		||||
        Map<String, String> params = new HashMap<>();
 | 
			
		||||
        for (Map.Entry<String, String[]> entry : getParams(request).entrySet()) {
 | 
			
		||||
            params.put(entry.getKey(), StringUtils.join(entry.getValue(), StringUtils.SEPARATOR));
 | 
			
		||||
            params.put(entry.getKey(), StringUtils.joinComma(entry.getValue()));
 | 
			
		||||
        }
 | 
			
		||||
        return params;
 | 
			
		||||
    }
 | 
			
		||||
 
 | 
			
		||||
@@ -361,15 +361,24 @@ public class StringUtils extends org.apache.commons.lang3.StringUtils {
 | 
			
		||||
            return input;
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * 以逗号拼接元素
 | 
			
		||||
     * 将可迭代对象中的元素使用逗号拼接成字符串
 | 
			
		||||
     *
 | 
			
		||||
     * @param iterable 可迭代对象
 | 
			
		||||
     * @param iterable 可迭代对象,如 List、Set 等
 | 
			
		||||
     * @return 拼接后的字符串
 | 
			
		||||
     */
 | 
			
		||||
    public static String joinComma(Iterable<?> iterable) {
 | 
			
		||||
        return StringUtils.join(iterable, SEPARATOR);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * 将数组中的元素使用逗号拼接成字符串
 | 
			
		||||
     *
 | 
			
		||||
     * @param array 任意类型的数组
 | 
			
		||||
     * @return 拼接后的字符串
 | 
			
		||||
     */
 | 
			
		||||
    public static String joinComma(Object[] array) {
 | 
			
		||||
        return StringUtils.join(array, SEPARATOR);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -1,6 +1,5 @@
 | 
			
		||||
package org.dromara.common.mybatis.handler;
 | 
			
		||||
 | 
			
		||||
import cn.hutool.core.annotation.AnnotationUtil;
 | 
			
		||||
import cn.hutool.core.collection.CollUtil;
 | 
			
		||||
import cn.hutool.core.util.ObjectUtil;
 | 
			
		||||
import lombok.AllArgsConstructor;
 | 
			
		||||
@@ -10,7 +9,6 @@ import net.sf.jsqlparser.expression.Expression;
 | 
			
		||||
import net.sf.jsqlparser.expression.operators.conditional.AndExpression;
 | 
			
		||||
import net.sf.jsqlparser.expression.operators.relational.ParenthesedExpressionList;
 | 
			
		||||
import net.sf.jsqlparser.parser.CCJSqlParserUtil;
 | 
			
		||||
import org.apache.ibatis.io.Resources;
 | 
			
		||||
import org.dromara.common.core.domain.dto.RoleDTO;
 | 
			
		||||
import org.dromara.common.core.domain.model.LoginUser;
 | 
			
		||||
import org.dromara.common.core.exception.ServiceException;
 | 
			
		||||
@@ -22,22 +20,13 @@ import org.dromara.common.mybatis.annotation.DataPermission;
 | 
			
		||||
import org.dromara.common.mybatis.enums.DataScopeType;
 | 
			
		||||
import org.dromara.common.mybatis.helper.DataPermissionHelper;
 | 
			
		||||
import org.dromara.common.satoken.utils.LoginHelper;
 | 
			
		||||
import org.springframework.context.ConfigurableApplicationContext;
 | 
			
		||||
import org.springframework.context.expression.BeanFactoryResolver;
 | 
			
		||||
import org.springframework.core.io.Resource;
 | 
			
		||||
import org.springframework.core.io.support.PathMatchingResourcePatternResolver;
 | 
			
		||||
import org.springframework.core.io.support.ResourcePatternResolver;
 | 
			
		||||
import org.springframework.core.type.ClassMetadata;
 | 
			
		||||
import org.springframework.core.type.classreading.CachingMetadataReaderFactory;
 | 
			
		||||
import org.springframework.expression.*;
 | 
			
		||||
import org.springframework.expression.common.TemplateParserContext;
 | 
			
		||||
import org.springframework.expression.spel.standard.SpelExpressionParser;
 | 
			
		||||
import org.springframework.expression.spel.support.StandardEvaluationContext;
 | 
			
		||||
import org.springframework.util.ClassUtils;
 | 
			
		||||
 | 
			
		||||
import java.lang.reflect.Method;
 | 
			
		||||
import java.util.*;
 | 
			
		||||
import java.util.concurrent.ConcurrentHashMap;
 | 
			
		||||
import java.util.function.Function;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 
 | 
			
		||||
@@ -37,7 +37,7 @@ public class SysTenantPackageBo extends BaseEntity {
 | 
			
		||||
    /**
 | 
			
		||||
     * 关联菜单id
 | 
			
		||||
     */
 | 
			
		||||
    @AutoMapping(target = "menuIds", expression = "java(org.dromara.common.core.utils.StringUtils.join(source.getMenuIds(), \",\"))")
 | 
			
		||||
    @AutoMapping(target = "menuIds", expression = "java(org.dromara.common.core.utils.StringUtils.joinComma(source.getMenuIds()))")
 | 
			
		||||
    private Long[] menuIds;
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
 
 | 
			
		||||
@@ -88,11 +88,7 @@ public class SysTenantPackageServiceImpl implements ISysTenantPackageService {
 | 
			
		||||
        SysTenantPackage add = MapstructUtils.convert(bo, SysTenantPackage.class);
 | 
			
		||||
        // 保存菜单id
 | 
			
		||||
        List<Long> menuIds = Arrays.asList(bo.getMenuIds());
 | 
			
		||||
        if (CollUtil.isNotEmpty(menuIds)) {
 | 
			
		||||
            add.setMenuIds(StringUtils.join(menuIds, ", "));
 | 
			
		||||
        } else {
 | 
			
		||||
            add.setMenuIds("");
 | 
			
		||||
        }
 | 
			
		||||
        add.setMenuIds(CollUtil.isNotEmpty(menuIds) ? StringUtils.joinComma(menuIds) : "");
 | 
			
		||||
        boolean flag = baseMapper.insert(add) > 0;
 | 
			
		||||
        if (flag) {
 | 
			
		||||
            bo.setPackageId(add.getPackageId());
 | 
			
		||||
@@ -109,11 +105,7 @@ public class SysTenantPackageServiceImpl implements ISysTenantPackageService {
 | 
			
		||||
        SysTenantPackage update = MapstructUtils.convert(bo, SysTenantPackage.class);
 | 
			
		||||
        // 保存菜单id
 | 
			
		||||
        List<Long> menuIds = Arrays.asList(bo.getMenuIds());
 | 
			
		||||
        if (CollUtil.isNotEmpty(menuIds)) {
 | 
			
		||||
            update.setMenuIds(StringUtils.join(menuIds, ", "));
 | 
			
		||||
        } else {
 | 
			
		||||
            update.setMenuIds("");
 | 
			
		||||
        }
 | 
			
		||||
        update.setMenuIds(CollUtil.isNotEmpty(menuIds) ? StringUtils.joinComma(menuIds) : "");
 | 
			
		||||
        return baseMapper.updateById(update) > 0;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user