绑定系统字段调整,update方法时 不处理create_user_id和create_time字段
This commit is contained in:
parent
d9feee5a28
commit
d2c824e64d
|
@ -10,6 +10,7 @@ import org.aspectj.lang.JoinPoint;
|
|||
import org.aspectj.lang.annotation.Aspect;
|
||||
import org.aspectj.lang.annotation.Before;
|
||||
import org.aspectj.lang.annotation.Pointcut;
|
||||
import org.aspectj.lang.reflect.MethodSignature;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
@ -38,6 +39,9 @@ public class BindUserIdAop {
|
|||
if (StpUtil.isLogin()) {
|
||||
Object loginId = StpUtil.getLoginId();
|
||||
Object obj = objs[0];
|
||||
// 获取方法签名
|
||||
MethodSignature signature = (MethodSignature) point.getSignature();
|
||||
String methodName = signature.getName();
|
||||
if (obj instanceof HashMap) {
|
||||
((HashMap<String,Object>) obj).put("create_user_id",loginId);
|
||||
((HashMap<String,Object>) obj).put("modify_user_id",loginId);
|
||||
|
@ -51,21 +55,25 @@ public class BindUserIdAop {
|
|||
jsonStrObj = JSON.parseObject(jsonStr);
|
||||
}
|
||||
if(null != jsonStrObj){
|
||||
if (jsonStrObj.getString("create_user_id") == null) {
|
||||
jsonStrObj.put("create_user_id",loginId);
|
||||
}
|
||||
//如果是update的方法,则不处理create_user_id 和 create_time
|
||||
if (jsonStrObj.getString("modify_user_id") == null) {
|
||||
jsonStrObj.put("modify_user_id",loginId);
|
||||
}
|
||||
if (jsonStrObj.getString("create_time") == null) {
|
||||
jsonStrObj.put("create_time",DateUtil.now());
|
||||
}
|
||||
if (jsonStrObj.getString("modify_time") == null) {
|
||||
jsonStrObj.put("modify_time",DateUtil.now());
|
||||
}
|
||||
//save方法才要赋值create_user_id 和 creat_time id
|
||||
if (methodName.startsWith("save")){
|
||||
if (jsonStrObj.getString("create_user_id") == null) {
|
||||
jsonStrObj.put("create_user_id",loginId);
|
||||
}
|
||||
if (jsonStrObj.getString("create_time") == null) {
|
||||
jsonStrObj.put("create_time",DateUtil.now());
|
||||
}
|
||||
if (jsonStrObj.getString("id") == null) {
|
||||
jsonStrObj.put("id",UUIDLong.longUUID());
|
||||
}
|
||||
}
|
||||
}else{
|
||||
jsonStrObj = new JSONObject();
|
||||
jsonStrObj.put("create_user_id",loginId);
|
||||
|
|
Loading…
Reference in New Issue