mirror of
				https://github.com/continew-org/continew-starter.git
				synced 2025-10-31 22:57:19 +08:00 
			
		
		
		
	refactor: 根据 Sonar 建议调整,StrUtil => CharSequenceUtil
工具层调整以减少 Sonar 建议,应用层则可忽略,怎么用方便怎么来
This commit is contained in:
		| @@ -16,18 +16,9 @@ | ||||
|  | ||||
| package top.charles7c.continew.starter.data.mybatis.plus.datapermission; | ||||
|  | ||||
| import java.lang.reflect.Method; | ||||
| import java.util.Collections; | ||||
| import java.util.Set; | ||||
|  | ||||
| import cn.hutool.core.util.StrUtil; | ||||
| import cn.hutool.core.text.CharSequenceUtil; | ||||
| import com.baomidou.mybatisplus.core.toolkit.StringUtils; | ||||
| import com.baomidou.mybatisplus.extension.plugins.handler.DataPermissionHandler; | ||||
|  | ||||
| import org.slf4j.Logger; | ||||
| import org.slf4j.LoggerFactory; | ||||
| import top.charles7c.continew.starter.core.constant.StringConstants; | ||||
|  | ||||
| import net.sf.jsqlparser.expression.Expression; | ||||
| import net.sf.jsqlparser.expression.Function; | ||||
| import net.sf.jsqlparser.expression.LongValue; | ||||
| @@ -42,6 +33,13 @@ import net.sf.jsqlparser.schema.Table; | ||||
| import net.sf.jsqlparser.statement.select.PlainSelect; | ||||
| import net.sf.jsqlparser.statement.select.SelectExpressionItem; | ||||
| import net.sf.jsqlparser.statement.select.SubSelect; | ||||
| import org.slf4j.Logger; | ||||
| import org.slf4j.LoggerFactory; | ||||
| import top.charles7c.continew.starter.core.constant.StringConstants; | ||||
|  | ||||
| import java.lang.reflect.Method; | ||||
| import java.util.Collections; | ||||
| import java.util.Set; | ||||
|  | ||||
| /** | ||||
|  * 数据权限处理器实现类 | ||||
| @@ -69,7 +67,7 @@ public class DataPermissionHandlerImpl implements DataPermissionHandler { | ||||
|             for (Method method : methodArr) { | ||||
|                 DataPermission dataPermission = method.getAnnotation(DataPermission.class); | ||||
|                 String name = method.getName(); | ||||
|                 if (null == dataPermission || !StrUtil.equalsAny(methodName, name, name + "_COUNT")) { | ||||
|                 if (null == dataPermission || !CharSequenceUtil.equalsAny(methodName, name, name + "_COUNT")) { | ||||
|                     continue; | ||||
|                 } | ||||
|                 if (dataPermissionFilter.isFilter()) { | ||||
|   | ||||
| @@ -21,7 +21,7 @@ import org.slf4j.LoggerFactory; | ||||
| import cn.hutool.core.collection.CollUtil; | ||||
| import cn.hutool.core.util.ArrayUtil; | ||||
| import cn.hutool.core.util.ObjectUtil; | ||||
| import cn.hutool.core.util.StrUtil; | ||||
| import cn.hutool.core.text.CharSequenceUtil; | ||||
| import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; | ||||
| import top.charles7c.continew.starter.core.exception.BadRequestException; | ||||
| import top.charles7c.continew.starter.core.util.ReflectUtils; | ||||
| @@ -117,7 +117,7 @@ public class QueryWrapperHelper { | ||||
|             // 没有 @Query 注解,默认等值查询 | ||||
|             Query queryAnnotation = field.getAnnotation(Query.class); | ||||
|             if (null == queryAnnotation) { | ||||
|                 return Collections.singletonList(q -> q.eq(StrUtil.toUnderlineCase(fieldName), fieldValue)); | ||||
|                 return Collections.singletonList(q -> q.eq(CharSequenceUtil.toUnderlineCase(fieldName), fieldValue)); | ||||
|             } | ||||
|             // 解析单列查询 | ||||
|             QueryType queryType = queryAnnotation.type(); | ||||
| @@ -125,7 +125,7 @@ public class QueryWrapperHelper { | ||||
|             final int columnLength = ArrayUtil.length(columns); | ||||
|             List<Consumer<QueryWrapper<R>>> consumers = new ArrayList<>(columnLength); | ||||
|             if (columnLength <= 1) { | ||||
|                 String columnName = columnLength == 1 ? columns[0] : StrUtil.toUnderlineCase(fieldName); | ||||
|                 String columnName = columnLength == 1 ? columns[0] : CharSequenceUtil.toUnderlineCase(fieldName); | ||||
|                 parse(queryType, columnName, fieldValue, consumers); | ||||
|                 return consumers; | ||||
|             } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user