1. 修复bug

topo_dev
xueqingkun 9 months ago
parent e8f109b77c
commit 4b8e8e02bd

@ -1,5 +1,6 @@
package com.supervision.police.controller;
import com.supervision.common.domain.R;
import com.supervision.police.dto.MenuDTO;
import com.supervision.police.service.SystemMenuService;
import io.swagger.v3.oas.annotations.Operation;
@ -22,7 +23,8 @@ public class MenuController {
private final SystemMenuService menuService;
@Operation(summary = "查看用户信息列表")
@GetMapping("/listMenu")
public List<MenuDTO> listMenu() {
return menuService.listMenu();
public R<List<MenuDTO>> listMenu() {
List<MenuDTO> menuDTOS = menuService.listMenu();
return R.ok(menuDTOS);
}
}

@ -1,6 +1,7 @@
package com.supervision.police.controller;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.supervision.common.domain.R;
import com.supervision.police.dto.RoleDTO;
import com.supervision.police.service.SystemRoleService;
import io.swagger.v3.oas.annotations.Operation;
@ -18,9 +19,9 @@ public class RoleController {
private final SystemRoleService roleService;
@Operation(summary = "新增角色")
@PostMapping("/save")
public String saveRole(@RequestBody RoleDTO roleDTO) {
return roleService.saveRole(roleDTO);
public R<String> saveRole(@RequestBody RoleDTO roleDTO) {
String roleId = roleService.saveRole(roleDTO);
return R.ok(roleId);
}
@Operation(summary = "修改角色")
@ -31,14 +32,16 @@ public class RoleController {
@Operation(summary = "删除角色")
@DeleteMapping("/delete")
public Boolean deleteRole(@Parameter(name = "id") @RequestParam(name="id") String id) {
return roleService.deleteRole(id);
public R<Boolean> deleteRole(@Parameter(name = "id") @RequestParam(name="id") String id) {
Boolean success = roleService.deleteRole(id);
return R.ok(success);
}
@Operation(summary = "查看角色列表")
@GetMapping("/list")
public IPage<RoleDTO> list(@Parameter(name = "roleName",description = "角色名称") @RequestParam(required = false) String roleName,
public R<IPage<RoleDTO>> list(@Parameter(name = "roleName",description = "角色名称") @RequestParam(required = false) String roleName,
@Parameter(name = "pageNum",description = "页码") @RequestParam(defaultValue = "1") Integer pageNum,
@Parameter(name = "pageSize",description = "每页大小") @RequestParam(defaultValue = "10") Integer pageSize) {
return roleService.list(roleName, pageNum, pageSize);
IPage<RoleDTO> list = roleService.list(roleName, pageNum, pageSize);
return R.ok(list);
}
}

@ -1,8 +1,7 @@
package com.supervision.police.controller;
import cn.hutool.core.lang.Assert;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.supervision.common.domain.R;
import com.supervision.police.dto.user.*;
import com.supervision.police.service.SystemUserService;
import io.swagger.v3.oas.annotations.Operation;
@ -22,17 +21,17 @@ public class UserController {
@Operation(summary = "登录")
@PostMapping("/login")
public LoginResVO login(@RequestBody LoginReqVO reqVO) {
return userService.login(reqVO);
public R<LoginResVO> login(@RequestBody LoginReqVO reqVO) {
LoginResVO login = userService.login(reqVO);
return R.ok(login);
}
@Operation(summary = "新增用户信息")
@PostMapping("/saveUserInfo")
public String saveUserInfo(@RequestBody UserInfoReqVo userInfoReqVo) {
return userService.saveUserInfo(userInfoReqVo);
public R<String> saveUserInfo(@RequestBody UserInfoReqVo userInfoReqVo) {
String userId = userService.saveUserInfo(userInfoReqVo);
return R.ok(userId);
}
@Operation(summary = "修改用户信息")
@ -49,17 +48,19 @@ public class UserController {
@Operation(summary = "删除用户信息")
@DeleteMapping("/delete")
public Boolean deleteUser(@Parameter(name = "id") @RequestParam(name="id") String id) {
return userService.deleteUser(id);
public R<Boolean> deleteUser(@Parameter(name = "id") @RequestParam(name="id") String id) {
Boolean success = userService.deleteUser(id);
return R.ok(success);
}
@Operation(summary = "查看用户信息列表")
@GetMapping("/list")
public IPage<UserInfoDTO> list(@Parameter(name = "userName",description = "用户名") @RequestParam(required = false) String userName,
public R<IPage<UserInfoDTO>> list(@Parameter(name = "userName",description = "用户名") @RequestParam(required = false) String userName,
@Parameter(name = "roleId",description = "角色id") @RequestParam(required = false) String roleId,
@Parameter(name = "roleName",description = "角色名") @RequestParam(required = false) String roleName,
@Parameter(name = "pageNum",description = "页码") @RequestParam(defaultValue = "1") Integer pageNum,
@Parameter(name = "pageSize",description = "每页大小") @RequestParam(defaultValue = "10") Integer pageSize) {
return userService.list(userName, roleId, roleName, pageNum, pageSize);
IPage<UserInfoDTO> list = userService.list(userName, roleId, roleName, pageNum, pageSize);
return R.ok(list);
}

@ -28,7 +28,7 @@ public class RoleDTO {
private List<String> menuIdList;
@Schema(description = "关联用户数量")
private int userCount;
private Long userCount;
@Schema(description = "更新时间")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
@ -46,7 +46,7 @@ public class RoleDTO {
this.roleName = role.getRoleName();
this.remark = role.getRemark();
this.updateTime = role.getUpdateTime();
this.userCount = userCount.intValue();
this.userCount = Objects.isNull(userCount) ? 0L : userCount;
if (CollUtil.isNotEmpty(roleMenuRelationList)){
this.menuIdList = roleMenuRelationList.stream().map(SystemRoleMenuRelation::getMenuId).toList();
}

@ -38,7 +38,7 @@ public class CaseScoreDetailBuilder {
private List<LawParty> lawPartyList;
@Schema(description = "指标结果")
private List<IndexResult> indexResultList;
private List<IndexResult> indexResultList = new ArrayList<>();
/**
* Ollama
@ -212,7 +212,7 @@ public class CaseScoreDetailBuilder {
return this.indexResultList.stream()
.filter(indexResult -> StrUtil.equals(indexGroup,indexResult.getIndexGroup()))
.mapToInt(IndexResult::getIndexScore).sum();
.mapToInt(IndexResult::getActualScore).sum();
}

@ -40,7 +40,7 @@ public class IndexResult {
private int actualScore;
@Schema(description = "原子指标结果")
private List<AtomicResult> atomicResults;
private List<AtomicResult> atomicResults = new ArrayList<>();
public IndexResult() {
}

@ -1,10 +1,11 @@
package com.supervision.police.dto.user;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.annotation.TableId;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.supervision.police.domain.SystemUser;
import com.supervision.police.domain.SystemUserRoleRelation;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import org.springframework.scheduling.support.SimpleTriggerContext;
import java.time.LocalDateTime;
import java.util.*;
@ -13,44 +14,36 @@ import java.util.*;
public class UserInfoDTO {
/**
*
*/
@TableId
@Schema(description = "用户id")
private String id;
/**
* id
*/
@Schema(description = "头像id")
private String headPicId;
/**
*
*/
@Schema(description = "账户名")
private String account;
/**
*
*/
@Schema(description = "用户名")
private String userName;
/**
*
*/
@Schema(description = "手机号码")
private String phoneNum;
/**
* 0 1
*/
@Schema(description = "账号状态 0正常 1停用")
private Integer status;
@Schema(description = "用户角色列表")
private List<UserRoleDTO> userRoleList;
/**
*
*/
@Schema(description = "最近登录时间")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private LocalDateTime recentLoginTime;
@Schema(description = "注册时间")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private LocalDateTime registerTime;
public UserInfoDTO() {
}
@ -76,6 +69,7 @@ public class UserInfoDTO {
this.phoneNum = systemUser.getPhoneNum();
this.status = systemUser.getStatus();
this.recentLoginTime = systemUser.getRecentLoginTime();
this.registerTime = systemUser.getCreateTime();
}
}

@ -10,6 +10,4 @@ public class UserRoleDTO {
private String roleId;
private String roleName;
private Integer roleType;
}

@ -20,6 +20,8 @@ public interface SystemUserRoleRelationMapper extends BaseMapper<SystemUserRoleR
@Param("roleName") String roleName);
List<RoleMenuDTO> listUserRoleMenu(String userId);
List<UserRoleDTO> listUserRoleByUserIdList(List<String> userIdList);
}

@ -31,4 +31,7 @@ public interface SystemUserRoleRelationService extends IService<SystemUserRoleRe
List<RoleMenuDTO> listUserRoleMenu(String userId);
List<SystemUserRoleRelation> listUserRoleByRoleIdList(List<String> roleIdList);
List<UserRoleDTO> listUserRoleByUserIdList(List<String> userIdList);
}

@ -109,13 +109,13 @@ public class SystemRoleServiceImpl extends ServiceImpl<SystemRoleMapper, SystemR
List<String> roleIdList = page.getRecords().stream().map(SystemRole::getId).toList();
// 角色关联的用户数量
List<SystemUserRoleRelation> userRoleList = systemUserRoleRelationService.listUserRoleByRoleIdList(roleIdList);
Map<String, Long> roleCount = userRoleList.stream().collect(Collectors.groupingBy(SystemUserRoleRelation::getRoleId, Collectors.counting()));
Map<String, Long> roleUserCount = userRoleList.stream().collect(Collectors.groupingBy(SystemUserRoleRelation::getRoleId, Collectors.counting()));
// 角色关联的菜单数据
List<SystemRoleMenuRelation> roleMenuList = roleMenuRelationService.listRoleMenuByRoleIdList(roleIdList);
Map<String, List<SystemRoleMenuRelation>> roleMenuMap = roleMenuList.stream().collect(Collectors.groupingBy(SystemRoleMenuRelation::getRoleId));
return page.convert(systemRole ->
new RoleDTO(systemRole, roleCount.get(systemRole.getId()),roleMenuMap.get(systemRole.getId())));
new RoleDTO(systemRole, roleUserCount.get(systemRole.getId()),roleMenuMap.get(systemRole.getId())));
}
}

@ -12,6 +12,7 @@ import com.supervision.police.mapper.SystemUserRoleRelationMapper;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.ArrayList;
import java.util.List;
@ -33,6 +34,7 @@ public class SystemUserRoleRelationServiceImpl extends ServiceImpl<SystemUserRol
}
@Override
@Transactional(transactionManager = "dataSourceTransactionManager",rollbackFor = Exception.class)
public List<SystemUserRoleRelation> saveUserRoleRelation(String userId, List<String> roleIdList) {
Assert.notEmpty(userId, "用户id不能为空");
@ -47,11 +49,12 @@ public class SystemUserRoleRelationServiceImpl extends ServiceImpl<SystemUserRol
userRole.setUserId(userId);
return userRole;
}).toList();
super.saveBatch(userRoleList);
userRoleList.forEach(super::save);
return userRoleList;
}
@Override
@Transactional(transactionManager = "dataSourceTransactionManager",rollbackFor = Exception.class)
public List<SystemUserRoleRelation> updateUserRoleRelation(String userId, List<String> roleIdList) {
Assert.notEmpty(userId, "用户id不能为空");
@ -78,6 +81,15 @@ public class SystemUserRoleRelationServiceImpl extends ServiceImpl<SystemUserRol
return super.getBaseMapper().listUserRoleMenu(userId);
}
@Override
public List<UserRoleDTO> listUserRoleByUserIdList(List<String> userIdList) {
if (CollUtil.isEmpty(userIdList)){
return new ArrayList<>();
}
return super.getBaseMapper().listUserRoleByUserIdList(userIdList);
}
@Override
public List<SystemUserRoleRelation> listUserRoleByRoleIdList(List<String> roleIdList) {
if (CollUtil.isEmpty(roleIdList)){

@ -8,6 +8,7 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.supervision.police.domain.SystemUser;
import com.supervision.police.domain.SystemUserRoleRelation;
import com.supervision.police.dto.user.*;
import com.supervision.police.service.SystemUserRoleRelationService;
import com.supervision.police.service.SystemUserService;
@ -37,7 +38,6 @@ public class SystemUserServiceImpl extends ServiceImpl<SystemUserMapper, SystemU
private final SystemUserRoleRelationService userRoleRelationManageService;
@Override
@Transactional(rollbackFor = Exception.class)
public LoginResVO login(LoginReqVO reqVO) {
// 校验用户信息是否正确
@ -63,7 +63,7 @@ public class SystemUserServiceImpl extends ServiceImpl<SystemUserMapper, SystemU
}
@Override
@Transactional(rollbackFor = Exception.class)
@Transactional(transactionManager = "dataSourceTransactionManager",rollbackFor = Exception.class)
public String saveUserInfo(UserInfoReqVo userInfoReqVo) {
Assert.notEmpty(userInfoReqVo.getAccount(), "账号不能为空");
Assert.notEmpty(userInfoReqVo.getUserName(), "姓名不能为空");
@ -71,7 +71,7 @@ public class SystemUserServiceImpl extends ServiceImpl<SystemUserMapper, SystemU
Assert.notEmpty(userInfoReqVo.getRoleIdList(), "角色不能为空");
Long count = super.lambdaQuery().eq(SystemUser::getAccount, userInfoReqVo.getAccount()).count();
Assert.isTrue(count == 0, "用户名已存在");
Assert.isTrue(count == 0, "账号已存在");
SystemUser systemUser = userInfoReqVo.toSystemUser();
// 设置默认密码
@ -81,7 +81,7 @@ public class SystemUserServiceImpl extends ServiceImpl<SystemUserMapper, SystemU
}
@Override
@Transactional(rollbackFor = Exception.class)
@Transactional(transactionManager = "dataSourceTransactionManager",rollbackFor = Exception.class)
public void updateUserInfo(UserInfoReqVo userInfoReqVo) {
Assert.notEmpty(userInfoReqVo.getId(), "用户id不能为空");
@ -110,6 +110,7 @@ public class SystemUserServiceImpl extends ServiceImpl<SystemUserMapper, SystemU
}
@Override
@Transactional(transactionManager = "dataSourceTransactionManager",rollbackFor = Exception.class)
public Boolean deleteUser(String id) {
Assert.notEmpty(id, "用户id不能为空");
@ -126,26 +127,27 @@ public class SystemUserServiceImpl extends ServiceImpl<SystemUserMapper, SystemU
@Override
public IPage<UserInfoDTO> list(String userName, String roleId, String roleName, Integer pageNum, Integer pageSize) {
List<UserRoleDTO> userRoleDTOS = new ArrayList<>();
List<UserRoleDTO> userRoleFilterList = new ArrayList<>();
// 先对角色进行判断
if (StrUtil.isNotEmpty(roleId) || StrUtil.isNotEmpty(roleName)){
userRoleDTOS = userRoleRelationManageService.listUserRole(null, roleId, roleName);
if (CollUtil.isEmpty(userRoleDTOS)){
userRoleFilterList = userRoleRelationManageService.listUserRole(null, roleId, roleName);
if (CollUtil.isEmpty(userRoleFilterList)){
return Page.of(pageNum, pageSize, 0);
}
}
//构建查询条件
//查询用户数据
Page<SystemUser> userInfoPage = super.page(Page.of(pageNum, pageSize),
new LambdaQueryWrapper<SystemUser>()
.eq(StrUtil.isNotEmpty(userName), SystemUser::getUserName, userName)
.in(CollUtil.isNotEmpty(userRoleDTOS), SystemUser::getId, userRoleDTOS.stream().map(UserRoleDTO::getUserId).toList()));
.in(CollUtil.isNotEmpty(userRoleFilterList), SystemUser::getId, userRoleFilterList.stream().map(UserRoleDTO::getUserId).toList()));
if (CollUtil.isEmpty(userInfoPage.getRecords())){
return Page.of(pageNum, pageSize, userInfoPage.getTotal());
}
Map<String, List<UserRoleDTO>> userRoleMap = userRoleDTOS.stream().collect(Collectors.groupingBy(UserRoleDTO::getUserId, Collectors.toList()));
List<UserRoleDTO> userRoleList = userRoleRelationManageService.listUserRoleByUserIdList(userInfoPage.getRecords().stream().map(SystemUser::getId).toList());
Map<String, List<UserRoleDTO>> userRoleMap = userRoleList.stream().collect(Collectors.groupingBy(UserRoleDTO::getUserId, Collectors.toList()));
return userInfoPage.convert(systemUser -> new UserInfoDTO(systemUser,userRoleMap));
}

@ -47,4 +47,16 @@
left join system_menu m on rm.menu_id = m.id
where ur.user_id = #{userId}
</select>
<select id="listUserRoleByUserIdList" resultType="com.supervision.police.dto.user.UserRoleDTO">
select r.id as roleId,
r.role_name as roleName,
ur.user_id as userId
from system_role r
left join system_user_role_relation ur on r.id = ur.role_id
where ur.user_id in
<foreach collection="userIdList" item="userId" open="(" separator="," close=")">
#{userId}
</foreach>
</select>
</mapper>

Loading…
Cancel
Save