|
@@ -2,12 +2,14 @@
|
|
|
package com.jy.log.record;
|
|
|
|
|
|
import cn.hutool.core.util.ObjectUtil;
|
|
|
+import cn.hutool.core.util.ReflectUtil;
|
|
|
import cn.hutool.core.util.StrUtil;
|
|
|
import cn.hutool.extra.spring.SpringUtil;
|
|
|
import com.alibaba.fastjson2.JSON;
|
|
|
import com.alibaba.fastjson2.JSONObject;
|
|
|
import com.jy.framework.model.annotation.RecordAudit;
|
|
|
import com.jy.framework.model.base.BaseIdPo;
|
|
|
+import com.jy.framework.model.enums.BusinessType;
|
|
|
import com.jy.framework.model.enums.LogTagExtendedType;
|
|
|
import com.jy.framework.satoken.LoginContext;
|
|
|
import com.jy.framework.utils.AssertUtil;
|
|
@@ -89,12 +91,6 @@ public class RecordAuditAspect {
|
|
|
if (result instanceof BaseIdPo baseIdPo) {
|
|
|
logUserOperation.setBusinessId(baseIdPo.getId());
|
|
|
}
|
|
|
-
|
|
|
- if (args != null && args.length == 1) {
|
|
|
- Object newObject = JSON.parseObject(JSON.toJSONString(args[0]), parameterTypes[0]);
|
|
|
- String description = LogTagUtil.getObjectAllLogTag(newObject);
|
|
|
- logUserOperation.setDescription(description);
|
|
|
- }
|
|
|
}
|
|
|
case UPDATE -> {
|
|
|
if (args != null && args.length == 1 && args[0] instanceof BaseIdPo) {
|
|
@@ -121,20 +117,16 @@ public class RecordAuditAspect {
|
|
|
logUserOperation.setAuditStatus(0);
|
|
|
Object oldData = getOldData(point, signature, recordAudit);
|
|
|
logUserOperation.setSourceData(JSONObject.toJSONString(oldData));
|
|
|
-
|
|
|
- if (ObjectUtil.isNotEmpty(oldData)) {
|
|
|
- if (oldData instanceof Collection<?> oldDataCollection) {
|
|
|
- String description = oldDataCollection.stream().map(LogTagUtil::getObjectAllLogTag).collect(Collectors.joining("; ", "删除数据:{", "}"));
|
|
|
- logUserOperation.setDescription(description);
|
|
|
- } else {
|
|
|
- String description = LogTagUtil.getObjectAllLogTag(oldData);
|
|
|
- logUserOperation.setDescription("删除数据:" + description);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
}
|
|
|
case OTHER -> {
|
|
|
+ logUserOperation.setOperationType(BusinessType.UPDATE.getKey());
|
|
|
logUserOperation.setAuditStatus(1);
|
|
|
+ if (args != null && args.length == 1 && StrUtil.isNotBlank(recordAudit.businessIdField())) {
|
|
|
+ Object arg = args[0];
|
|
|
+ Field field = ReflectUtil.getField(arg.getClass(), recordAudit.businessIdField());
|
|
|
+ field.setAccessible(true);
|
|
|
+ logUserOperation.setBusinessId(Long.valueOf(field.get(arg).toString()));
|
|
|
+ }
|
|
|
point.proceed();
|
|
|
}
|
|
|
}
|