diff --git a/dq-financial-hrms/src/main/java/com/daqing/financial/hrms/dao/UserDao.java b/dq-financial-hrms/src/main/java/com/daqing/financial/hrms/dao/UserDao.java index d07a978d..257862f9 100644 --- a/dq-financial-hrms/src/main/java/com/daqing/financial/hrms/dao/UserDao.java +++ b/dq-financial-hrms/src/main/java/com/daqing/financial/hrms/dao/UserDao.java @@ -5,6 +5,8 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper; import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Param; +import java.util.List; + /** * 人资管理系统,员工账号信息表,用于存储员工账号密码等登录相关数据 * @@ -28,4 +30,6 @@ public interface UserDao extends BaseMapper { Boolean updateWeChat(@Param("id") Long id, @Param("weChatId") String weChatId); Long getEmployeeIdByUserId(Long userId); + + List listPhoneAccount(); } diff --git a/dq-financial-hrms/src/main/java/com/daqing/financial/hrms/service/impl/UserServiceImpl.java b/dq-financial-hrms/src/main/java/com/daqing/financial/hrms/service/impl/UserServiceImpl.java index e5a217fd..a181940c 100644 --- a/dq-financial-hrms/src/main/java/com/daqing/financial/hrms/service/impl/UserServiceImpl.java +++ b/dq-financial-hrms/src/main/java/com/daqing/financial/hrms/service/impl/UserServiceImpl.java @@ -26,6 +26,7 @@ import javax.imageio.ImageIO; import javax.servlet.http.HttpServletRequest; import java.awt.image.BufferedImage; import java.io.*; +import java.util.List; import java.util.Objects; import java.util.UUID; @@ -75,6 +76,13 @@ public class UserServiceImpl extends ServiceImpl implements && employeeAndUserVO.getPrimaryCode() != null && employeeAndUserVO.getPrimaryCode().length() != 0) { // 没有绑定手机号,现在绑定 + List phoneAccounts = this.getBaseMapper().listPhoneAccount(); + for (String pAccount : phoneAccounts) { + // 判断该手机号是否已经绑定过了 + if (employeeAndUserVO.getPrimaryPhone().equals(pAccount)) { + ExceptionCast.cast(HrmsCode.USER_PHONE_ACCOUNT_REPETITION); + } + } String code = RedisUtil.get(employeeAndUserVO.getPrimaryPhone()); if (code == null || code.length() == 0 || !Objects.equals(employeeAndUserVO.getPrimaryCode(), code)) { ExceptionCast.cast(HrmsCode.USER_PHONE_CODE_MISTAKE); @@ -101,6 +109,13 @@ public class UserServiceImpl extends ServiceImpl implements ExceptionCast.cast(HrmsCode.USER_PRIMARY_CODE_MISTAKE); } RedisUtil.del(employeeAndUserVO.getPrimaryPhone()); + // 判断更换的手机号是否已绑定过用户 + List phoneAccounts = this.getBaseMapper().listPhoneAccount(); + for (String pAccount : phoneAccounts) { + if (employeeAndUserVO.getNewPhone().equals(pAccount)) { + ExceptionCast.cast(HrmsCode.USER_PHONE_ACCOUNT_REPETITION); + } + } String newCode = RedisUtil.get(employeeAndUserVO.getNewPhone()); if (newCode == null || newCode.length() == 0 || !Objects.equals(newCode, employeeAndUserVO.getNewCode())) { @@ -204,6 +219,13 @@ public class UserServiceImpl extends ServiceImpl implements if (phone == null || phone.length() == 0 || code == null || code.length() == 0) { ExceptionCast.cast(HrmsCode.USER_PHONE_OR_CODE_NOT_NULL); } + // 判断当前手机号是否已绑定用户 + List phoneAccounts = this.getBaseMapper().listPhoneAccount(); + for (String phoneAccount : phoneAccounts) { + if (phone.equals(phoneAccount)) { + ExceptionCast.cast(HrmsCode.USER_PHONE_ACCOUNT_REPETITION); + } + } if (RedisUtil.get(phone) == null || RedisUtil.get(phone).length() == 0 || !Objects.equals(code, RedisUtil.get(phone))) { ExceptionCast.cast(HrmsCode.USER_BINDING_FAIL); diff --git a/dq-financial-hrms/src/main/resources/mapper/hrms/UserDao.xml b/dq-financial-hrms/src/main/resources/mapper/hrms/UserDao.xml index ce325376..31fb728a 100644 --- a/dq-financial-hrms/src/main/resources/mapper/hrms/UserDao.xml +++ b/dq-financial-hrms/src/main/resources/mapper/hrms/UserDao.xml @@ -54,4 +54,9 @@ AND u.id = #{userId} + + + \ No newline at end of file diff --git a/dq-framework-model/src/main/java/com/daqing/framework/domain/hrms/response/HrmsCode.java b/dq-framework-model/src/main/java/com/daqing/framework/domain/hrms/response/HrmsCode.java index ae91c73f..679040c6 100644 --- a/dq-framework-model/src/main/java/com/daqing/framework/domain/hrms/response/HrmsCode.java +++ b/dq-framework-model/src/main/java/com/daqing/framework/domain/hrms/response/HrmsCode.java @@ -60,6 +60,7 @@ public enum HrmsCode implements ResultCode { USER_FILE_IS_NULL(false,88015,"当前文件不存在,请正确选择文件!"), USER_FILE_TYPE_MISTAKE(false,88013,"文件格式不正确,请重新选择图片文件!"), USER_FILE_UPLOAD_FAIL(false,88014,"上传图像失败,请稍后刷新再试!"), + USER_PHONE_ACCOUNT_REPETITION(false,88015,"该手机号已绑定过用户,请更换手机号!"), PHNOE_ACCOUNT_NOT_EMPTY(false,33001,"手机号码为空!"), VERIFY_CODE_NOT_EMPTY(false,33002,"短信验证码为空!"),