|
|
@@ -74,7 +74,7 @@ public class StringBufferContentAspect {
|
|
|
// 假设这里通过某种业务逻辑生成了stringBufferContent的值
|
|
|
this.buildStringBufferBasedOnDataPermissions(path, invAccountQueryVo);
|
|
|
|
|
|
- // 继续执行被注解标注的方法或类的原有逻辑
|
|
|
+ // 继续执行被注解标注的方法或类的原有逻辑e
|
|
|
return joinPoint.proceed();
|
|
|
}
|
|
|
|
|
|
@@ -149,7 +149,7 @@ public class StringBufferContentAspect {
|
|
|
}
|
|
|
private void handleSingleDataPermission(DataPermissions dataPermissions, StringBuilder stringBuffer,
|
|
|
DataParams invAccountQueryVo) {
|
|
|
- HashMap<String, Object> sqlMap = new HashMap<>();
|
|
|
+ HashMap<String, String> sqlMap = new HashMap<>();
|
|
|
String ruleCondition = dataPermissions.getRuleCondition();
|
|
|
String descByCode = DataPermissionsEnum.getDescByCode(ruleCondition);
|
|
|
String ruleField = dataPermissions.getRuleField();
|
|
|
@@ -163,7 +163,7 @@ public class StringBufferContentAspect {
|
|
|
}
|
|
|
|
|
|
private void handleMultipleDataPermissions(Map<String, List<DataPermissions>> groupedMap, StringBuilder stringBuffer, DataParams invAccountQueryVo) {
|
|
|
- HashMap<String, Object> sqlMap = new HashMap<>();
|
|
|
+ HashMap<String, String> sqlMap = new HashMap<>();
|
|
|
for (Map.Entry<String, List<DataPermissions>> entry : groupedMap.entrySet()) {
|
|
|
List<DataPermissions> dataPermissionsList = entry.getValue();
|
|
|
int index = 0;
|
|
|
@@ -172,6 +172,18 @@ public class StringBufferContentAspect {
|
|
|
String descByCode = DataPermissionsEnum.getDescByCode(ruleCondition);
|
|
|
String ruleField = dataPermissions.getRuleField();
|
|
|
String ruleValue = dataPermissions.getRuleValue();
|
|
|
+ StringBuilder stringBuilder = new StringBuilder();
|
|
|
+ if(ruleValue.contains(",")){
|
|
|
+ String[] split = ruleValue.split(",");
|
|
|
+ int indexNumber =0;
|
|
|
+ for (String s : split) {
|
|
|
+ stringBuilder.append("'").append(s).append("'").append(",");
|
|
|
+ indexNumber++;
|
|
|
+ }
|
|
|
+ stringBuilder.deleteCharAt(stringBuilder.length() - 1);
|
|
|
+ ruleValue =stringBuilder.toString();
|
|
|
+
|
|
|
+ }
|
|
|
if (index >= 1) {
|
|
|
sqlMap.put(ruleField + index, ruleValue);
|
|
|
} else {
|
|
|
@@ -182,7 +194,6 @@ public class StringBufferContentAspect {
|
|
|
}
|
|
|
}
|
|
|
invAccountQueryVo.setStringBufferContent(stringBuffer.toString());
|
|
|
- invAccountQueryVo.setStringBufferContentMap(sqlMap);
|
|
|
}
|
|
|
|
|
|
private void buildStringBuffer(StringBuilder stringBuffer, String ruleField, String descByCode, String ruleValue) {
|
|
|
@@ -196,11 +207,16 @@ public class StringBufferContentAspect {
|
|
|
String commonSqlPrefix = String.format(" and %s %s", ruleField, descByCode);
|
|
|
String sqlFragment;
|
|
|
if (descByCode.contains("in")) {
|
|
|
- // 如果是in的情况,添加括号包裹map取值部分
|
|
|
- sqlFragment = commonSqlPrefix + String.format(" (#{mapValue.%s})", mapValueKey);
|
|
|
+ if(!ruleValue.contains(",")){
|
|
|
+ sqlFragment = commonSqlPrefix + " ('"+ruleValue+"') ";
|
|
|
+
|
|
|
+ }else {
|
|
|
+ // 如果是in的情况,添加括号包裹map取值部分
|
|
|
+ sqlFragment = commonSqlPrefix + " ("+ruleValue+") ";
|
|
|
+ }
|
|
|
} else {
|
|
|
// 其他情况直接拼接map取值部分
|
|
|
- sqlFragment = commonSqlPrefix + String.format(" #{mapValue.%s}", mapValueKey);
|
|
|
+ sqlFragment = commonSqlPrefix + " '"+ruleValue+"' ";
|
|
|
}
|
|
|
stringBuffer.append(sqlFragment);
|
|
|
}
|