Skip to content

Commit

Permalink
fix: 修复更新手机号、邮箱未加密的问题
Browse files Browse the repository at this point in the history
  • Loading branch information
Charles7c committed Jun 6, 2024
1 parent 0cfc7a5 commit 485d708
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -108,4 +108,24 @@ IPage<UserDetailResp> selectUserPage(@Param("page") IPage<UserDO> page,
* @return 用户数量
*/
Long selectCountByPhone(@FieldEncrypt @Param("phone") String phone, @Param("id") Long id);

/**
* 修改手机号
*
* @param phone 手机号
* @param id ID
* @return 影响行数
*/
@Select("UPDATE sys_user SET phone = #{phone} WHERE id = #{id}")
int updatePhone(@FieldEncrypt @Param("phone") String phone, @Param("id") Long id);

/**
* 修改邮箱
*
* @param email 邮箱
* @param id ID
* @return 影响行数
*/
@Select("UPDATE sys_user SET email = #{email} WHERE id = #{id}")
int updateEmail(@FieldEncrypt @Param("email") String email, @Param("id") Long id);
}
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ public void updatePhone(String newPhone, String oldPassword, Long id) {
CheckUtils.throwIf(this.isPhoneExists(newPhone, id), "手机号已绑定其他账号,请更换其他手机号");
CheckUtils.throwIfEqual(newPhone, user.getPhone(), "新手机号不能与当前手机号相同");
// 更新手机号
baseMapper.lambdaUpdate().set(UserDO::getPhone, newPhone).eq(UserDO::getId, id).update();
baseMapper.updatePhone(newPhone, id);
}

@Override
Expand All @@ -243,7 +243,7 @@ public void updateEmail(String newEmail, String oldPassword, Long id) {
CheckUtils.throwIf(this.isEmailExists(newEmail, id), "邮箱已绑定其他账号,请更换其他邮箱");
CheckUtils.throwIfEqual(newEmail, user.getEmail(), "新邮箱不能与当前邮箱相同");
// 更新邮箱
baseMapper.lambdaUpdate().set(UserDO::getEmail, newEmail).eq(UserDO::getId, id).update();
baseMapper.updateEmail(newEmail, id);
}

@Override
Expand Down

0 comments on commit 485d708

Please sign in to comment.