|
|
@@ -1,6 +1,7 @@
|
|
|
package com.izouma.wenlvju.web;
|
|
|
|
|
|
import cn.hutool.core.util.ObjectUtil;
|
|
|
+import cn.hutool.core.util.StrUtil;
|
|
|
import com.izouma.wenlvju.domain.User;
|
|
|
import com.izouma.wenlvju.dto.ExpertDTO;
|
|
|
import com.izouma.wenlvju.dto.OrganizationRegDTO;
|
|
|
@@ -69,15 +70,13 @@ public class UserController extends BaseController {
|
|
|
public User save(@RequestBody User user) {
|
|
|
if (user.getId() != null) {
|
|
|
User orig = userRepo.findById(user.getId()).orElseThrow(new BusinessException("无记录"));
|
|
|
- ObjUtils.merge(orig, user);
|
|
|
- if (ObjectUtil.isNotNull(orig.getPhone())) {
|
|
|
- User byPhone = userRepo.findByPhoneAndDelFalse(orig.getPhone());
|
|
|
+ if (StrUtil.isNotEmpty(user.getPhone())) {
|
|
|
+ User byPhone = userRepo.findByPhoneAndDelFalseAndIdIsNot(user.getPhone(), user.getId());
|
|
|
if (ObjectUtil.isNotNull(byPhone)) {
|
|
|
- if (!byPhone.getId().equals(user.getId())) {
|
|
|
- throw new BusinessException("该手机号已绑定");
|
|
|
- }
|
|
|
+ throw new BusinessException("该手机号已绑定");
|
|
|
}
|
|
|
}
|
|
|
+ ObjUtils.merge(orig, user);
|
|
|
return userRepo.save(orig);
|
|
|
}
|
|
|
return userRepo.save(user);
|