1. 修复bug

topo_dev
xueqingkun 9 months ago
parent 851034f3ce
commit bc761c2b52

@ -26,6 +26,8 @@ public class CorsConfig implements WebMvcConfigurer {
.allowCredentials(true)
// 设置允许的方法
.allowedMethods("*")
// 允许跨域的请求头
.allowedHeaders("*")
// 跨域允许时间
.maxAge(3600);
}

@ -16,7 +16,7 @@ import java.time.format.DateTimeFormatter;
import java.util.ArrayList;
import java.util.List;
//@Configuration
@Configuration
public class WebConfig implements WebMvcConfigurer {
@ -40,15 +40,9 @@ public class WebConfig implements WebMvcConfigurer {
paths.add("/error");
paths.add("/favicon.ico");
paths.add("/user/login");
paths.add("/user/register");
paths.add("/minio/downloadFile");
paths.add("/user/changePassWord");
paths.add("/user/checkAccount");
paths.add("/webSocket/**");
paths.add("/ask/downloadTalkVideo");
paths.add("/fileManage/downloadFile");
paths.add("/aqLibrary/downloadQuestionLibraryTemplate");
paths.add("/medicalRecManage/downloadMedicalAnswerTemplate");
paths.add("/qaKnowledge/**");
// 开发环境,放开不校验token.每次修改这里需要重启(热部署不行)
// paths.add("/**");
return paths;

@ -4,6 +4,7 @@ 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 com.supervision.utils.UserUtil;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
@ -26,18 +27,25 @@ public class UserController {
return R.ok(login);
}
@Operation(summary = "查看账号信息")
@GetMapping("/getCurrentUser")
public R<UserInfoDTO> getCurrentUser() {
UserInfoDTO currentUser = userService.getCurrentUser();
return R.ok(currentUser);
}
@Operation(summary = "新增用户信息")
@PostMapping("/saveUserInfo")
public R<String> saveUserInfo(@RequestBody UserInfoReqVo userInfoReqVo) {
String userId = userService.saveUserInfo(userInfoReqVo);
public R<String> saveUserInfo(@RequestBody UserInfoVoDTO userInfoVoDTO) {
String userId = userService.saveUserInfo(userInfoVoDTO.toUserInfoReqVo());
return R.ok(userId);
}
@Operation(summary = "修改用户信息")
@PostMapping("/update")
public R<?> updateUser(@RequestBody UserInfoReqVo userInfoReqVo) {
userService.updateUserInfo(userInfoReqVo);
public R<?> updateUser(@RequestBody UserInfoVoDTO userInfoVoDTO) {
userService.updateUserInfo(userInfoVoDTO.toUserInfoReqVo());
return R.ok();
}
@ -56,13 +64,15 @@ public class UserController {
}
@Operation(summary = "查看用户信息列表")
@GetMapping("/list")
public R<IPage<UserInfoDTO>> list(@Parameter(name = "userName",description = "用户名") @RequestParam(required = false) String userName,
public R<IPage<UserInfoVoDTO>> 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) {
IPage<UserInfoDTO> list = userService.list(userName, roleId, roleName, pageNum, pageSize);
return R.ok(list);
IPage<UserInfoDTO> page = userService.list(userName, roleId, roleName, pageNum, pageSize);
return R.ok(page.convert(UserInfoVoDTO::new));
}

@ -52,6 +52,12 @@ public class LoginResVO {
if (Objects.isNull(userInfoDTO)){
return;
}
if (CollUtil.isNotEmpty(this.roleList)){
userInfoDTO.setUserRoleList(this.roleList);
}
if (CollUtil.isNotEmpty(this.permission)){
userInfoDTO.setPermission(this.permission);
}
this.token = TokenUtil.creatToken(JSONUtil.toJsonStr(userInfoDTO));
}
public void setToken(String token) {
@ -66,6 +72,7 @@ public class LoginResVO {
if (CollUtil.isEmpty(roleMenuDTOS)){
return;
}
this.permission = roleMenuDTOS.stream().map(RoleMenuDTO::getLabelCode).filter(Objects::nonNull).collect(Collectors.toList());
this.permission = roleMenuDTOS.stream().map(RoleMenuDTO::getLabelCode).filter(Objects::nonNull)
.distinct().collect(Collectors.toList());
}
}

@ -32,9 +32,15 @@ public class UserInfoDTO {
@Schema(description = "账号状态 0正常 1停用")
private Integer status;
@Schema(description = "备注")
private String remark;
@Schema(description = "用户角色列表")
private List<UserRoleDTO> userRoleList;
private List<UserRoleDTO> userRoleList = new ArrayList<>();
@Schema(description = "菜单权限标识")
private List<String> permission = new ArrayList<>();
@Schema(description = "最近登录时间")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
@ -70,6 +76,7 @@ public class UserInfoDTO {
this.status = systemUser.getStatus();
this.recentLoginTime = systemUser.getRecentLoginTime();
this.registerTime = systemUser.getCreateTime();
this.remark = systemUser.getRemark();
}
}

@ -0,0 +1,101 @@
package com.supervision.police.dto.user;
import cn.hutool.core.collection.CollUtil;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import java.time.LocalDateTime;
import java.util.List;
/**
* UserInfoReqVo
*
*
*
*/
@Data
public class UserInfoVoDTO {
@Schema(description = "用户id")
private String id;
@Schema(description = "头像ID")
private String headPicId;
@Schema(description = "账号")
private String account;
@Schema(description = "用户名")
private String userName;
@Schema(description = "密码")
private String password;
@Schema(description = "手机号")
private String phoneNum;
@Schema(description = "账号状态 0正常 1停用")
private Integer status;
@Schema(description = "角色ID")
private String roleId;
@Schema(description = "角色名")
private String roleName;
@Schema(description = "备注")
private String remark;
@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 UserInfoVoDTO() {
}
public UserInfoVoDTO(UserInfoDTO userInfoDTO) {
if (userInfoDTO == null){
return;
}
this.id = userInfoDTO.getId();
this.headPicId = userInfoDTO.getHeadPicId();
this.account = userInfoDTO.getAccount();
this.userName = userInfoDTO.getUserName();
this.phoneNum = userInfoDTO.getPhoneNum();
this.status = userInfoDTO.getStatus();
if (CollUtil.isNotEmpty(userInfoDTO.getUserRoleList())){
UserRoleDTO userRole = CollUtil.getFirst(userInfoDTO.getUserRoleList());
this.roleId = userRole.getRoleId();
this.roleName = userRole.getRoleName();
}
this.recentLoginTime = userInfoDTO.getRecentLoginTime();
this.registerTime = userInfoDTO.getRegisterTime();
this.userRoleList = userInfoDTO.getUserRoleList();
this.remark = userInfoDTO.getRemark();
}
public UserInfoReqVo toUserInfoReqVo() {
UserInfoReqVo userInfoReqVo = new UserInfoReqVo();
userInfoReqVo.setId(this.id);
userInfoReqVo.setHeadPicId(this.headPicId);
userInfoReqVo.setAccount(this.account);
userInfoReqVo.setUserName(this.userName);
userInfoReqVo.setPassword(this.password);
userInfoReqVo.setPhoneNum(this.phoneNum);
userInfoReqVo.setStatus(this.status);
userInfoReqVo.setRoleIdList(List.of(this.roleId));
userInfoReqVo.setRemark(this.remark);
return userInfoReqVo;
}
}

@ -5,8 +5,6 @@ import com.supervision.police.domain.SystemUser;
import com.baomidou.mybatisplus.extension.service.IService;
import com.supervision.police.dto.user.*;
import java.util.List;
/**
* @author Administrator
* @description system_user()Service
@ -16,7 +14,7 @@ public interface SystemUserService extends IService<SystemUser> {
LoginResVO login(LoginReqVO reqVO);
UserInfoDTO getUserAccountInfo();
UserInfoDTO getCurrentUser();
String saveUserInfo(UserInfoReqVo userInfoReqVo);

@ -52,17 +52,18 @@ public class SystemUserServiceImpl extends ServiceImpl<SystemUserMapper, SystemU
// 组装用户信息
LoginResVO loginResVO = new LoginResVO(systemUser);
// 设置用户token信息
loginResVO.setToken(new UserInfoDTO(systemUser));
loginResVO.setRoleList(userRoleRelationManageService.listUserRoleByUserIdList(CollUtil.newArrayList(systemUser.getId())));
// 设置用户权限信息
loginResVO.roleMenuDTOSetPermission(userRoleRelationManageService.listUserRoleMenu(systemUser.getId()));
// 设置用户token信息
loginResVO.setToken(new UserInfoDTO(systemUser));
return loginResVO;
}
@Override
public UserInfoDTO getUserAccountInfo() {
public UserInfoDTO getCurrentUser() {
return UserUtil.getUser();
}

Loading…
Cancel
Save