package cn.gistack.sm.patrol.util;
|
|
import org.springblade.core.mp.base.BaseEntity;
|
import org.springblade.core.secure.BladeUser;
|
import org.springblade.core.secure.utils.AuthUtil;
|
import org.springblade.core.tool.utils.DateUtil;
|
import org.springblade.core.tool.utils.Func;
|
|
import java.util.Date;
|
|
/**
|
* @ClassName EnhancementServicesTool
|
* @Description TODO 给框架重写save方法导致没有默认技术字段赋值的解决方法
|
* @Author guoshilong
|
* @Date 2022/11/25
|
* @Version 1.0
|
*/
|
public class EnhancementServicesTool<T extends BaseEntity> {
|
public void resolveEntity(T entity) {
|
try {
|
BladeUser user = AuthUtil.getUser();
|
Date now = DateUtil.now();
|
if (entity.getId() == null) {
|
if (user != null) {
|
entity.setCreateUser(user.getUserId());
|
entity.setCreateDept(Func.firstLong(user.getDeptId()));
|
entity.setUpdateUser(user.getUserId());
|
}
|
|
if (entity.getStatus() == null) {
|
entity.setStatus(1);
|
}
|
|
entity.setCreateTime(now);
|
} else if (user != null) {
|
entity.setUpdateUser(user.getUserId());
|
}
|
|
entity.setUpdateTime(now);
|
entity.setIsDeleted(0);
|
|
} catch (Throwable var8) {
|
throw var8;
|
}
|
}
|
}
|