|
|
@@ -1346,14 +1346,7 @@ public class ApiController extends BaseController {
|
|
|
if(StringUtils.isBlank(user.getPassword())){
|
|
|
throw new RuntimeException("密码不能为空");
|
|
|
}
|
|
|
- if (!userService.checkLoginNameUnique(user))
|
|
|
- {
|
|
|
- throw new RuntimeException("新增用户'" + user.getLoginName() + "'失败,登录账号已存在");
|
|
|
- }
|
|
|
- else if (StringUtils.isNotEmpty(user.getPhonenumber()) && !userService.checkPhoneUnique(user))
|
|
|
- {
|
|
|
- throw new RuntimeException("新增用户'" + user.getLoginName() + "'失败,手机号码已存在");
|
|
|
- }
|
|
|
+
|
|
|
// 校验分机号是否为空
|
|
|
if (null == user.getExtNum()) {
|
|
|
throw new RuntimeException("新增用户失败,分机号不能为空");
|
|
|
@@ -1363,27 +1356,34 @@ public class ApiController extends BaseController {
|
|
|
if (null == extNum) {
|
|
|
throw new RuntimeException("新增用户失败,分机号" + user.getExtNum() + "不存在");
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
user.setSalt(ShiroUtils.randomSalt());
|
|
|
-
|
|
|
user.setPassword(passwordService.encryptPassword(user.getLoginName(), user.getPassword(), user.getSalt()));
|
|
|
-
|
|
|
user.setPwdUpdateDate(DateUtils.getNowDate());
|
|
|
user.setCreateBy("ylrz");
|
|
|
- int i = userService.insertUser(user);
|
|
|
+ int i;
|
|
|
+ SysUser sysUser = userService.selectUserByLoginName(user.getLoginName());
|
|
|
+ if (sysUser != null)
|
|
|
+ {
|
|
|
+ //优化一下,如果账号存在就更新账号
|
|
|
+ user.setUserId(sysUser.getUserId());
|
|
|
+ i = userService.updateUser(user);
|
|
|
+ }else{
|
|
|
+ i = userService.insertUser(user);
|
|
|
+ }
|
|
|
+
|
|
|
if(i>0){
|
|
|
//绑定分机
|
|
|
extNum.setUserCode(user.getLoginName());
|
|
|
int num = ccExtNumService.updateCcExtNum(extNum);
|
|
|
if(num>0){
|
|
|
user.setExtPass(extNum.getExtPass());
|
|
|
- log.info("新增用户成功,用户名:{},分机号:{}", user.getLoginName(), user.getExtNum());
|
|
|
return AjaxResult.success(user);
|
|
|
} else {
|
|
|
- throw new RuntimeException("新增用户成功,但分机号绑定失败");
|
|
|
+ throw new RuntimeException("用户信息处理成功,但分机号绑定失败");
|
|
|
}
|
|
|
}
|
|
|
- throw new RuntimeException("新增用户失败");
|
|
|
+ throw new RuntimeException("新增用户和绑分机操作失败");
|
|
|
}
|
|
|
/**
|
|
|
* 修改用户且绑分机
|