Commit 5987dbf3 by guojuxing

新建管理员的时候,判断手机号码重复,想要区别管理员类别:gic管理员、运营实施管理员

parent 5287943f
...@@ -66,6 +66,20 @@ public interface TabSysUserMapper { ...@@ -66,6 +66,20 @@ public interface TabSysUserMapper {
int countByPhone(@Param("phone") String phone, @Param("userId") Integer userId, int countByPhone(@Param("phone") String phone, @Param("userId") Integer userId,
@Param("enterpriseId") Integer enterpriseId); @Param("enterpriseId") Integer enterpriseId);
/**
* 手机号码查询个数
* @Title: countByPhoneAndLoginType

* @Description:

 * @author guojuxing
* @param phone
* @param userId
* @param enterpriseId

* @param loginType
* @return int


 */
int countByPhoneAndLoginType(@Param("phone") String phone, @Param("userId") Integer userId,
@Param("enterpriseId") Integer enterpriseId, @Param("loginType") Integer loginType);
TabSysUser selectByEnterpriseId(@Param("enterpriseId") Integer enterpriseId); TabSysUser selectByEnterpriseId(@Param("enterpriseId") Integer enterpriseId);
List<TabSysUser> listAllUserByPhoneNumber(@Param("phoneNumber") String phoneNumber); List<TabSysUser> listAllUserByPhoneNumber(@Param("phoneNumber") String phoneNumber);
......
...@@ -48,6 +48,19 @@ public interface UserService { ...@@ -48,6 +48,19 @@ public interface UserService {
*/ */
boolean isPhoneRepeat(Integer userId, String phone, Integer enterpriseId); boolean isPhoneRepeat(Integer userId, String phone, Integer enterpriseId);
/**
* 手机号码是否重复
* @Title: isPhoneRepeat

* @Description:

 * @author guojuxing
* @param userId
* @param phone 手机号码
* @param enterpriseId 商户ID
* @param loginType
 管理员类别
* @return boolean


 */
boolean isPhoneRepeat(Integer userId, String phone, Integer enterpriseId, Integer loginType);
TabSysUser getUserByEnterpriseId(Integer enterpriseId); TabSysUser getUserByEnterpriseId(Integer enterpriseId);
List<TabSysUser> listAllUserByPhoneNumber(String phoneNumber); List<TabSysUser> listAllUserByPhoneNumber(String phoneNumber);
......
...@@ -75,6 +75,18 @@ public class UserServiceImpl implements UserService { ...@@ -75,6 +75,18 @@ public class UserServiceImpl implements UserService {
} }
@Override @Override
public boolean isPhoneRepeat(Integer userId, String phone, Integer enterpriseId, Integer loginType) {
if (loginType == null) {
loginType = LoginUserTypeEnum.GIC_USER.getCode();
}
int count = tabSysUserMapper.countByPhoneAndLoginType(phone, userId, enterpriseId, loginType);
if (count > 0) {
return true;
}
return false;
}
@Override
public TabSysUser getUserByEnterpriseId(Integer enterpriseId) { public TabSysUser getUserByEnterpriseId(Integer enterpriseId) {
return tabSysUserMapper.selectByEnterpriseId(enterpriseId); return tabSysUserMapper.selectByEnterpriseId(enterpriseId);
} }
......
...@@ -62,7 +62,7 @@ public class UserApiServiceImpl implements UserApiService { ...@@ -62,7 +62,7 @@ public class UserApiServiceImpl implements UserApiService {
if (!paramResult.isSuccess()) { if (!paramResult.isSuccess()) {
return paramResult; return paramResult;
} }
if (userService.isPhoneRepeat(null, userDTO.getPhoneNumber(), userDTO.getEnterpriseId())) { if (userService.isPhoneRepeat(null, userDTO.getPhoneNumber(), userDTO.getEnterpriseId(), null)) {
return ServiceResponse.failure(ErrorCode.PARAMETER_ERROR.getCode(), "手机号码不能重复"); return ServiceResponse.failure(ErrorCode.PARAMETER_ERROR.getCode(), "手机号码不能重复");
} }
...@@ -127,7 +127,8 @@ public class UserApiServiceImpl implements UserApiService { ...@@ -127,7 +127,8 @@ public class UserApiServiceImpl implements UserApiService {
if (userDTO.getEnterpriseId() == null) { if (userDTO.getEnterpriseId() == null) {
ServiceResponse.failure(ErrorCode.PARAMETER_ERROR.getCode(), "商户ID不能为空"); ServiceResponse.failure(ErrorCode.PARAMETER_ERROR.getCode(), "商户ID不能为空");
} }
if (userService.isPhoneRepeat(null, userDTO.getPhoneNumber(), userDTO.getEnterpriseId())) { if (userService.isPhoneRepeat(null, userDTO.getPhoneNumber(), userDTO.getEnterpriseId(),
LoginUserTypeEnum.OPERATION_USER.getCode())) {
return ServiceResponse.failure(ErrorCode.PARAMETER_ERROR.getCode(), "手机号码不能重复"); return ServiceResponse.failure(ErrorCode.PARAMETER_ERROR.getCode(), "手机号码不能重复");
} }
return ServiceResponse.success(userService.saveOperationUser(userDTO)); return ServiceResponse.success(userService.saveOperationUser(userDTO));
...@@ -140,7 +141,7 @@ public class UserApiServiceImpl implements UserApiService { ...@@ -140,7 +141,7 @@ public class UserApiServiceImpl implements UserApiService {
if (!paramResult.isSuccess()) { if (!paramResult.isSuccess()) {
return paramResult; return paramResult;
} }
if (userService.isPhoneRepeat(null, userDTO.getPhoneNumber(), userDTO.getEnterpriseId())) { if (userService.isPhoneRepeat(null, userDTO.getPhoneNumber(), userDTO.getEnterpriseId(), null)) {
return ServiceResponse.failure(ErrorCode.PARAMETER_ERROR.getCode(), "手机号码不能重复"); return ServiceResponse.failure(ErrorCode.PARAMETER_ERROR.getCode(), "手机号码不能重复");
} }
if (userDTO.getPasswordType() == null) { if (userDTO.getPasswordType() == null) {
...@@ -167,7 +168,7 @@ public class UserApiServiceImpl implements UserApiService { ...@@ -167,7 +168,7 @@ public class UserApiServiceImpl implements UserApiService {
if (tabUser == null) { if (tabUser == null) {
return ServiceResponse.failure(ErrorCode.PARAMETER_ERROR.getCode(), "用户ID输入有误"); return ServiceResponse.failure(ErrorCode.PARAMETER_ERROR.getCode(), "用户ID输入有误");
} }
if (userService.isPhoneRepeat(userDTO.getUserId(), userDTO.getPhoneNumber(), tabUser.getEnterpriseId())) { if (userService.isPhoneRepeat(userDTO.getUserId(), userDTO.getPhoneNumber(), tabUser.getEnterpriseId(), null)) {
return ServiceResponse.failure(ErrorCode.PARAMETER_ERROR.getCode(), "手机号码不能重复"); return ServiceResponse.failure(ErrorCode.PARAMETER_ERROR.getCode(), "手机号码不能重复");
} }
//gic管理员只有一个超管 //gic管理员只有一个超管
...@@ -405,7 +406,8 @@ public class UserApiServiceImpl implements UserApiService { ...@@ -405,7 +406,8 @@ public class UserApiServiceImpl implements UserApiService {
} }
@Override @Override
public ServiceResponse<String> editPhoneOrPassword(Integer userId, String nationCode, String phone, String password) { public ServiceResponse<String> editPhoneOrPassword(Integer userId, String nationCode, String phone,
String password) {
TabSysUser tabUser = userService.getUserById(userId); TabSysUser tabUser = userService.getUserById(userId);
if (tabUser == null) { if (tabUser == null) {
return ServiceResponse.failure(ErrorCode.PARAMETER_ERROR.getCode(), "用户ID输入有误,无此数据"); return ServiceResponse.failure(ErrorCode.PARAMETER_ERROR.getCode(), "用户ID输入有误,无此数据");
......
...@@ -197,6 +197,17 @@ ...@@ -197,6 +197,17 @@
and phone_number = #{phone} and phone_number = #{phone}
</select> </select>
<select id="countByPhoneAndLoginType" resultType="int">
select count(1) from tab_sys_user
where status = 1
<if test="userId != null">
and user_id <![CDATA[ <> ]]> #{userId}
</if>
and enterprise_id = #{enterpriseId}
and phone_number = #{phone}
and login_type = #{loginType}
</select>
<select id="selectByEnterpriseId" parameterType="java.lang.Integer" resultMap="BaseResultMap"> <select id="selectByEnterpriseId" parameterType="java.lang.Integer" resultMap="BaseResultMap">
select select
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment