Browse Source

feat: [操作日志] 角色日志

master
memorylkf 2 months ago
parent
commit
46648e8011
5 changed files with 51 additions and 0 deletions
  1. +25
    -0
      hxhq-modules/hxhq-system/src/main/java/com/hxhq/system/controller/SysRoleController.java
  2. +7
    -0
      hxhq-modules/hxhq-system/src/main/java/com/hxhq/system/mapper/SysUserMapper.java
  3. +7
    -0
      hxhq-modules/hxhq-system/src/main/java/com/hxhq/system/service/ISysUserService.java
  4. +5
    -0
      hxhq-modules/hxhq-system/src/main/java/com/hxhq/system/service/impl/SysUserServiceImpl.java
  5. +7
    -0
      hxhq-modules/hxhq-system/src/main/resources/mapper/system/SysUserMapper.xml

+ 25
- 0
hxhq-modules/hxhq-system/src/main/java/com/hxhq/system/controller/SysRoleController.java View File

@ -5,6 +5,8 @@ import java.util.List;
import java.util.stream.Collectors;
import javax.servlet.http.HttpServletResponse;
import com.hxhq.business.domain.SystemLog;
import com.hxhq.business.service.ISystemLogService;
import com.hxhq.system.domain.SysUserRole;
import com.hxhq.system.form.RoleUserSaveForm;
import com.hxhq.system.service.ISysDeptService;
@ -51,6 +53,9 @@ public class SysRoleController extends BaseController
@Autowired
private ISysDeptService deptService;
@Autowired
private ISystemLogService systemLogService;
@RequiresPermissions("system:role:list")
@GetMapping("/list")
public TableDataInfo list(SysRole role)
@ -239,14 +244,34 @@ public class SysRoleController extends BaseController
@Transactional(rollbackFor = Exception.class)
public AjaxResult setAll(@RequestBody RoleUserSaveForm form)
{
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<String> deleteUserNames = new ArrayList<>();
List<String> addUserNames = new ArrayList<>();
if(deleteIds.size()>0){
roleService.deleteAuthUsers(form.getRoleId(), deleteIds.toArray(new Long[0]));
deleteUserNames = userService.selectNamesByIdList(deleteIds);
}
if(addList.size()>0){
roleService.insertAuthUsers(form.getRoleId(), addList.toArray(new Long[0]));
addUserNames = userService.selectNamesByIdList(addList);
}
if(addUserNames.size()>0 || deleteUserNames.size()>0){
SystemLog log = new SystemLog();
log.setName(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)):""));
systemLogService.save(log);
}
return AjaxResult.success("操作成功");

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

@ -187,4 +187,11 @@ public interface SysUserMapper
* @return
*/
List<BzListDto> selectBzList();
/**
* 根据用户id获取用户姓名
* @param idList
* @return
*/
List<String> selectNamesByIdList(@Param("idList") List<Long> idList);
}

+ 7
- 0
hxhq-modules/hxhq-system/src/main/java/com/hxhq/system/service/ISysUserService.java View File

@ -269,4 +269,11 @@ public interface ISysUserService
*/
List<BzListDto> selectBzList();
/**
* 根据id获取用户姓名
* @param idList
* @return
*/
List<String> selectNamesByIdList(List<Long> idList);
}

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

@ -607,4 +607,9 @@ public class SysUserServiceImpl implements ISysUserService
public List<BzListDto> selectBzList() {
return userMapper.selectBzList();
}
@Override
public List<String> selectNamesByIdList(List<Long> idList) {
return userMapper.selectNamesByIdList(idList);
}
}

+ 7
- 0
hxhq-modules/hxhq-system/src/main/resources/mapper/system/SysUserMapper.xml View File

@ -340,5 +340,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
WHERE u.`del_flag`='0' AND r.`del_flag`='0' AND r.`role_key`='bz'
</select>
<select id="selectNamesByIdList" resultType="java.lang.String">
SELECT GROUP_CONCAT(nick_name) FROM `sys_user` WHERE user_id IN
<foreach collection="idList" item="id" open="(" separator="," close=")">
#{id}
</foreach>
</select>
</mapper>

Loading…
Cancel
Save