修复bug
This commit is contained in:
parent
a9149df19c
commit
db2b42af57
|
@ -28,7 +28,7 @@ public class MenuReq implements Serializable {
|
||||||
@ApiModelProperty("菜单名称")
|
@ApiModelProperty("菜单名称")
|
||||||
private String menuName;
|
private String menuName;
|
||||||
|
|
||||||
@ApiModelProperty("父级菜单id")
|
@ApiModelProperty("父级菜单id,父级菜单修改无效")
|
||||||
private String parentId;
|
private String parentId;
|
||||||
|
|
||||||
@ApiModelProperty("显示顺序")
|
@ApiModelProperty("显示顺序")
|
||||||
|
|
|
@ -24,6 +24,7 @@ public class UserReq implements Serializable {
|
||||||
@Serial
|
@Serial
|
||||||
private static final long serialVersionUID = -5491849652107338027L;
|
private static final long serialVersionUID = -5491849652107338027L;
|
||||||
|
|
||||||
|
@NotBlank(message = "账号不能为空")
|
||||||
@Pattern(groups = {ValidationGroup.Insert.class},regexp = "^[a-zA-Z0-9_]{4,20}$", message = "只能包含字母、数字或下划线,长度4-20")
|
@Pattern(groups = {ValidationGroup.Insert.class},regexp = "^[a-zA-Z0-9_]{4,20}$", message = "只能包含字母、数字或下划线,长度4-20")
|
||||||
@ApiModelProperty("账号")
|
@ApiModelProperty("账号")
|
||||||
private String account;
|
private String account;
|
||||||
|
|
|
@ -131,7 +131,10 @@ public class AuthServiceImpl implements AuthService {
|
||||||
|
|
||||||
private void saveSession(String userId){
|
private void saveSession(String userId){
|
||||||
StpUtil.getSession().set("userInfo", queryUserInfo(userId));
|
StpUtil.getSession().set("userInfo", queryUserInfo(userId));
|
||||||
StpUtil.getSession().set("menuInfo", queryMenuInfo(userId));
|
List<Tree<String>> menuInfo = queryMenuInfo(userId);
|
||||||
|
if(!menuInfo.isEmpty()){
|
||||||
|
StpUtil.getSession().set("menuInfo", menuInfo);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private UserInfo queryUserInfo(String userId){
|
private UserInfo queryUserInfo(String userId){
|
||||||
|
|
|
@ -73,11 +73,13 @@ public class MenuServiceImpl extends ServiceImpl<MenuMapper, MenuEntity> impleme
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
@Override
|
@Override
|
||||||
public void update(String menuId, MenuReq req) {
|
public void update(String menuId, MenuReq req) {
|
||||||
if(null == this.getById(menuId)){
|
MenuEntity menu = this.getById(menuId);
|
||||||
|
if(null == menu){
|
||||||
throw new ServiceException(Message.MENU_ID_NOT_EXIST);
|
throw new ServiceException(Message.MENU_ID_NOT_EXIST);
|
||||||
}
|
}
|
||||||
MenuEntity entity = Converts.INSTANCE.toMenuEntity(req);
|
MenuEntity entity = Converts.INSTANCE.toMenuEntity(req);
|
||||||
entity.setMenuId(menuId);
|
entity.setMenuId(menuId);
|
||||||
|
entity.setParentId(menu.getParentId());
|
||||||
if(StrUtil.isBlank(entity.getParentId())){
|
if(StrUtil.isBlank(entity.getParentId())){
|
||||||
entity.setParentId("0");
|
entity.setParentId("0");
|
||||||
}
|
}
|
||||||
|
|
|
@ -134,8 +134,7 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, UserEntity> impleme
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
@Override
|
@Override
|
||||||
public String save(UserReq req) {
|
public String save(UserReq req) {
|
||||||
UserEntity entity = Converts.INSTANCE.toUserEntity(req);
|
UserEntity entity = validate(req, null);
|
||||||
validate(req, null);
|
|
||||||
String salt = RandomUtil.randomString(req.getAccount(), 4);
|
String salt = RandomUtil.randomString(req.getAccount(), 4);
|
||||||
entity.setSalt(salt);
|
entity.setSalt(salt);
|
||||||
String password = enableDefaultPassword ? defaultPassword : PasswordUtil.generatePassword();
|
String password = enableDefaultPassword ? defaultPassword : PasswordUtil.generatePassword();
|
||||||
|
@ -176,11 +175,6 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, UserEntity> impleme
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void main(String[] args) {
|
|
||||||
System.out.println(Integer.parseInt("00001") + 1);
|
|
||||||
System.out.println(StrUtil.fillBefore("2",'0', 5));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 功能描述:更新用户信息
|
* 功能描述:更新用户信息
|
||||||
|
@ -197,10 +191,9 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, UserEntity> impleme
|
||||||
if(null == originalEntity || originalEntity.getDelFlag().equals(Constants.DEL_FLAG_1)){
|
if(null == originalEntity || originalEntity.getDelFlag().equals(Constants.DEL_FLAG_1)){
|
||||||
throw new ServiceException(Message.USER_ID_NOT_EXIST);
|
throw new ServiceException(Message.USER_ID_NOT_EXIST);
|
||||||
}
|
}
|
||||||
UserEntity entity = Converts.INSTANCE.toUserEntity(req);
|
UserEntity entity = validate(req, originalEntity);
|
||||||
entity.setUserId(userId);
|
entity.setUserId(userId);
|
||||||
entity.setAccount(null);
|
entity.setAccount(null);
|
||||||
validate(req, originalEntity);
|
|
||||||
if(CollUtil.isNotEmpty(req.getPostIds())){
|
if(CollUtil.isNotEmpty(req.getPostIds())){
|
||||||
userPostService.bindUserPost(userId, req.getPostIds());
|
userPostService.bindUserPost(userId, req.getPostIds());
|
||||||
}
|
}
|
||||||
|
@ -208,7 +201,7 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, UserEntity> impleme
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private void validate(UserReq req, UserEntity originalEntity){
|
private UserEntity validate(UserReq req, UserEntity originalEntity){
|
||||||
if(StrUtil.isNotBlank(req.getDeptId()) && deptService.getById(req.getDeptId()) == null){
|
if(StrUtil.isNotBlank(req.getDeptId()) && deptService.getById(req.getDeptId()) == null){
|
||||||
throw new ServiceException(Message.DEPT_ID_NOT_EXIST);
|
throw new ServiceException(Message.DEPT_ID_NOT_EXIST);
|
||||||
}
|
}
|
||||||
|
@ -216,24 +209,30 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, UserEntity> impleme
|
||||||
if(this.getOne(accountWrapper) != null && originalEntity == null){
|
if(this.getOne(accountWrapper) != null && originalEntity == null){
|
||||||
throw new ServiceException(Message.ACCOUNT_EXIST);
|
throw new ServiceException(Message.ACCOUNT_EXIST);
|
||||||
}
|
}
|
||||||
if(originalEntity == null || (StrUtil.isNotBlank(req.getMobile()) && !originalEntity.getMobile().equals(req.getMobile()))){
|
if(StrUtil.isNotBlank(req.getMobile())){
|
||||||
LambdaQueryWrapper<UserEntity> mobileWrapper = Wrappers.lambdaQuery(UserEntity.class).eq(StrUtil.isNotBlank(req.getMobile()), UserEntity::getMobile, req.getMobile()).eq(UserEntity::getDelFlag, Constants.DEL_FLAG_0);
|
LambdaQueryWrapper<UserEntity> mobileWrapper = Wrappers.lambdaQuery(UserEntity.class).eq(UserEntity::getMobile, req.getMobile()).eq(UserEntity::getDelFlag, Constants.DEL_FLAG_0);
|
||||||
if(this.getOne(mobileWrapper) != null){
|
List<UserEntity> mobileUserList = this.list(mobileWrapper);
|
||||||
|
if((originalEntity == null && !mobileUserList.isEmpty()) || (originalEntity != null && !originalEntity.getMobile().equals(req.getMobile()) && mobileUserList.size() > 1)){
|
||||||
throw new ServiceException(Message.MOBILE_EXIST);
|
throw new ServiceException(Message.MOBILE_EXIST);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(originalEntity == null || (StrUtil.isNotBlank(req.getEmail()) && !originalEntity.getEmail().equals(req.getEmail()))){
|
if(StrUtil.isNotBlank(req.getEmail())){
|
||||||
LambdaQueryWrapper<UserEntity> emailWrapper = Wrappers.lambdaQuery(UserEntity.class).eq(StrUtil.isNotBlank(req.getEmail()), UserEntity::getEmail, req.getEmail()).eq(UserEntity::getDelFlag, Constants.DEL_FLAG_0);
|
LambdaQueryWrapper<UserEntity> emailWrapper = Wrappers.lambdaQuery(UserEntity.class).eq(UserEntity::getEmail, req.getEmail()).eq(UserEntity::getDelFlag, Constants.DEL_FLAG_0);
|
||||||
if(this.getOne(emailWrapper) != null){
|
List<UserEntity> emailUserList = this.list(emailWrapper);
|
||||||
|
if((originalEntity == null && !emailUserList.isEmpty()) || (originalEntity != null && !originalEntity.getEmail().equals(req.getEmail()) && emailUserList.size() > 1)){
|
||||||
throw new ServiceException(Message.EMAIL_EXIST);
|
throw new ServiceException(Message.EMAIL_EXIST);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(originalEntity == null || (StrUtil.isNotBlank(req.getIdentityCard()) && !originalEntity.getIdentityCard().equals(req.getIdentityCard()))){
|
if(StrUtil.isNotBlank(req.getIdentityCard())){
|
||||||
LambdaQueryWrapper<UserEntity> emailWrapper = Wrappers.lambdaQuery(UserEntity.class).eq(StrUtil.isNotBlank(req.getIdentityCard()), UserEntity::getIdentityCard, req.getIdentityCard()).eq(UserEntity::getDelFlag, Constants.DEL_FLAG_0);
|
LambdaQueryWrapper<UserEntity> identifyCardWrapper = Wrappers.lambdaQuery(UserEntity.class).eq(UserEntity::getIdentityCard, req.getIdentityCard()).eq(UserEntity::getDelFlag, Constants.DEL_FLAG_0);
|
||||||
if(this.getOne(emailWrapper) != null){
|
List<UserEntity> identifyCardUserList = this.list(identifyCardWrapper);
|
||||||
|
if((originalEntity == null && !identifyCardUserList.isEmpty()) || (originalEntity != null && !originalEntity.getIdentityCard().equals(req.getIdentityCard()) && identifyCardUserList.size() > 1)){
|
||||||
throw new ServiceException(Message.IDENTITY_CARD_EXIST);
|
throw new ServiceException(Message.IDENTITY_CARD_EXIST);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return Converts.INSTANCE.toUserEntity(req);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -1,12 +1,11 @@
|
||||||
package com.dite.znpt.web.controller;
|
package com.dite.znpt.web.controller;
|
||||||
|
|
||||||
|
|
||||||
|
import com.dite.znpt.domain.PageResult;
|
||||||
|
import com.dite.znpt.domain.Result;
|
||||||
import com.dite.znpt.domain.vo.*;
|
import com.dite.znpt.domain.vo.*;
|
||||||
import com.dite.znpt.service.RoleService;
|
|
||||||
import com.dite.znpt.service.UserRoleService;
|
import com.dite.znpt.service.UserRoleService;
|
||||||
import com.dite.znpt.service.UserService;
|
import com.dite.znpt.service.UserService;
|
||||||
import com.dite.znpt.domain.Result;
|
|
||||||
import com.dite.znpt.domain.PageResult;
|
|
||||||
import com.dite.znpt.util.ValidationGroup;
|
import com.dite.znpt.util.ValidationGroup;
|
||||||
import io.swagger.annotations.Api;
|
import io.swagger.annotations.Api;
|
||||||
import io.swagger.annotations.ApiOperation;
|
import io.swagger.annotations.ApiOperation;
|
||||||
|
@ -14,7 +13,6 @@ import org.springframework.validation.annotation.Validated;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author huise23
|
* @author huise23
|
||||||
|
|
Loading…
Reference in New Issue