修复bug
This commit is contained in:
parent
a9149df19c
commit
db2b42af57
|
@ -28,7 +28,7 @@ public class MenuReq implements Serializable {
|
|||
@ApiModelProperty("菜单名称")
|
||||
private String menuName;
|
||||
|
||||
@ApiModelProperty("父级菜单id")
|
||||
@ApiModelProperty("父级菜单id,父级菜单修改无效")
|
||||
private String parentId;
|
||||
|
||||
@ApiModelProperty("显示顺序")
|
||||
|
|
|
@ -24,6 +24,7 @@ public class UserReq implements Serializable {
|
|||
@Serial
|
||||
private static final long serialVersionUID = -5491849652107338027L;
|
||||
|
||||
@NotBlank(message = "账号不能为空")
|
||||
@Pattern(groups = {ValidationGroup.Insert.class},regexp = "^[a-zA-Z0-9_]{4,20}$", message = "只能包含字母、数字或下划线,长度4-20")
|
||||
@ApiModelProperty("账号")
|
||||
private String account;
|
||||
|
|
|
@ -131,7 +131,10 @@ public class AuthServiceImpl implements AuthService {
|
|||
|
||||
private void saveSession(String 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){
|
||||
|
|
|
@ -73,11 +73,13 @@ public class MenuServiceImpl extends ServiceImpl<MenuMapper, MenuEntity> impleme
|
|||
@Transactional(rollbackFor = Exception.class)
|
||||
@Override
|
||||
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);
|
||||
}
|
||||
MenuEntity entity = Converts.INSTANCE.toMenuEntity(req);
|
||||
entity.setMenuId(menuId);
|
||||
entity.setParentId(menu.getParentId());
|
||||
if(StrUtil.isBlank(entity.getParentId())){
|
||||
entity.setParentId("0");
|
||||
}
|
||||
|
|
|
@ -134,8 +134,7 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, UserEntity> impleme
|
|||
@Transactional(rollbackFor = Exception.class)
|
||||
@Override
|
||||
public String save(UserReq req) {
|
||||
UserEntity entity = Converts.INSTANCE.toUserEntity(req);
|
||||
validate(req, null);
|
||||
UserEntity entity = validate(req, null);
|
||||
String salt = RandomUtil.randomString(req.getAccount(), 4);
|
||||
entity.setSalt(salt);
|
||||
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)){
|
||||
throw new ServiceException(Message.USER_ID_NOT_EXIST);
|
||||
}
|
||||
UserEntity entity = Converts.INSTANCE.toUserEntity(req);
|
||||
UserEntity entity = validate(req, originalEntity);
|
||||
entity.setUserId(userId);
|
||||
entity.setAccount(null);
|
||||
validate(req, originalEntity);
|
||||
if(CollUtil.isNotEmpty(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){
|
||||
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){
|
||||
throw new ServiceException(Message.ACCOUNT_EXIST);
|
||||
}
|
||||
if(originalEntity == null || (StrUtil.isNotBlank(req.getMobile()) && !originalEntity.getMobile().equals(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);
|
||||
if(this.getOne(mobileWrapper) != null){
|
||||
if(StrUtil.isNotBlank(req.getMobile())){
|
||||
LambdaQueryWrapper<UserEntity> mobileWrapper = Wrappers.lambdaQuery(UserEntity.class).eq(UserEntity::getMobile, req.getMobile()).eq(UserEntity::getDelFlag, Constants.DEL_FLAG_0);
|
||||
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);
|
||||
|
||||
}
|
||||
}
|
||||
if(originalEntity == null || (StrUtil.isNotBlank(req.getEmail()) && !originalEntity.getEmail().equals(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);
|
||||
if(this.getOne(emailWrapper) != null){
|
||||
if(StrUtil.isNotBlank(req.getEmail())){
|
||||
LambdaQueryWrapper<UserEntity> emailWrapper = Wrappers.lambdaQuery(UserEntity.class).eq(UserEntity::getEmail, req.getEmail()).eq(UserEntity::getDelFlag, Constants.DEL_FLAG_0);
|
||||
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);
|
||||
|
||||
}
|
||||
}
|
||||
if(originalEntity == null || (StrUtil.isNotBlank(req.getIdentityCard()) && !originalEntity.getIdentityCard().equals(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);
|
||||
if(this.getOne(emailWrapper) != null){
|
||||
if(StrUtil.isNotBlank(req.getIdentityCard())){
|
||||
LambdaQueryWrapper<UserEntity> identifyCardWrapper = Wrappers.lambdaQuery(UserEntity.class).eq(UserEntity::getIdentityCard, req.getIdentityCard()).eq(UserEntity::getDelFlag, Constants.DEL_FLAG_0);
|
||||
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);
|
||||
}
|
||||
}
|
||||
return Converts.INSTANCE.toUserEntity(req);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -1,12 +1,11 @@
|
|||
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.service.RoleService;
|
||||
import com.dite.znpt.service.UserRoleService;
|
||||
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 io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
|
@ -14,7 +13,6 @@ import org.springframework.validation.annotation.Validated;
|
|||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author huise23
|
||||
|
|
Loading…
Reference in New Issue