|
|
@@ -36,9 +36,8 @@ import org.springframework.stereotype.Component;
|
|
|
|
|
|
import java.lang.reflect.Method;
|
|
|
import java.time.LocalDateTime;
|
|
|
-import java.util.Collection;
|
|
|
-import java.util.Map;
|
|
|
-import java.util.Objects;
|
|
|
+import java.util.*;
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
@Slf4j
|
|
|
@Aspect
|
|
|
@@ -136,7 +135,13 @@ public class OperatorTrajectoryAspect {
|
|
|
return StringUtils.join(arg);
|
|
|
} else if (arg instanceof String) {
|
|
|
return String.valueOf(arg);
|
|
|
- } else if (arg != null) {
|
|
|
+ } else if (arg instanceof String[]){
|
|
|
+ StringBuilder argStrBuilrder = new StringBuilder();
|
|
|
+ for (String s : (String[]) arg) {
|
|
|
+ argStrBuilrder.append(s).append(",");
|
|
|
+ }
|
|
|
+ return argStrBuilrder.substring(0, argStrBuilrder.length() - 1);
|
|
|
+ }else if (arg != null) {
|
|
|
JSONObject jsonObject = (JSONObject) JSON.toJSON(arg);
|
|
|
return jsonObject.getString(key);
|
|
|
}
|
|
|
@@ -148,6 +153,10 @@ public class OperatorTrajectoryAspect {
|
|
|
public void doBefore(JoinPoint point, OperatorTrajectory operatorTrajectory){
|
|
|
Object obj = point.getArgs()[0];
|
|
|
String id = getId(point,operatorTrajectory.primary());
|
|
|
+ List<String> ids = new ArrayList<>();
|
|
|
+ if (Objects.nonNull(id)){
|
|
|
+ ids = Arrays.stream(id.split(",")).collect(Collectors.toList());
|
|
|
+ }
|
|
|
if (isRecorded(operatorTrajectory.isRecorded(),obj)){
|
|
|
return;
|
|
|
}
|
|
|
@@ -183,24 +192,28 @@ public class OperatorTrajectoryAspect {
|
|
|
break;
|
|
|
//更新
|
|
|
case "U":
|
|
|
- beforeData = GetSelectIdDataUtils.selectById(operatorTrajectory.entityClass(), operatorTrajectory.mapperClass(), id);
|
|
|
- trajectory.setPrimaryValue(id);
|
|
|
- if (!Objects.isNull(beforeData)){
|
|
|
- trajectory.setBeforeJson(JSON.toJSONString(beforeData));
|
|
|
+ for (String s : ids) {
|
|
|
+ beforeData = GetSelectIdDataUtils.selectById(operatorTrajectory.entityClass(), operatorTrajectory.mapperClass(), s);
|
|
|
+ trajectory.setPrimaryValue(s);
|
|
|
+ if (!Objects.isNull(beforeData)) {
|
|
|
+ trajectory.setBeforeJson(JSON.toJSONString(beforeData));
|
|
|
+ }
|
|
|
+ trajectory.setOperationContent(DescriptionUtils.generateDescription(beforeData, operatorName));
|
|
|
+ operatorTrajectoryService.save(trajectory);
|
|
|
}
|
|
|
- trajectory.setOperationContent(DescriptionUtils.generateDescription(beforeData,operatorName));
|
|
|
- operatorTrajectoryService.save(trajectory);
|
|
|
break;
|
|
|
//删除
|
|
|
case "D":
|
|
|
- beforeData = GetSelectIdDataUtils.selectById(operatorTrajectory.entityClass(), operatorTrajectory.mapperClass(), id);
|
|
|
- trajectory.setPrimaryValue(id);
|
|
|
- trajectory.setBeforeJson(JSON.toJSONString(beforeData));
|
|
|
- trajectory.setOperationContent(DescriptionUtils.generateDescription(beforeData,operatorName));
|
|
|
- operatorTrajectoryService.save(trajectory);
|
|
|
- break;
|
|
|
- default:
|
|
|
- log.warn("Unsupported operator type: {}", operatorTrajectory.type());
|
|
|
+ for (String s : ids) {
|
|
|
+ beforeData = GetSelectIdDataUtils.selectById(operatorTrajectory.entityClass(), operatorTrajectory.mapperClass(), s);
|
|
|
+ trajectory.setPrimaryValue(s);
|
|
|
+ trajectory.setBeforeJson(JSON.toJSONString(beforeData));
|
|
|
+ trajectory.setOperationContent(DescriptionUtils.generateDescription(beforeData, operatorName));
|
|
|
+ operatorTrajectoryService.save(trajectory);
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ default:
|
|
|
+ log.warn("Unsupported operator type: {}", operatorTrajectory.type());
|
|
|
|
|
|
}
|
|
|
// 用于验证上下文
|