!210 报错国际化

Merge pull request !210 from fxz/dev
This commit is contained in:
lbw 2022-03-30 06:17:13 +00:00 committed by Gitee
commit e1dd46d0b6
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
12 changed files with 135 additions and 23 deletions

View File

@ -13,9 +13,79 @@ public interface ErrorCodes {
*/ */
String SYS_PARAM_CONFIG_ERROR = "sys.param.config.error"; String SYS_PARAM_CONFIG_ERROR = "sys.param.config.error";
/**
* 系统内置参数不能删除
*/
String SYS_PARAM_DELETE_SYSTEM = "sys.param.delete.system";
/** /**
* 用户已存在 * 用户已存在
*/ */
String SYS_USER_USERNAME_EXISTING = "sys.user.username.existing"; String SYS_USER_USERNAME_EXISTING = "sys.user.username.existing";
/**
* 用户原密码错误修改失败
*/
String SYS_USER_UPDATE_PASSWORDERROR = "sys.user.update.passwordError";
/**
* 用户信息为空
*/
String SYS_USER_USERINFO_EMPTY = "sys.user.userInfo.empty";
/**
* 获取当前用户信息失败
*/
String SYS_USER_QUERY_ERROR = "sys.user.query.error";
/**
* 部门名称不存在
*/
String SYS_DEPT_DEPTNAME_INEXISTENCE = "sys.dept.deptName.inexistence";
/**
* 岗位名称不存在
*/
String SYS_POST_POSTNAME_INEXISTENCE = "sys.post.postName.inexistence";
/**
* 岗位名称或编码已经存在
*/
String SYS_POST_NAMEORCODE_EXISTING = "sys.post.nameOrCode.existing";
/**
* 角色名称不存在
*/
String SYS_ROLE_ROLENAME_INEXISTENCE = "sys.role.roleName.inexistence";
/**
* 角色名或角色编码已经存在
*/
String SYS_ROLE_NAMEORCODE_EXISTING = "sys.role.nameOrCode.existing";
/**
* 菜单存在下级节点 删除失败
*/
String SYS_MENU_DELETE_EXISTING = "sys.menu.delete.existing";
/**
* 系统内置字典不允许删除
*/
String SYS_DICT_DELETE_SYSTEM = "sys.dict.delete.system";
/**
* 系统内置字典不能修改
*/
String SYS_DICT_UPDATE_SYSTEM = "sys.dict.update.system";
/**
* 验证码发送频繁
*/
String SYS_APP_SMS_OFTEN = "sys.app.sms.often";
/**
* 手机号未注册
*/
String SYS_APP_PHONE_UNREGISTERED = "sys.app.phone.unregistered";
} }

View File

