Browse Source

新增用户设置角色

master
WendyYang 5 months ago
parent
commit
35904a4294
2 changed files with 32 additions and 1 deletions
  1. +9
    -1
      kq-vas-api/src/main/java/com/ningdatech/kqapi/user/manage/UserInfoManage.java
  2. +23
    -0
      kq-vas-api/src/main/java/com/ningdatech/kqapi/user/model/enumerization/RoleEnum.java

+ 9
- 1
kq-vas-api/src/main/java/com/ningdatech/kqapi/user/manage/UserInfoManage.java View File

@@ -15,6 +15,7 @@ import com.ningdatech.kqapi.security.model.UserInfoDetails;
import com.ningdatech.kqapi.user.model.entity.UserAuth;
import com.ningdatech.kqapi.user.model.entity.UserInfo;
import com.ningdatech.kqapi.user.model.enumerization.AccountStatus;
import com.ningdatech.kqapi.user.model.enumerization.RoleEnum;
import com.ningdatech.kqapi.user.model.po.ChangeAccountStatusReq;
import com.ningdatech.kqapi.user.model.po.ModifyPasswordReq;
import com.ningdatech.kqapi.user.model.po.SaveUserReq;
@@ -77,10 +78,14 @@ public class UserInfoManage {
@Transactional(rollbackFor = Exception.class)
public synchronized void saveUser(SaveUserReq req) {
Long userId = req.getUserId();
UserInfo oldUser = null;
UserInfo oldUser;
if (userId == null) {
oldUser = null;
BizUtils.password(req.getPassword());
} else {
if (StrUtil.isNotBlank(req.getPassword())) {
BizUtils.password(req.getPassword());
}
oldUser = userInfoService.getById(userId);
}
// 校验 账号是否已经使用
@@ -94,6 +99,9 @@ public class UserInfoManage {
entity.setUsername(req.getUserName());
entity.setAvatarFileId(req.getAvatarFileId());
entity.setAccountStatus(AccountStatus.ENABLE);
if (userId == null) {
entity.setRole(RoleEnum.USER.name());
}
userInfoService.saveOrUpdate(entity);
if (userId == null) {
saveUserAuth(req, entity);


+ 23
- 0
kq-vas-api/src/main/java/com/ningdatech/kqapi/user/model/enumerization/RoleEnum.java View File

@@ -0,0 +1,23 @@
package com.ningdatech.kqapi.user.model.enumerization;

import lombok.AllArgsConstructor;
import lombok.Getter;

/**
* <p>
* RoleEnum
* </p>
*
* @author WendyYang
* @since 16:19 2024/5/29
*/
@Getter
@AllArgsConstructor
public enum RoleEnum {

SUPER_ADMIN("超级管理员"),
USER("普通用户");

private final String displayName;

}

Loading…
Cancel
Save