用户可以修改相同手机号修复

This commit is contained in:
张松 2025-03-01 15:05:30 +08:00
parent 8de08b17cd
commit fd257f1b3b
2 changed files with 8 additions and 0 deletions

View File

@ -1,6 +1,7 @@
package com.czg.account.dto.shopuser;
import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.Size;
import lombok.Data;
/**
@ -16,6 +17,7 @@ public class ShopUserEditDTO {
/**
* 昵称
*/
@Size(min = 1, message = "昵称不为空")
private String nickName;
/**
* 性别 0女 1男
@ -24,9 +26,11 @@ public class ShopUserEditDTO {
/**
* 生日
*/
@Size(min = 1, message = "生日不为空")
private String birthDay;
/**
* 手机号
*/
@Size(min = 1, message = "手机号不为空")
private String phone;
}

View File

@ -85,6 +85,10 @@ public class ShopUserServiceImpl extends ServiceImpl<ShopUserMapper, ShopUser> i
@Override
public Boolean updateInfo(Long shopId, ShopUserEditDTO shopUserEditDTO) {
long count = count(new QueryWrapper().eq(ShopUser::getShopId, shopId).eq(ShopUser::getPhone, shopUserEditDTO.getPhone()).ne(ShopUser::getId, shopUserEditDTO.getId()));
if (count > 0) {
throw new ApiNotPrintException("手机号已存在");
}
ShopUser shopUser = getUserInfo(shopId, shopUserEditDTO.getId());
BeanUtil.copyProperties(shopUserEditDTO, shopUser);
return updateById(shopUser);