diff --git a/continew-system/src/main/java/top/continew/admin/system/mapper/user/UserMapper.java b/continew-system/src/main/java/top/continew/admin/system/mapper/user/UserMapper.java index 1237bc42..4a926588 100644 --- a/continew-system/src/main/java/top/continew/admin/system/mapper/user/UserMapper.java +++ b/continew-system/src/main/java/top/continew/admin/system/mapper/user/UserMapper.java @@ -94,22 +94,4 @@ public interface UserMapper extends DataPermissionMapper { */ @Select("SELECT nickname FROM sys_user WHERE id = #{id}") String selectNicknameById(@Param("id") Long id); - - /** - * 根据邮箱查询数量 - * - * @param email 邮箱 - * @param id ID - * @return 用户数量 - */ - Long selectCountByEmail(@FieldEncrypt @Param("email") String email, @Param("id") Long id); - - /** - * 根据手机号查询数量 - * - * @param phone 手机号 - * @param id ID - * @return 用户数量 - */ - Long selectCountByPhone(@FieldEncrypt @Param("phone") String phone, @Param("id") Long id); } diff --git a/continew-system/src/main/java/top/continew/admin/system/service/impl/UserServiceImpl.java b/continew-system/src/main/java/top/continew/admin/system/service/impl/UserServiceImpl.java index 2a7db3ac..4b0cd474 100644 --- a/continew-system/src/main/java/top/continew/admin/system/service/impl/UserServiceImpl.java +++ b/continew-system/src/main/java/top/continew/admin/system/service/impl/UserServiceImpl.java @@ -136,12 +136,8 @@ public class UserServiceImpl extends BaseServiceImpl 0; + private void checkEmailRepeat(String email, Long id, String template) { + CheckUtils.throwIf(StrUtil.isNotBlank(email) && baseMapper.lambdaQuery() + .eq(UserDO::getEmail, EncryptHelper.encrypt(email)) + .ne(ObjectUtil.isNotNull(id), UserDO::getId, id) + .exists(), template, email); } /** - * 手机号码是否存在 + * 检查手机号码是否重复 * * @param phone 手机号码 * @param id ID - * @return 是否存在 */ - private boolean isPhoneExists(String phone, Long id) { - Long count = baseMapper.selectCountByPhone(phone, id); - return count != null && count > 0; + private void checkPhoneRepeat(String phone, Long id, String template) { + CheckUtils.throwIf(StrUtil.isNotBlank(phone) && baseMapper.lambdaQuery() + .eq(UserDO::getPhone, EncryptHelper.encrypt(phone)) + .ne(ObjectUtil.isNotNull(id), UserDO::getId, id) + .exists(), template, phone); } /** diff --git a/continew-system/src/main/resources/mapper/user/UserMapper.xml b/continew-system/src/main/resources/mapper/user/UserMapper.xml index 1990d62f..059d63cd 100644 --- a/continew-system/src/main/resources/mapper/user/UserMapper.xml +++ b/continew-system/src/main/resources/mapper/user/UserMapper.xml @@ -35,22 +35,4 @@ ${ew.customSqlSegment} - - - - \ No newline at end of file