From b42902e1b974f3339a197a8ff4c2d23c08d884e4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B9=A6=E4=B8=AD=E8=87=AA=E6=9C=89=E9=A2=9C=E5=A6=82?= =?UTF-8?q?=E7=8E=89?= <1206770390@qq.com> Date: Sun, 27 Jul 2025 02:17:02 +0000 Subject: [PATCH] =?UTF-8?q?refactor(system/user):=20=E9=87=8D=E6=9E=84?= =?UTF-8?q?=E7=94=A8=E6=88=B7=E9=82=AE=E7=AE=B1=E5=92=8C=E6=89=8B=E6=9C=BA?= =?UTF-8?q?=E5=8F=B7=E5=94=AF=E4=B8=80=E6=80=A7=E6=A0=A1=E9=AA=8C=E9=80=BB?= =?UTF-8?q?=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../admin/system/mapper/user/UserMapper.java | 18 ------- .../system/service/impl/UserServiceImpl.java | 47 +++++++++---------- .../main/resources/mapper/user/UserMapper.xml | 18 ------- 3 files changed, 21 insertions(+), 62 deletions(-) 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