|
@@ -1,5 +1,6 @@
|
|
|
package com.ydtech.handler;
|
|
package com.ydtech.handler;
|
|
|
|
|
|
|
|
|
|
+import cn.dev33.satoken.context.SaHolder;
|
|
|
import cn.dev33.satoken.stp.StpUtil;
|
|
import cn.dev33.satoken.stp.StpUtil;
|
|
|
import cn.hutool.core.util.ObjectUtil;
|
|
import cn.hutool.core.util.ObjectUtil;
|
|
|
import cn.hutool.http.HttpStatus;
|
|
import cn.hutool.http.HttpStatus;
|
|
@@ -13,7 +14,7 @@ import org.apache.ibatis.reflection.MetaObject;
|
|
|
import java.util.Date;
|
|
import java.util.Date;
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
- * MP注入处理器 抄来的
|
|
|
|
|
|
|
+ * MP注入处理器 抄来的
|
|
|
*
|
|
*
|
|
|
* @author: lig
|
|
* @author: lig
|
|
|
* @date: 2023年06月30日 0030
|
|
* @date: 2023年06月30日 0030
|
|
@@ -30,17 +31,8 @@ public class CreateAndUpdateMetaObjectHandler implements MetaObjectHandler {
|
|
|
? baseEntity.getCreateTime() : new Date();
|
|
? baseEntity.getCreateTime() : new Date();
|
|
|
baseEntity.setCreateTime(current);
|
|
baseEntity.setCreateTime(current);
|
|
|
// baseEntity.setUpdateTime(current);
|
|
// baseEntity.setUpdateTime(current);
|
|
|
- String username;
|
|
|
|
|
-
|
|
|
|
|
- if (StringUtils.isNotBlank(baseEntity.getCreateBy())) {
|
|
|
|
|
- username = baseEntity.getCreateBy();
|
|
|
|
|
- } else {
|
|
|
|
|
- try {
|
|
|
|
|
- username = StpUtil.getLoginId().toString();
|
|
|
|
|
- } catch (Exception e) {
|
|
|
|
|
- username = null;
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ String username = StringUtils.isNotBlank(baseEntity.getCreateBy())
|
|
|
|
|
+ ? baseEntity.getCreateBy() : StpUtil.getLoginId("");
|
|
|
|
|
|
|
|
// 当前已登录 且 创建人为空 则填充
|
|
// 当前已登录 且 创建人为空 则填充
|
|
|
baseEntity.setCreateBy(username);
|
|
baseEntity.setCreateBy(username);
|
|
@@ -48,7 +40,7 @@ public class CreateAndUpdateMetaObjectHandler implements MetaObjectHandler {
|
|
|
// baseEntity.setUpdateBy(username);
|
|
// baseEntity.setUpdateBy(username);
|
|
|
}
|
|
}
|
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
|
- throw new SystemException(StringUtils.toString(HttpStatus.HTTP_UNAUTHORIZED), "自动注入异常 => " + e.getMessage());
|
|
|
|
|
|
|
+ throw new SystemException(StringUtils.toString(HttpStatus.HTTP_UNAUTHORIZED),"自动注入异常 => " + e.getMessage());
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -67,7 +59,7 @@ public class CreateAndUpdateMetaObjectHandler implements MetaObjectHandler {
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
|
- throw new SystemException(StringUtils.toString(HttpStatus.HTTP_UNAUTHORIZED), "自动注入异常 => " + e.getMessage());
|
|
|
|
|
|
|
+ throw new SystemException(StringUtils.toString(HttpStatus.HTTP_UNAUTHORIZED),"自动注入异常 => " + e.getMessage());
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|