fix(iam): 用户接口异常捕获
This commit is contained in:
+20
@@ -2,6 +2,7 @@ package com.jero.modules.system.service.impl;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.aliyun.oss.ServiceException;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
@@ -469,6 +470,8 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
|
||||
//step.1 保存用户
|
||||
// 对手机号、邮箱进行加密处理
|
||||
this.proceedUserInfoEncrypt(user);
|
||||
// 唯一性校验
|
||||
this.uniqueCheckout(user);
|
||||
this.save(user);
|
||||
//step.2 保存角色
|
||||
if(oConvertUtils.isNotEmpty(selectedRoles)) {
|
||||
@@ -488,6 +491,23 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
|
||||
}
|
||||
}
|
||||
|
||||
private void uniqueCheckout(SysUser user) {
|
||||
// 账号唯一性校验
|
||||
if (StringUtils.isNotBlank(user.getUsername())) {
|
||||
Integer count = userMapper.selectCount(new LambdaQueryWrapper<SysUser>().eq(SysUser::getUsername, user.getUsername()));
|
||||
if (count > 0) {
|
||||
throw new ServiceException("工号【" + user.getUsername() + "】已存在!");
|
||||
}
|
||||
}
|
||||
// 手机号唯一校验
|
||||
if (StringUtils.isNotBlank(user.getPhone())) {
|
||||
Integer count = userMapper.selectCount(new LambdaQueryWrapper<SysUser>().eq(SysUser::getPhone, user.getPhone()));
|
||||
if (count > 0) {
|
||||
throw new ServiceException("电话【" + PasswordUtil.decrypt(user.getPhone()) + "】已存在!");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @Remarks: 对手机号、邮箱进行加密处理
|
||||
**/
|
||||
|
||||
Reference in New Issue
Block a user