update 修改 BaseEntity 创建人, 修改人字段类型, 修改相关 LambdaQueryWrapper 类型判断 ;

update 修改 CreateAndUpdateMetaObjectHandler#insertFill 字段填充保存相关参数id ;
feature/model
zlyx 2 years ago
parent 1e1c79f163
commit 3ba8323cb7

@ -31,11 +31,17 @@ public class BaseEntity implements Serializable {
@TableField(exist = false)
private String searchValue;
/**
*
*/
@TableField(fill = FieldFill.INSERT)
private Long createDept;
/**
*
*/
@TableField(fill = FieldFill.INSERT)
private String createBy;
private Long createBy;
/**
*
@ -47,7 +53,7 @@ public class BaseEntity implements Serializable {
*
*/
@TableField(fill = FieldFill.INSERT_UPDATE)
private String updateBy;
private Long updateBy;
/**
*

@ -30,12 +30,17 @@ public class CreateAndUpdateMetaObjectHandler implements MetaObjectHandler {
? baseEntity.getCreateTime() : new Date();
baseEntity.setCreateTime(current);
baseEntity.setUpdateTime(current);
String username = StringUtils.isNotBlank(baseEntity.getCreateBy())
? baseEntity.getCreateBy() : getLoginUsername();
LoginUser loginUser = LoginHelper.getLoginUser();
Long userId = ObjectUtil.isNotNull(baseEntity.getCreateBy())
? baseEntity.getCreateBy() : loginUser.getUserId();
// 当前已登录 且 创建人为空 则填充
baseEntity.setCreateBy(username);
baseEntity.setCreateBy(userId);
// 当前已登录 且 更新人为空 则填充
baseEntity.setUpdateBy(username);
baseEntity.setUpdateBy(userId);
// 创建部门
Long deptId = ObjectUtil.isNotNull(baseEntity.getCreateDept())
? baseEntity.getCreateDept() : loginUser.getDeptId();
baseEntity.setCreateDept(deptId);
}
} catch (Exception e) {
throw new ServiceException("自动注入异常 => " + e.getMessage(), HttpStatus.HTTP_UNAUTHORIZED);
@ -49,11 +54,8 @@ public class CreateAndUpdateMetaObjectHandler implements MetaObjectHandler {
Date current = new Date();
// 更新时间填充(不管为不为空)
baseEntity.setUpdateTime(current);
String username = getLoginUsername();
// 当前已登录 更新人填充(不管为不为空)
if (StringUtils.isNotBlank(username)) {
baseEntity.setUpdateBy(username);
}
baseEntity.setUpdateBy(LoginHelper.getUserId());
}
} catch (Exception e) {
throw new ServiceException("自动注入异常 => " + e.getMessage(), HttpStatus.HTTP_UNAUTHORIZED);

@ -68,7 +68,7 @@ public class TestDemoVo implements Serializable {
*
*/
@ExcelProperty(value = "创建人")
private String createBy;
private Long createBy;
/**
*
@ -80,7 +80,7 @@ public class TestDemoVo implements Serializable {
*
*/
@ExcelProperty(value = "更新人")
private String updateBy;
private Long updateBy;
}