@ -1,2 +1,23 @@
sys.user.update.passwordError=\u539f\u5bc6\u7801\u9519\u8bef\uff0c\u4fee\u6539\u5931\u8d25
sys.user.query.error=\u83b7\u53d6\u5f53\u524d\u7528\u6237\u4fe1\u606f\u5931\u8d25
sys.user.username.existing={0} \u7528\u6237\u540D\u5DF2\u5B58\u5728 sys.user.username.existing={0} \u7528\u6237\u540D\u5DF2\u5B58\u5728
sys.user.userInfo.empty={0} \u7528\u6237\u4fe1\u606f\u4e3a\u7a7a
sys.dept.deptName.inexistence={0} \u90e8\u95e8\u540d\u79f0\u4e0d\u5b58\u5728
sys.post.postName.inexistence={0} \u5c97\u4f4d\u540d\u79f0\u4e0d\u5b58\u5728
sys.post.nameOrCode.existing={0} {1} \u5c97\u4f4d\u540d\u6216\u5c97\u4f4d\u7f16\u7801\u5df2\u7ecf\u5b58\u5728
sys.role.roleName.inexistence={0} \u89d2\u8272\u540d\u79f0\u4e0d\u5b58\u5728
sys.role.nameOrCode.existing={0} {1} \u89d2\u8272\u540d\u6216\u89d2\u8272\u7f16\u7801\u5df2\u7ecf\u5b58\u5728
sys.param.delete.system=\u7cfb\u7edf\u5185\u7f6e\u53c2\u6570\u4e0d\u80fd\u5220\u9664
sys.param.config.error={0} \u7CFB\u7EDF\u53C2\u6570\u914D\u7F6E\u9519\u8BEF sys.param.config.error={0} \u7CFB\u7EDF\u53C2\u6570\u914D\u7F6E\u9519\u8BEF
sys.menu.delete.existing=\u83dc\u5355\u542b\u6709\u4e0b\u7ea7\u4e0d\u80fd\u5220\u9664
sys.app.sms.often=\u9a8c\u8bc1\u7801\u53d1\u9001\u8fc7\u9891\u7e41
sys.app.phone.unregistered={0} \u624b\u673a\u53f7\u672a\u6ce8\u518c
sys.dict.delete.system=\u7cfb\u7edf\u5185\u7f6e\u5b57\u5178\u9879\u76ee\u4e0d\u80fd\u5220\u9664
sys.dict.update.system=\u7cfb\u7edf\u5185\u7f6e\u5b57\u5178\u9879\u76ee\u4e0d\u80fd\u4fee\u6539

View File

