李进 2 lat temu
rodzic
commit
3a785c48cb

+ 17 - 0
sys-api-service/src/main/java/com/xy/service/UserInfoServiceImpl.java

@@ -15,6 +15,7 @@ import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import lombok.AllArgsConstructor;
 import org.springframework.stereotype.Service;
+import org.springframework.util.StringUtils;
 import org.springframework.validation.annotation.Validated;
 import org.springframework.web.bind.annotation.PostMapping;
 import org.springframework.web.bind.annotation.RequestBody;
@@ -112,6 +113,22 @@ public class UserInfoServiceImpl extends ServiceImpl<UserInfoMapper, UserInfo> i
     @Lock(value = "update.userId", prefix = "user_update_")
     public R update(@RequestBody @Validated UserInfoDto.Update update) {
         UserInfo byId = getById(update.getUserId());
+        if (!StringUtils.isEmpty(update.getTel())) {
+            if (!byId.getTel().equals(update.getTel())) {
+                long count = count(new LambdaQueryWrapper<UserInfo>().eq(UserInfo::getTel, update.getTel()));
+                if (count > 0) {
+                    return R.fail("手机号已存在");
+                }
+            }
+        }
+        if (!StringUtils.isEmpty(update.getMail())) {
+            if (!byId.getMail().equals(update.getMail())) {
+                long count = count(new LambdaQueryWrapper<UserInfo>().eq(UserInfo::getTel, update.getMail()));
+                if (count > 0) {
+                    return R.fail("邮箱已存在");
+                }
+            }
+        }
         //系统累加
         if (Emptys.check(update.getSysIds())) {
             update.setSysIds(byId.getSysIds().indexOf(update.getSysIds()) == -1 ? new StringJoiner(",").add(byId.getSysIds()).add(update.getSysIds()).toString() : null);