@ -2,6 +2,7 @@ package com.ruoyi.generator.util;
import com.ruoyi.common.core.constant.GenConstants;
import com.ruoyi.common.core.utils.StringUtils;
import com.ruoyi.common.satoken.utils.LoginHelper;
import com.ruoyi.generator.config.GenConfig;
import com.ruoyi.generator.domain.GenTable;
import com.ruoyi.generator.domain.GenTableColumn;
@ -29,7 +30,7 @@ public class GenUtils {
genTable.setBusinessName(getBusinessName(genTable.getTableName()));
genTable.setFunctionName(replaceText(genTable.getTableComment()));
genTable.setFunctionAuthor(GenConfig.getAuthor());
genTable.setCreateBy(operName);
genTable.setCreateBy(LoginHelper.getUserId());
}
/**

@ -50,7 +50,7 @@ public class SysOssVo implements Serializable {
/**
*
*/
private String createBy;
private Long createBy;
/**
*

@ -57,7 +57,7 @@ public class SysUserImportListener extends AnalysisEventListener<SysUserImportVo
user = BeanUtil.toBean(userVo, SysUser.class);
ValidatorUtils.validate(user);
user.setPassword(password);
user.setCreateBy(operName);
user.setCreateBy(LoginHelper.getUserId());
userService.insertUser(user);
successNum++;
successMsg.append("<br/>").append(successNum).append("、账号 ").append(user.getUserName()).append(" 导入成功");
@ -68,7 +68,7 @@ public class SysUserImportListener extends AnalysisEventListener<SysUserImportVo
ValidatorUtils.validate(user);
userService.checkUserAllowed(user);
userService.checkUserDataScope(user.getUserId());
user.setUpdateBy(operName);
user.setUpdateBy(LoginHelper.getUserId());
userService.updateUser(user);
successNum++;
successMsg.append("<br/>").append(successNum).append("、账号 ").append(user.getUserName()).append(" 更新成功");

@ -81,7 +81,7 @@ public class SysLoginService {
LoginHelper.loginByDevice(loginUser, DeviceType.PC);
recordLogininfor(username, Constants.LOGIN_SUCCESS, MessageUtils.message("user.login.success"));
recordLoginInfo(user.getUserId(), username);
recordLoginInfo(user.getUserId());
return StpUtil.getTokenValue();
}
@ -96,7 +96,7 @@ public class SysLoginService {
LoginHelper.loginByDevice(loginUser, DeviceType.APP);
recordLogininfor(user.getUserName(), Constants.LOGIN_SUCCESS, MessageUtils.message("user.login.success"));
recordLoginInfo(user.getUserId(), user.getUserName());
recordLoginInfo(user.getUserId());
return StpUtil.getTokenValue();
}
@ -118,7 +118,7 @@ public class SysLoginService {
LoginHelper.loginByDevice(loginUser, DeviceType.XCX);
recordLogininfor(user.getUserName(), Constants.LOGIN_SUCCESS, MessageUtils.message("user.login.success"));
recordLoginInfo(user.getUserId(), user.getUserName());
recordLoginInfo(user.getUserId());
return StpUtil.getTokenValue();
}
@ -232,7 +232,7 @@ public class SysLoginService {
private LoginUser buildLoginUser(SysUser user) {
LoginUser loginUser = new LoginUser();
loginUser.setUserId(user.getUserId());
loginUser.setDeptId(user.getDeptId());
loginUser.setDeptId(ObjectUtil.isNull(user.getDept()) ? null : user.getDept().getDeptId());
loginUser.setUsername(user.getUserName());
loginUser.setUserType(user.getUserType());
loginUser.setMenuPermission(permissionService.getMenuPermission(user));
@ -248,12 +248,12 @@ public class SysLoginService {
*
* @param userId ID
*/
public void recordLoginInfo(Long userId, String username) {
public void recordLoginInfo(Long userId) {
SysUser sysUser = new SysUser();
sysUser.setUserId(userId);
sysUser.setLoginIp(ServletUtils.getClientIP());
sysUser.setLoginDate(DateUtils.getNowDate());
sysUser.setUpdateBy(username);
sysUser.setUpdateBy(userId);
userMapper.updateById(sysUser);
}

@ -1,5 +1,6 @@
package com.ruoyi.system.service.impl;
import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.ruoyi.common.mybatis.core.page.PageQuery;
@ -30,7 +31,7 @@ public class SysNoticeServiceImpl implements ISysNoticeService {
LambdaQueryWrapper<SysNotice> lqw = new LambdaQueryWrapper<SysNotice>()
.like(StringUtils.isNotBlank(notice.getNoticeTitle()), SysNotice::getNoticeTitle, notice.getNoticeTitle())
.eq(StringUtils.isNotBlank(notice.getNoticeType()), SysNotice::getNoticeType, notice.getNoticeType())
.like(StringUtils.isNotBlank(notice.getCreateBy()), SysNotice::getCreateBy, notice.getCreateBy());
.like(ObjectUtil.isNotNull(notice.getCreateBy()), SysNotice::getCreateBy, notice.getCreateBy());
Page<SysNotice> page = baseMapper.selectPage(pageQuery.build(), lqw);
return TableDataInfo.build(page);
}
@ -57,7 +58,7 @@ public class SysNoticeServiceImpl implements ISysNoticeService {
return baseMapper.selectList(new LambdaQueryWrapper<SysNotice>()
.like(StringUtils.isNotBlank(notice.getNoticeTitle()), SysNotice::getNoticeTitle, notice.getNoticeTitle())
.eq(StringUtils.isNotBlank(notice.getNoticeType()), SysNotice::getNoticeType, notice.getNoticeType())
.like(StringUtils.isNotBlank(notice.getCreateBy()), SysNotice::getCreateBy, notice.getCreateBy()));
.like(ObjectUtil.isNotNull(notice.getCreateBy()), SysNotice::getCreateBy, notice.getCreateBy()));
}
/**

@ -78,7 +78,7 @@ public class SysOssServiceImpl implements ISysOssService {
lqw.eq(StringUtils.isNotBlank(bo.getUrl()), SysOss::getUrl, bo.getUrl());
lqw.between(params.get("beginCreateTime") != null && params.get("endCreateTime") != null,
SysOss::getCreateTime, params.get("beginCreateTime"), params.get("endCreateTime"));
lqw.eq(StringUtils.isNotBlank(bo.getCreateBy()), SysOss::getCreateBy, bo.getCreateBy());
lqw.eq(ObjectUtil.isNotNull(bo.getCreateBy()), SysOss::getCreateBy, bo.getCreateBy());
lqw.eq(StringUtils.isNotBlank(bo.getService()), SysOss::getService, bo.getService());
return lqw;
}

@ -287,8 +287,8 @@ public class SysUserServiceImpl implements ISysUserService {
*/
@Override
public boolean registerUser(SysUser user) {
user.setCreateBy(user.getUserName());
user.setUpdateBy(user.getUserName());
user.setCreateBy(user.getUserId());
user.setUpdateBy(user.getUserId());
return baseMapper.insert(user) > 0;
}

Loading…
Cancel
Save