@ -5,6 +5,8 @@ import com.pig4cloud.pig.admin.api.dto.UserInfo;
import com.pig4cloud.pig.admin.api.entity.SysUser; import com.pig4cloud.pig.admin.api.entity.SysUser;
import com.pig4cloud.pig.admin.service.AppService; import com.pig4cloud.pig.admin.service.AppService;
import com.pig4cloud.pig.admin.service.SysUserService; import com.pig4cloud.pig.admin.service.SysUserService;
import com.pig4cloud.pig.common.core.exception.ErrorCodes;
import com.pig4cloud.pig.common.core.util.MsgUtils;
import com.pig4cloud.pig.common.core.util.R; import com.pig4cloud.pig.common.core.util.R;
import com.pig4cloud.pig.common.security.annotation.Inner; import com.pig4cloud.pig.common.security.annotation.Inner;
import io.swagger.v3.oas.annotations.security.SecurityRequirement; import io.swagger.v3.oas.annotations.security.SecurityRequirement;
@ -47,7 +49,7 @@ public class AppController {
public R<UserInfo> infoByMobile(@PathVariable String phone) { public R<UserInfo> infoByMobile(@PathVariable String phone) {
SysUser user = userService.getOne(Wrappers.<SysUser>query().lambda().eq(SysUser::getPhone, phone)); SysUser user = userService.getOne(Wrappers.<SysUser>query().lambda().eq(SysUser::getPhone, phone));
if (user == null) { if (user == null) {
return R.failed(String.format("用户信息为空 %s", phone)); return R.failed(MsgUtils.getMessage(ErrorCodes.SYS_USER_USERINFO_EMPTY, phone));
} }
return R.ok(userService.getUserInfo(user)); return R.ok(userService.getUserInfo(user));
} }

View File

@ -27,6 +27,8 @@ import com.pig4cloud.pig.admin.api.vo.UserExcelVO;
import com.pig4cloud.pig.admin.api.vo.UserInfoVO; import com.pig4cloud.pig.admin.api.vo.UserInfoVO;
import com.pig4cloud.pig.admin.api.vo.UserVO; import com.pig4cloud.pig.admin.api.vo.UserVO;
import com.pig4cloud.pig.admin.service.SysUserService; import com.pig4cloud.pig.admin.service.SysUserService;
import com.pig4cloud.pig.common.core.exception.ErrorCodes;
import com.pig4cloud.pig.common.core.util.MsgUtils;
import com.pig4cloud.pig.common.core.util.R; import com.pig4cloud.pig.common.core.util.R;
import com.pig4cloud.pig.common.log.annotation.SysLog; import com.pig4cloud.pig.common.log.annotation.SysLog;
import com.pig4cloud.pig.common.security.annotation.Inner; import com.pig4cloud.pig.common.security.annotation.Inner;
@ -67,7 +69,7 @@ public class UserController {
String username = SecurityUtils.getUser().getUsername(); String username = SecurityUtils.getUser().getUsername();
SysUser user = userService.getOne(Wrappers.<SysUser>query().lambda().eq(SysUser::getUsername, username)); SysUser user = userService.getOne(Wrappers.<SysUser>query().lambda().eq(SysUser::getUsername, username));
if (user == null) { if (user == null) {
return R.failed("获取当前用户信息失败"); return R.failed(MsgUtils.getMessage(ErrorCodes.SYS_USER_QUERY_ERROR));
} }
UserInfo userInfo = userService.getUserInfo(user); UserInfo userInfo = userService.getUserInfo(user);
UserInfoVO vo = new UserInfoVO(); UserInfoVO vo = new UserInfoVO();
@ -86,7 +88,7 @@ public class UserController {
public R<UserInfo> info(@PathVariable String username) { public R<UserInfo> info(@PathVariable String username) {
SysUser user = userService.getOne(Wrappers.<SysUser>query().lambda().eq(SysUser::getUsername, username)); SysUser user = userService.getOne(Wrappers.<SysUser>query().lambda().eq(SysUser::getUsername, username));
if (user == null) { if (user == null) {
return R.failed(String.format("用户信息为空 %s", username)); return R.failed(MsgUtils.getMessage(ErrorCodes.SYS_USER_USERINFO_EMPTY, username));
} }
return R.ok(userService.getUserInfo(user)); return R.ok(userService.getUserInfo(user));
} }

View File

@ -25,6 +25,8 @@ import com.pig4cloud.pig.admin.mapper.SysUserMapper;
import com.pig4cloud.pig.admin.service.AppService; import com.pig4cloud.pig.admin.service.AppService;
import com.pig4cloud.pig.common.core.constant.CacheConstants; import com.pig4cloud.pig.common.core.constant.CacheConstants;
import com.pig4cloud.pig.common.core.constant.SecurityConstants; import com.pig4cloud.pig.common.core.constant.SecurityConstants;
import com.pig4cloud.pig.common.core.exception.ErrorCodes;
import com.pig4cloud.pig.common.core.util.MsgUtils;
import com.pig4cloud.pig.common.core.util.R; import com.pig4cloud.pig.common.core.util.R;
import io.springboot.sms.core.SmsClient; import io.springboot.sms.core.SmsClient;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
@ -63,14 +65,14 @@ public class AppServiceImpl implements AppService {
if (CollUtil.isEmpty(userList)) { if (CollUtil.isEmpty(userList)) {
log.info("手机号未注册:{}", phone); log.info("手机号未注册:{}", phone);
return R.ok(Boolean.FALSE, "手机号未注册"); return R.ok(Boolean.FALSE, MsgUtils.getMessage(ErrorCodes.SYS_APP_PHONE_UNREGISTERED, phone));
} }
Object codeObj = redisTemplate.opsForValue().get(CacheConstants.DEFAULT_CODE_KEY + phone); Object codeObj = redisTemplate.opsForValue().get(CacheConstants.DEFAULT_CODE_KEY + phone);
if (codeObj != null) { if (codeObj != null) {
log.info("手机号验证码未过期:{}{}", phone, codeObj); log.info("手机号验证码未过期:{}{}", phone, codeObj);
return R.ok(Boolean.FALSE, "验证码发送过频繁"); return R.ok(Boolean.FALSE, MsgUtils.getMessage(ErrorCodes.SYS_APP_SMS_OFTEN));
} }
String code = RandomUtil.randomNumbers(Integer.parseInt(SecurityConstants.CODE_SIZE)); String code = RandomUtil.randomNumbers(Integer.parseInt(SecurityConstants.CODE_SIZE));

View File

@ -23,6 +23,8 @@ import com.pig4cloud.pig.admin.service.SysDictItemService;
import com.pig4cloud.pig.admin.service.SysDictService; import com.pig4cloud.pig.admin.service.SysDictService;
import com.pig4cloud.pig.common.core.constant.CacheConstants; import com.pig4cloud.pig.common.core.constant.CacheConstants;
import com.pig4cloud.pig.common.core.constant.enums.DictTypeEnum; import com.pig4cloud.pig.common.core.constant.enums.DictTypeEnum;
import com.pig4cloud.pig.common.core.exception.ErrorCodes;
import com.pig4cloud.pig.common.core.util.MsgUtils;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import org.springframework.cache.annotation.CacheEvict; import org.springframework.cache.annotation.CacheEvict;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
@ -52,7 +54,8 @@ public class SysDictItemServiceImpl extends ServiceImpl<SysDictItemMapper, SysDi
SysDictItem dictItem = this.getById(id); SysDictItem dictItem = this.getById(id);
SysDict dict = dictService.getById(dictItem.getDictId()); SysDict dict = dictService.getById(dictItem.getDictId());
// 系统内置 // 系统内置
Assert.state(!DictTypeEnum.SYSTEM.getType().equals(dict.getSystemFlag()), "系统内置字典项目不能删除"); Assert.state(!DictTypeEnum.SYSTEM.getType().equals(dict.getSystemFlag()),
MsgUtils.getMessage(ErrorCodes.SYS_DICT_DELETE_SYSTEM));
this.removeById(id); this.removeById(id);
} }
@ -67,7 +70,8 @@ public class SysDictItemServiceImpl extends ServiceImpl<SysDictItemMapper, SysDi
// 查询字典 // 查询字典
SysDict dict = dictService.getById(item.getDictId()); SysDict dict = dictService.getById(item.getDictId());
// 系统内置 // 系统内置
Assert.state(!DictTypeEnum.SYSTEM.getType().equals(dict.getSystemFlag()), "系统内置字典项目不能修改"); Assert.state(!DictTypeEnum.SYSTEM.getType().equals(dict.getSystemFlag()),
MsgUtils.getMessage(ErrorCodes.SYS_DICT_UPDATE_SYSTEM));
this.updateById(item); this.updateById(item);
} }

