Browse Source

feat: [操作日志] 用户日志

master
memorylkf 2 months ago
parent
commit
dacb391e4f
18 changed files with 485 additions and 26 deletions
  1. +64
    -0
      hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/controller/RoleChangeController.java
  2. +123
    -0
      hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/domain/RoleChange.java
  3. +14
    -0
      hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/mapper/RoleChangeMapper.java
  4. +37
    -0
      hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/service/IRoleChangeService.java
  5. +65
    -0
      hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/service/impl/RoleChangeServiceImpl.java
  6. +2
    -0
      hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/service/impl/SystemLogServiceImpl.java
  7. +48
    -2
      hxhq-modules/hxhq-system/src/main/java/com/hxhq/system/controller/SysRoleController.java
  8. +4
    -2
      hxhq-modules/hxhq-system/src/main/java/com/hxhq/system/controller/SysUserController.java
  9. +15
    -0
      hxhq-modules/hxhq-system/src/main/java/com/hxhq/system/form/RoleUserSaveForm.java
  10. +36
    -0
      hxhq-modules/hxhq-system/src/main/java/com/hxhq/system/form/UserSaveForm.java
  11. +7
    -0
      hxhq-modules/hxhq-system/src/main/java/com/hxhq/system/mapper/SysRoleMapper.java
  12. +8
    -0
      hxhq-modules/hxhq-system/src/main/java/com/hxhq/system/service/ISysRoleService.java
  13. +2
    -1
      hxhq-modules/hxhq-system/src/main/java/com/hxhq/system/service/ISysUserService.java
  14. +3
    -2
      hxhq-modules/hxhq-system/src/main/java/com/hxhq/system/service/impl/SysMenuServiceImpl.java
  15. +8
    -2
      hxhq-modules/hxhq-system/src/main/java/com/hxhq/system/service/impl/SysRoleServiceImpl.java
  16. +35
    -17
      hxhq-modules/hxhq-system/src/main/java/com/hxhq/system/service/impl/SysUserServiceImpl.java
  17. +6
    -0
      hxhq-modules/hxhq-system/src/main/resources/mapper/business/RoleChangeMapper.xml
  18. +8
    -0
      hxhq-modules/hxhq-system/src/main/resources/mapper/system/SysRoleMapper.xml

+ 64
- 0
hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/controller/RoleChangeController.java View File

@ -0,0 +1,64 @@
package com.hxhq.business.controller;
import java.util.Arrays;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.hxhq.business.domain.RoleChange;
import com.hxhq.business.service.IRoleChangeService;
import com.hxhq.common.core.web.controller.BaseController;
import com.hxhq.common.core.web.domain.AjaxResult;
import com.hxhq.common.core.web.page.TableDataInfo;
/**
* 角色变更历史Controller
*
* @author hxhq
* @date 2026-02-04
*/
@RestController
@RequestMapping("/business/roleChange")
public class RoleChangeController extends BaseController
{
@Autowired
private IRoleChangeService roleChangeService;
/**
* 查询角色变更历史列表
*/
@GetMapping("/list")
public TableDataInfo list(RoleChange roleChange)
{
startPage();
List<RoleChange> list = roleChangeService.queryList(roleChange);
return getDataTable(list);
}
/**
* 获取角色变更历史详细信息
*/
@GetMapping(value = "/info")
public AjaxResult getInfo(Long id)
{
return AjaxResult.success(roleChangeService.getById(id));
}
/**
* 新增角色变更历史信息
*/
@PostMapping("/save")
public AjaxResult save(@RequestBody RoleChange roleChange)
{
return toAjax(roleChangeService.saveOrUpdate(roleChange));
}
/**
* 删除角色变更历史信息
*/
@PostMapping("/delete")
public AjaxResult delete(@RequestBody Long[] ids)
{
return toAjax(roleChangeService.removeByIds(Arrays.asList(ids)));
}
}

+ 123
- 0
hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/domain/RoleChange.java View File

@ -0,0 +1,123 @@
package com.hxhq.business.domain;
import com.baomidou.mybatisplus.annotation.TableName;
import com.hxhq.common.core.domain.MpBaseEntity;
/**
* 角色变更历史对象 t_role_change
*
* @author hxhq
* @date 2026-02-04
*/
@TableName("t_role_change")
public class RoleChange extends MpBaseEntity
{
private static final long serialVersionUID = 1L;
/** 用户id */
private Long userId;
/** 操作类型 */
private String jcmc;
/** 操作类型-英文 */
private String jcmcEn;
/** 操作人id */
private Long qmrId;
/** 操作人名称 */
private String qmrMc;
/** 操作人名称-英文 */
private String qmrMcEn;
/** 变更前角色 */
private String bgq;
/** 变更后角色 */
private String bgh;
public void setUserId(Long userId)
{
this.userId = userId;
}
public Long getUserId()
{
return userId;
}
public void setJcmc(String jcmc)
{
this.jcmc = jcmc;
}
public String getJcmc()
{
return jcmc;
}
public void setJcmcEn(String jcmcEn)
{
this.jcmcEn = jcmcEn;
}
public String getJcmcEn()
{
return jcmcEn;
}
public void setQmrId(Long qmrId)
{
this.qmrId = qmrId;
}
public Long getQmrId()
{
return qmrId;
}
public void setQmrMc(String qmrMc)
{
this.qmrMc = qmrMc;
}
public String getQmrMc()
{
return qmrMc;
}
public void setQmrMcEn(String qmrMcEn)
{
this.qmrMcEn = qmrMcEn;
}
public String getQmrMcEn()
{
return qmrMcEn;
}
public void setBgq(String bgq)
{
this.bgq = bgq;
}
public String getBgq()
{
return bgq;
}
public void setBgh(String bgh)
{
this.bgh = bgh;
}
public String getBgh()
{
return bgh;
}
}

+ 14
- 0
hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/mapper/RoleChangeMapper.java View File

@ -0,0 +1,14 @@
package com.hxhq.business.mapper;
import com.hxhq.business.domain.RoleChange;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
/**
* 角色变更历史Mapper接口
*
* @author hxhq
* @date 2026-02-04
*/
public interface RoleChangeMapper extends BaseMapper<RoleChange>
{
}

+ 37
- 0
hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/service/IRoleChangeService.java View File

@ -0,0 +1,37 @@
package com.hxhq.business.service;
import java.util.List;
import com.hxhq.business.domain.RoleChange;
import com.baomidou.mybatisplus.extension.service.IService;
/**
* 角色变更历史Service接口
*
* @author hxhq
* @date 2026-02-04
*/
public interface IRoleChangeService extends IService<RoleChange>
{
/**
* 查询角色变更历史列表
*
* @param roleChange 角色变更历史
* @return 角色变更历史集合
*/
public List<RoleChange> queryList(RoleChange roleChange);
/**
* 保存
* @param userId
* @param bgq
* @param bgh
* @param remark
*/
void saveInfo(Long userId,String bgq,String bgh,String remark);
/**
* 批量保存
* @param list
*/
void saveList(List<RoleChange> list);
}

+ 65
- 0
hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/service/impl/RoleChangeServiceImpl.java View File

@ -0,0 +1,65 @@
package com.hxhq.business.service.impl;
import java.util.List;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.hxhq.common.core.utils.DateUtils;
import com.hxhq.common.security.utils.SecurityUtils;
import org.springframework.stereotype.Service;
import com.hxhq.business.mapper.RoleChangeMapper;
import com.hxhq.business.domain.RoleChange;
import com.hxhq.business.service.IRoleChangeService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
/**
* 角色变更历史Service业务层处理
*
* @author hxhq
* @date 2026-02-04
*/
@Service
public class RoleChangeServiceImpl extends ServiceImpl<RoleChangeMapper, RoleChange> implements IRoleChangeService
{
/**
* 查询角色变更历史列表
*
* @param roleChange 角色变更历史
* @return 角色变更历史
*/
@Override
public List<RoleChange> queryList(RoleChange roleChange)
{
QueryWrapper<RoleChange> queryWrapper = Wrappers.query();
return this.list(queryWrapper);
}
@Override
public void saveInfo(Long userId, String bgq, String bgh, String remark) {
RoleChange roleChange = new RoleChange();
roleChange.setUserId(userId);
roleChange.setBgq(bgq);
roleChange.setBgh(bgh);
roleChange.setRemark(remark);
roleChange.setJcmc("分配角色");
roleChange.setJcmcEn("Role Change");
roleChange.setQmrId(SecurityUtils.getUserId());
roleChange.setQmrMc(SecurityUtils.getNickName());
roleChange.setQmrMcEn(SecurityUtils.getUsername());
save(roleChange);
}
@Override
public void saveList(List<RoleChange> list) {
for(RoleChange roleChange : list){
roleChange.setJcmc("分配角色");
roleChange.setJcmcEn("Role Change");
roleChange.setQmrId(SecurityUtils.getUserId());
roleChange.setQmrMc(SecurityUtils.getNickName());
roleChange.setQmrMcEn(SecurityUtils.getUsername());
}
if(list.size()>0){
saveBatch(list);
}
}
}

+ 2
- 0
hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/service/impl/SystemLogServiceImpl.java View File

@ -61,6 +61,7 @@ public class SystemLogServiceImpl extends ServiceImpl
public void saveStudyInfo(Study study, String jcnr, String jcnrEn, SignForm signForm) {
SystemLog info = new SystemLog();
info.setName(study.getName()+"("+study.getSn()+")");
info.setNameEn(study.getName()+"("+study.getSn()+")");
info.setJcnr(jcnr);
info.setJcnrEn(jcnrEn);
info.setJcmc(signForm.getQmyy());
@ -78,6 +79,7 @@ public class SystemLogServiceImpl extends ServiceImpl
for(StudyJcgj jcgj : jcgjList){
SystemLog info = new SystemLog();
info.setName(study.getName()+"("+study.getSn()+")");
info.setNameEn(study.getName()+"("+study.getSn()+")");
info.setJcnr(jcgj.getJcnr());
info.setJcnrEn(jcgj.getJcnrEn());
info.setJcmc(jcgj.getJcmc());

+ 48
- 2
hxhq-modules/hxhq-system/src/main/java/com/hxhq/system/controller/SysRoleController.java View File

@ -5,8 +5,13 @@ import java.util.List;
import java.util.stream.Collectors;
import javax.servlet.http.HttpServletResponse;
import com.hxhq.business.domain.RoleChange;
import com.hxhq.business.domain.SystemLog;
import com.hxhq.business.form.common.SignForm;
import com.hxhq.business.service.IRoleChangeService;
import com.hxhq.business.service.ISystemLogService;
import com.hxhq.common.core.exception.ServiceException;
import com.hxhq.common.core.utils.StringUtils;
import com.hxhq.system.domain.SysUserRole;
import com.hxhq.system.form.RoleUserSaveForm;
import com.hxhq.system.service.ISysDeptService;
@ -56,6 +61,9 @@ public class SysRoleController extends BaseController
@Autowired
private ISystemLogService systemLogService;
@Autowired
private IRoleChangeService roleChangeService;
@RequiresPermissions("system:role:list")
@GetMapping("/list")
public TableDataInfo list(SysRole role)
@ -244,11 +252,45 @@ public class SysRoleController extends BaseController
@Transactional(rollbackFor = Exception.class)
public AjaxResult setAll(@RequestBody RoleUserSaveForm form)
{
SignForm sign = form.getSign();
if(sign==null){
throw new ServiceException("签名参数有误");
}
if(StringUtils.isBlank(sign.getQmrmm())){
throw new ServiceException("签名密码不能为空");
}
userService.checkPassword(SecurityUtils.getLoginUser().getSysUser(),sign.getQmrmm(),false);
SysRole sysRole = roleService.selectRoleById(form.getRoleId());
List<Long> existsUserIds = userService.selectAllocatedListSimple(form.getRoleId());
List<Long> deleteIds = existsUserIds.stream().filter(o->!form.getUserIdList().contains(o)).collect(Collectors.toList());
List<Long> addList = form.getUserIdList().stream().filter(o->!existsUserIds.contains(o)).collect(Collectors.toList());
//角色变更历史
List<RoleChange> roleChangelist = new ArrayList<>();
if(addList.size()>0){
for(Long addId :addList){
List<String> oldNameList = roleService.selectRoleNameListByUserId(addId);
RoleChange roleChange = new RoleChange();
roleChange.setUserId(addId);
roleChange.setBgq(oldNameList.size()>0?String.join(",",oldNameList):"");
roleChange.setBgh(roleChange.getBgq()+","+sysRole.getRoleName());
roleChange.setRemark(sign.getRemark());
roleChangelist.add(roleChange);
}
}
if(deleteIds.size()>0){
for(Long deleteId :deleteIds){
List<String> oldNameList = roleService.selectRoleNameListByUserId(deleteId);
RoleChange roleChange = new RoleChange();
roleChange.setUserId(deleteId);
roleChange.setBgq(oldNameList.size()>0?String.join(",",oldNameList):"");
roleChange.setBgh(roleChange.getBgq().replace(","+sysRole.getRoleName(),"").replace(","+sysRole.getRoleName()+",","").replace(sysRole.getRoleName()+",",""));
roleChange.setRemark(sign.getRemark());
roleChangelist.add(roleChange);
}
}
List<String> deleteUserNames = new ArrayList<>();
List<String> addUserNames = new ArrayList<>();
if(deleteIds.size()>0){
@ -263,16 +305,20 @@ public class SysRoleController extends BaseController
if(addUserNames.size()>0 || deleteUserNames.size()>0){
SystemLog log = new SystemLog();
log.setName(sysRole.getRoleName());
log.setNameEn(sysRole.getRoleName());
log.setJcmc("分配用户");
log.setJcmcEn("Add User");
log.setQmrId(SecurityUtils.getUserId());
log.setQmrMc(SecurityUtils.getNickName());
log.setQmrMcEn(SecurityUtils.getUsername());
log.setJcnr((addUserNames.size()>0?("新增用户:"+String.join(",",addUserNames)):"")+(deleteUserNames.size()>0?(";删除用户:"+String.join(",",deleteUserNames)):""));
log.setJcnrEn((addUserNames.size()>0?("Add User:"+String.join(",",addUserNames)):"")+(deleteUserNames.size()>0?(";Remove User:"+String.join(",",deleteUserNames)):""));
log.setJcnr((addUserNames.size()>0?("新增用户:"+String.join(",",addUserNames)):"")+(deleteUserNames.size()>0?(";删除用户:"+String.join(",",deleteUserNames)):"")+(StringUtils.isBlank(sign.getRemark())?"":";备注:"+sign.getRemark()));
log.setJcnrEn((addUserNames.size()>0?("Add User:"+String.join(",",addUserNames)):"")+(deleteUserNames.size()>0?(";Remove User:"+String.join(",",deleteUserNames)):"")+(StringUtils.isBlank(sign.getRemark())?"":";Comment:"+sign.getRemark()));
systemLogService.save(log);
}
if(roleChangelist.size()>0){
roleChangeService.saveList(roleChangelist);
}
return AjaxResult.success("操作成功");
}

+ 4
- 2
hxhq-modules/hxhq-system/src/main/java/com/hxhq/system/controller/SysUserController.java View File

@ -14,6 +14,7 @@ import com.hxhq.business.enums.dept.DeptTypeEnum;
import com.hxhq.business.enums.study.StudyTypeEnum;
import com.hxhq.business.service.IStudyService;
import com.hxhq.system.dto.UserExportDto;
import com.hxhq.system.form.UserSaveForm;
import com.hxhq.system.service.ISysConfigService;
import org.apache.commons.lang3.ArrayUtils;
import org.springframework.beans.factory.annotation.Autowired;
@ -320,8 +321,9 @@ public class SysUserController extends BaseController
@RequiresPermissions("system:user:edit")
@Log(title = "用户管理", businessType = BusinessType.UPDATE)
@PutMapping
public AjaxResult edit(@Validated @RequestBody SysUser user)
public AjaxResult edit(@Validated @RequestBody UserSaveForm form)
{
SysUser user = form.getUser();
userService.checkUserAllowed(user);
userService.checkUserDataScope(user.getUserId());
deptService.checkDeptDataScope(user.getDeptId());
@ -339,7 +341,7 @@ public class SysUserController extends BaseController
return error("修改用户'" + user.getUserName() + "'失败,邮箱账号已存在");
}
user.setUpdateBy(SecurityUtils.getUsername());
return toAjax(userService.updateUser(user));
return toAjax(userService.updateUser(form));
}
/**

+ 15
- 0
hxhq-modules/hxhq-system/src/main/java/com/hxhq/system/form/RoleUserSaveForm.java View File

@ -1,5 +1,7 @@
package com.hxhq.system.form;
import com.hxhq.business.form.common.SignForm;
import java.util.List;
/**
@ -16,6 +18,11 @@ public class RoleUserSaveForm {
*/
private List<Long> userIdList;
/**
* 签名信息
*/
private SignForm sign;
public Long getRoleId() {
return roleId;
}
@ -31,4 +38,12 @@ public class RoleUserSaveForm {
public void setUserIdList(List<Long> userIdList) {
this.userIdList = userIdList;
}
public SignForm getSign() {
return sign;
}
public void setSign(SignForm sign) {
this.sign = sign;
}
}

+ 36
- 0
hxhq-modules/hxhq-system/src/main/java/com/hxhq/system/form/UserSaveForm.java View File

@ -0,0 +1,36 @@
package com.hxhq.system.form;
import com.hxhq.business.form.common.SignForm;
import com.hxhq.system.api.domain.SysUser;
/**
* @author memory
*/
public class UserSaveForm {
/**
* 用户
*/
private SysUser user;
/**
* 签名信息
*/
private SignForm sign;
public SysUser getUser() {
return user;
}
public void setUser(SysUser user) {
this.user = user;
}
public SignForm getSign() {
return sign;
}
public void setSign(SignForm sign) {
this.sign = sign;
}
}

+ 7
- 0
hxhq-modules/hxhq-system/src/main/java/com/hxhq/system/mapper/SysRoleMapper.java View File

@ -42,6 +42,13 @@ public interface SysRoleMapper
public List<Long> selectRoleListByUserId(Long userId);
/**
* 根据用户ID获取角色名称列表
* @param userId
* @return
*/
public List<String> selectRoleNameListByUserId(Long userId);
/**
* 通过角色ID查询角色
*
* @param roleId 角色ID

+ 8
- 0
hxhq-modules/hxhq-system/src/main/java/com/hxhq/system/service/ISysRoleService.java View File

@ -52,6 +52,14 @@ public interface ISysRoleService
public List<Long> selectRoleListByUserId(Long userId);
/**
* 根据用户ID获取角色名称列表
*
* @param userId 用户ID
* @return 选中角色ID列表
*/
public List<String> selectRoleNameListByUserId(Long userId);
/**
* 通过角色ID查询角色
*
* @param roleId 角色ID

+ 2
- 1
hxhq-modules/hxhq-system/src/main/java/com/hxhq/system/service/ISysUserService.java View File

@ -6,6 +6,7 @@ import java.util.Map;
import com.hxhq.business.dto.select.BzListDto;
import com.hxhq.business.dto.select.DeptUserTreeDto;
import com.hxhq.system.api.domain.SysUser;
import com.hxhq.system.form.UserSaveForm;
/**
* 用户 业务层
@ -130,7 +131,7 @@ public interface ISysUserService
* @param user 用户信息
* @return 结果
*/
public int updateUser(SysUser user);
public int updateUser(UserSaveForm form);
/**
* 用户授权角色

+ 3
- 2
hxhq-modules/hxhq-system/src/main/java/com/hxhq/system/service/impl/SysMenuServiceImpl.java View File

@ -614,8 +614,9 @@ public class SysMenuServiceImpl implements ISysMenuService
private SystemLog getLogInfo(SysMenu info){
SystemLog log = new SystemLog();
log.setName(info.getMenuName());
log.setJcmc("修改菜单");
log.setJcmcEn("Modify Menu");
log.setNameEn(info.getMenuName());
log.setJcmc("编辑菜单");
log.setJcmcEn("Edit Menu");
log.setQmrId(SecurityUtils.getUserId());
log.setQmrMc(SecurityUtils.getNickName());
log.setQmrMcEn(SecurityUtils.getUsername());

+ 8
- 2
hxhq-modules/hxhq-system/src/main/java/com/hxhq/system/service/impl/SysRoleServiceImpl.java View File

@ -136,6 +136,11 @@ public class SysRoleServiceImpl implements ISysRoleService
return roleMapper.selectRoleListByUserId(userId);
}
@Override
public List<String> selectRoleNameListByUserId(Long userId) {
return roleMapper.selectRoleNameListByUserId(userId);
}
/**
* 通过角色ID查询角色
*
@ -535,8 +540,9 @@ public class SysRoleServiceImpl implements ISysRoleService
private SystemLog getLogInfo(SysRole sysRole){
SystemLog log = new SystemLog();
log.setName(sysRole.getRoleName());
log.setJcmc("修改角色");
log.setJcmcEn("Modify Role");
log.setNameEn(sysRole.getRoleName());
log.setJcmc("编辑角色");
log.setJcmcEn("Edit Role");
log.setQmrId(SecurityUtils.getUserId());
log.setQmrMc(SecurityUtils.getNickName());
log.setQmrMcEn(SecurityUtils.getUsername());

+ 35
- 17
hxhq-modules/hxhq-system/src/main/java/com/hxhq/system/service/impl/SysUserServiceImpl.java View File

@ -4,9 +4,13 @@ import java.util.*;
import java.util.stream.Collectors;
import javax.validation.Validator;
import com.alibaba.fastjson2.JSONArray;
import com.alibaba.fastjson2.JSONObject;
import com.hxhq.business.domain.SystemLog;
import com.hxhq.business.dto.select.BzListDto;
import com.hxhq.business.dto.select.DeptUserTreeDto;
import com.hxhq.business.form.common.SignForm;
import com.hxhq.business.service.IRoleChangeService;
import com.hxhq.business.service.ISystemLogService;
import com.hxhq.business.utils.ObjectCompareUtil;
import com.hxhq.system.api.domain.SysDept;
@ -14,6 +18,7 @@ import com.hxhq.system.domain.SysMenu;
import com.hxhq.system.domain.SysPost;
import com.hxhq.system.domain.SysUserPost;
import com.hxhq.system.domain.SysUserRole;
import com.hxhq.system.form.UserSaveForm;
import com.hxhq.system.service.ISysConfigService;
import com.hxhq.system.service.ISysDeptService;
import com.hxhq.system.service.ISysUserService;
@ -75,6 +80,9 @@ public class SysUserServiceImpl implements ISysUserService
@Autowired
private ISystemLogService systemLogService;
@Autowired
private IRoleChangeService roleChangeService;
/**
* 根据条件分页查询用户列表
*
@ -296,15 +304,20 @@ public class SysUserServiceImpl implements ISysUserService
/**
* 修改保存用户信息
*
* @param user 用户信息
* @param form 用户信息
* @return 结果
*/
@Override
@Transactional(rollbackFor = Exception.class)
public int updateUser(SysUser user)
public int updateUser(UserSaveForm form)
{
SysUser old = selectUserById(user.getUserId());
List<Long> oldRoleIdList = roleMapper.selectRoleListByUserId(user.getUserId());
SysUser user = form.getUser();
SignForm sign = form.getSign();
List<SystemLog> logList = getModifyLogList(user, sign);
if(logList.size()>0){
systemLogService.saveBatch(logList);
}
Long userId = user.getUserId();
// 删除用户与角色关联
@ -316,14 +329,7 @@ public class SysUserServiceImpl implements ISysUserService
// 新增用户与岗位管理
insertUserPost(user);
int row = userMapper.updateUser(user);
List<SystemLog> logList = getModifyLogList(user,old,oldRoleIdList);
if(logList.size()>0){
systemLogService.saveBatch(logList);
}
return row;
return userMapper.updateUser(user);
}
/**
@ -638,7 +644,10 @@ public class SysUserServiceImpl implements ISysUserService
return userMapper.selectNamesByIdList(idList);
}
private List<SystemLog> getModifyLogList(SysUser info, SysUser old, List<Long> oldRoleIdList){
private List<SystemLog> getModifyLogList(SysUser info, SignForm sign){
SysUser old = selectUserById(info.getUserId());
List<Long> oldRoleIdList = roleMapper.selectRoleListByUserId(info.getUserId());
List<SystemLog> list = new ArrayList<>();
List<ObjectCompareUtil.FieldChange> fieldChanges = ObjectCompareUtil.compareObjects(old, info);
@ -677,6 +686,8 @@ public class SysUserServiceImpl implements ISysUserService
}
}
if(updateRole){
checkPassword(SecurityUtils.getLoginUser().getSysUser(),sign.getQmrmm(),false);
List<SysRole> allRoleList = roleMapper.selectRoleList(new SysRole());
List<SysRole> oldRoleList = new ArrayList<>();
@ -692,11 +703,15 @@ public class SysUserServiceImpl implements ISysUserService
}
}
List<String> oldRoleNameList = oldRoleList.stream().map(o->o.getRoleName()).collect(Collectors.toList());
List<String> bghList = oldRoleList.stream().map(o->o.getRoleName()).collect(Collectors.toList());
List<String> addNameList = new ArrayList<>();
List<String> deleteNameList = new ArrayList<>();
for(SysRole newRole : newRoleList){
if(!oldRoleIdList.contains(newRole.getRoleId())){
addNameList.add(newRole.getRoleName());
bghList.add(newRole.getRoleName());
}
}
@ -704,15 +719,17 @@ public class SysUserServiceImpl implements ISysUserService
for(SysRole oldRole : oldRoleList){
if(!newMenuIdList.contains(oldRole.getRoleId())){
deleteNameList.add(oldRole.getRoleName());
bghList.remove(oldRole.getRoleName());
}
}
if(addNameList.size()>0 || deleteNameList.size()>0){
SystemLog log = getLogInfo(old);
log.setJcnr((addNameList.size()>0?("新增角色:"+String.join(",",addNameList)):"")+(deleteNameList.size()>0?(";删除角色:"+String.join(",",deleteNameList)):""));
log.setJcnrEn((addNameList.size()>0?("Add Role:"+String.join(",",addNameList)):"")+(deleteNameList.size()>0?(";Remove Role:"+String.join(",",deleteNameList)):""));
log.setJcnr((addNameList.size()>0?("新增角色:"+String.join(",",addNameList)):"")+(deleteNameList.size()>0?(";删除角色:"+String.join(",",deleteNameList)):"")+(StringUtils.isBlank(sign.getRemark())?"":";备注:"+sign.getRemark()));
log.setJcnrEn((addNameList.size()>0?("Add Role:"+String.join(",",addNameList)):"")+(deleteNameList.size()>0?(";Remove Role:"+String.join(",",deleteNameList)):"")+(StringUtils.isBlank(sign.getRemark())?"":";Comment:"+sign.getRemark()));
list.add(log);
}
roleChangeService.saveInfo(info.getUserId(),String.join(",",oldRoleNameList),String.join(",",bghList),sign.getRemark());
}
return list;
@ -725,8 +742,9 @@ public class SysUserServiceImpl implements ISysUserService
private SystemLog getLogInfo(SysUser sysUser){
SystemLog log = new SystemLog();
log.setName(sysUser.getNickName());
log.setJcmc("修改用户");
log.setJcmcEn("Modify User");
log.setNameEn(sysUser.getNickName());
log.setJcmc("编辑用户");
log.setJcmcEn("Edit User");
log.setQmrId(SecurityUtils.getUserId());
log.setQmrMc(SecurityUtils.getNickName());
log.setQmrMcEn(SecurityUtils.getUsername());

+ 6
- 0
hxhq-modules/hxhq-system/src/main/resources/mapper/business/RoleChangeMapper.xml View File

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.hxhq.business.mapper.RoleChangeMapper">
</mapper>

+ 8
- 0
hxhq-modules/hxhq-system/src/main/resources/mapper/system/SysRoleMapper.xml View File

@ -72,6 +72,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
left join sys_user u on u.user_id = ur.user_id
where u.user_id = #{userId}
</select>
<select id="selectRoleNameListByUserId" parameterType="Long" resultType="java.lang.String">
select r.role_name
from sys_role r
left join sys_user_role ur on ur.role_id = r.role_id
left join sys_user u on u.user_id = ur.user_id
where u.user_id = #{userId}
</select>
<select id="selectRoleById" parameterType="Long" resultMap="SysRoleResult">
<include refid="selectRoleVo"/>

Loading…
Cancel
Save