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