View File

@ -24,6 +24,8 @@ import com.pig4cloud.pig.admin.mapper.SysDictMapper;
import com.pig4cloud.pig.admin.service.SysDictService; import com.pig4cloud.pig.admin.service.SysDictService;
import com.pig4cloud.pig.common.core.constant.CacheConstants; import com.pig4cloud.pig.common.core.constant.CacheConstants;
import com.pig4cloud.pig.common.core.constant.enums.DictTypeEnum; import com.pig4cloud.pig.common.core.constant.enums.DictTypeEnum;
import com.pig4cloud.pig.common.core.exception.ErrorCodes;
import com.pig4cloud.pig.common.core.util.MsgUtils;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import org.springframework.cache.annotation.CacheEvict; import org.springframework.cache.annotation.CacheEvict;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
@ -53,7 +55,8 @@ public class SysDictServiceImpl extends ServiceImpl<SysDictMapper, SysDict> impl
public void removeDict(Long id) { public void removeDict(Long id) {
SysDict dict = this.getById(id); SysDict dict = this.getById(id);
// 系统内置 // 系统内置
Assert.state(!DictTypeEnum.SYSTEM.getType().equals(dict.getSystemFlag()), "系统内置字典项目不能删除"); Assert.state(!DictTypeEnum.SYSTEM.getType().equals(dict.getSystemFlag()),
MsgUtils.getMessage(ErrorCodes.SYS_DICT_DELETE_SYSTEM));
baseMapper.deleteById(id); baseMapper.deleteById(id);
dictItemMapper.delete(Wrappers.<SysDictItem>lambdaQuery().eq(SysDictItem::getDictId, id)); dictItemMapper.delete(Wrappers.<SysDictItem>lambdaQuery().eq(SysDictItem::getDictId, id));
} }
@ -68,7 +71,8 @@ public class SysDictServiceImpl extends ServiceImpl<SysDictMapper, SysDict> impl
public void updateDict(SysDict dict) { public void updateDict(SysDict dict) {
SysDict sysDict = this.getById(dict.getId()); SysDict sysDict = this.getById(dict.getId());
// 系统内置 // 系统内置
Assert.state(!DictTypeEnum.SYSTEM.getType().equals(sysDict.getSystemFlag()), "系统内置字典项目不能修改"); Assert.state(!DictTypeEnum.SYSTEM.getType().equals(sysDict.getSystemFlag()),
MsgUtils.getMessage(ErrorCodes.SYS_DICT_UPDATE_SYSTEM));
this.updateById(dict); this.updateById(dict);
} }

View File

@ -31,6 +31,8 @@ import com.pig4cloud.pig.admin.service.SysMenuService;
import com.pig4cloud.pig.common.core.constant.CacheConstants; import com.pig4cloud.pig.common.core.constant.CacheConstants;
import com.pig4cloud.pig.common.core.constant.CommonConstants; import com.pig4cloud.pig.common.core.constant.CommonConstants;
import com.pig4cloud.pig.common.core.constant.enums.MenuTypeEnum; import com.pig4cloud.pig.common.core.constant.enums.MenuTypeEnum;
import com.pig4cloud.pig.common.core.exception.ErrorCodes;
import com.pig4cloud.pig.common.core.util.MsgUtils;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import org.springframework.cache.annotation.CacheEvict; import org.springframework.cache.annotation.CacheEvict;
import org.springframework.cache.annotation.Cacheable; import org.springframework.cache.annotation.Cacheable;
@ -39,10 +41,7 @@ import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.Assert; import org.springframework.util.Assert;
import javax.validation.constraints.NotNull; import javax.validation.constraints.NotNull;
import java.util.HashMap; import java.util.*;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.function.Function; import java.util.function.Function;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@ -78,7 +77,7 @@ public class SysMenuServiceImpl extends ServiceImpl<SysMenuMapper, SysMenu> impl
// 查询父节点为当前节点的节点 // 查询父节点为当前节点的节点
List<SysMenu> menuList = this.list(Wrappers.<SysMenu>query().lambda().eq(SysMenu::getParentId, id)); List<SysMenu> menuList = this.list(Wrappers.<SysMenu>query().lambda().eq(SysMenu::getParentId, id));
Assert.isTrue(CollUtil.isEmpty(menuList), "菜单含有下级不能删除"); Assert.isTrue(CollUtil.isEmpty(menuList), MsgUtils.getMessage(ErrorCodes.SYS_MENU_DELETE_EXISTING));
sysRoleMenuMapper.delete(Wrappers.<SysRoleMenu>query().lambda().eq(SysRoleMenu::getMenuId, id)); sysRoleMenuMapper.delete(Wrappers.<SysRoleMenu>query().lambda().eq(SysRoleMenu::getMenuId, id));
// 删除当前菜单及其子菜单 // 删除当前菜单及其子菜单

View File

@ -21,10 +21,11 @@ import cn.hutool.core.collection.CollUtil;
import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.pig4cloud.pig.admin.api.entity.SysPost; import com.pig4cloud.pig.admin.api.entity.SysPost;
import com.pig4cloud.pig.admin.api.entity.SysRole;
import com.pig4cloud.pig.admin.api.vo.PostExcelVO; import com.pig4cloud.pig.admin.api.vo.PostExcelVO;
import com.pig4cloud.pig.admin.mapper.SysPostMapper; import com.pig4cloud.pig.admin.mapper.SysPostMapper;
import com.pig4cloud.pig.admin.service.SysPostService; import com.pig4cloud.pig.admin.service.SysPostService;
import com.pig4cloud.pig.common.core.exception.ErrorCodes;
import com.pig4cloud.pig.common.core.util.MsgUtils;
import com.pig4cloud.pig.common.core.util.R; import com.pig4cloud.pig.common.core.util.R;
import com.pig4cloud.plugin.excel.vo.ErrorMessage; import com.pig4cloud.plugin.excel.vo.ErrorMessage;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
@ -67,7 +68,8 @@ public class SysPostServiceImpl extends ServiceImpl<SysPostMapper, SysPost> impl
|| excel.getPostCode().equals(post.getPostCode())); || excel.getPostCode().equals(post.getPostCode()));
if (existPost) { if (existPost) {
errorMsg.add(String.format("%s %s 岗位名或岗位编码已经存在", excel.getPostName(), excel.getPostCode())); errorMsg.add(MsgUtils.getMessage(ErrorCodes.SYS_POST_NAMEORCODE_EXISTING, excel.getPostName(),
excel.getPostCode()));
} }
// 数据合法情况 // 数据合法情况

View File

@ -24,6 +24,8 @@ import com.pig4cloud.pig.admin.mapper.SysPublicParamMapper;
import com.pig4cloud.pig.admin.service.SysPublicParamService; import com.pig4cloud.pig.admin.service.SysPublicParamService;
import com.pig4cloud.pig.common.core.constant.CacheConstants; import com.pig4cloud.pig.common.core.constant.CacheConstants;
import com.pig4cloud.pig.common.core.constant.enums.DictTypeEnum; import com.pig4cloud.pig.common.core.constant.enums.DictTypeEnum;
import com.pig4cloud.pig.common.core.exception.ErrorCodes;
import com.pig4cloud.pig.common.core.util.MsgUtils;
import com.pig4cloud.pig.common.core.util.R; import com.pig4cloud.pig.common.core.util.R;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import org.springframework.cache.annotation.CacheEvict; import org.springframework.cache.annotation.CacheEvict;
@ -64,7 +66,7 @@ public class SysPublicParamServiceImpl extends ServiceImpl<SysPublicParamMapper,
SysPublicParam param = this.getById(sysPublicParam.getPublicId()); SysPublicParam param = this.getById(sysPublicParam.getPublicId());
// 系统内置 // 系统内置
if (DictTypeEnum.SYSTEM.getType().equals(param.getSystemFlag())) { if (DictTypeEnum.SYSTEM.getType().equals(param.getSystemFlag())) {
return R.failed("系统内置参数不能删除"); return R.failed(MsgUtils.getMessage(ErrorCodes.SYS_PARAM_DELETE_SYSTEM));
} }
return R.ok(this.updateById(sysPublicParam)); return R.ok(this.updateById(sysPublicParam));
} }

View File

@ -27,6 +27,8 @@ import com.pig4cloud.pig.admin.mapper.SysRoleMapper;
import com.pig4cloud.pig.admin.mapper.SysRoleMenuMapper; import com.pig4cloud.pig.admin.mapper.SysRoleMenuMapper;
import com.pig4cloud.pig.admin.service.SysRoleService; import com.pig4cloud.pig.admin.service.SysRoleService;
import com.pig4cloud.pig.common.core.constant.CacheConstants; import com.pig4cloud.pig.common.core.constant.CacheConstants;
import com.pig4cloud.pig.common.core.exception.ErrorCodes;
import com.pig4cloud.pig.common.core.util.MsgUtils;
import com.pig4cloud.pig.common.core.util.R; import com.pig4cloud.pig.common.core.util.R;
import com.pig4cloud.plugin.excel.vo.ErrorMessage; import com.pig4cloud.plugin.excel.vo.ErrorMessage;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
@ -90,7 +92,8 @@ public class SysRoleServiceImpl extends ServiceImpl<SysRoleMapper, SysRole> impl
|| excel.getRoleCode().equals(sysRole.getRoleCode())); || excel.getRoleCode().equals(sysRole.getRoleCode()));
if (existRole) { if (existRole) {
errorMsg.add(String.format("%s %s 角色名或角色编码已经存在", excel.getRoleName(), excel.getRoleDesc())); errorMsg.add(MsgUtils.getMessage(ErrorCodes.SYS_ROLE_NAMEORCODE_EXISTING, excel.getRoleName(),
excel.getRoleCode()));
} }
// 数据合法情况 // 数据合法情况

View File

@ -174,7 +174,8 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
public Boolean updateUserInfo(UserDTO userDto) { public Boolean updateUserInfo(UserDTO userDto) {
UserVO userVO = baseMapper.getUserVoByUsername(userDto.getUsername()); UserVO userVO = baseMapper.getUserVoByUsername(userDto.getUsername());
Assert.isTrue(ENCODER.matches(userDto.getPassword(), userVO.getPassword()), "原密码错误,修改失败"); Assert.isTrue(ENCODER.matches(userDto.getPassword(), userVO.getPassword()),
MsgUtils.getMessage(ErrorCodes.SYS_USER_UPDATE_PASSWORDERROR));
SysUser sysUser = new SysUser(); SysUser sysUser = new SysUser();
if (StrUtil.isNotBlank(userDto.getNewpassword1())) { if (StrUtil.isNotBlank(userDto.getNewpassword1())) {
@ -284,14 +285,14 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
.anyMatch(sysUser -> excel.getUsername().equals(sysUser.getUsername())); .anyMatch(sysUser -> excel.getUsername().equals(sysUser.getUsername()));
if (exsitUserName) { if (exsitUserName) {
errorMsg.add(String.format("%s 用户名已存在", excel.getUsername())); errorMsg.add(MsgUtils.getMessage(ErrorCodes.SYS_USER_USERNAME_EXISTING, excel.getUsername()));
} }
// 判断输入的部门名称列表是否合法 // 判断输入的部门名称列表是否合法
Optional<SysDept> deptOptional = deptList.stream() Optional<SysDept> deptOptional = deptList.stream()
.filter(dept -> excel.getDeptName().equals(dept.getName())).findFirst(); .filter(dept -> excel.getDeptName().equals(dept.getName())).findFirst();
if (!deptOptional.isPresent()) { if (!deptOptional.isPresent()) {
errorMsg.add(String.format("%s 部门名称不存在", excel.getDeptName())); errorMsg.add(MsgUtils.getMessage(ErrorCodes.SYS_DEPT_DEPTNAME_INEXISTENCE, excel.getDeptName()));
} }
// 判断输入的角色名称列表是否合法 // 判断输入的角色名称列表是否合法
@ -301,7 +302,7 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
.collect(Collectors.toList()); .collect(Collectors.toList());
if (roleCollList.size() != roleNameList.size()) { if (roleCollList.size() != roleNameList.size()) {
errorMsg.add(String.format("%s 角色名称不存在", excel.getRoleNameList())); errorMsg.add(MsgUtils.getMessage(ErrorCodes.SYS_ROLE_ROLENAME_INEXISTENCE, excel.getRoleNameList()));
} }
// 判断输入的岗位名称列表是否合法 // 判断输入的岗位名称列表是否合法
@ -311,7 +312,7 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
.collect(Collectors.toList()); .collect(Collectors.toList());
if (postCollList.size() != postNameList.size()) { if (postCollList.size() != postNameList.size()) {
errorMsg.add(String.format("%s 岗位名称不存在", excel.getPostNameList())); errorMsg.add(MsgUtils.getMessage(ErrorCodes.SYS_POST_POSTNAME_INEXISTENCE, excel.getPostNameList()));
} }
// 数据合法情况 // 数据合法情况