增加通过手机号获取用户详情
This commit is contained in:
parent
1ce76e9f56
commit
08407ccbad
@ -67,4 +67,6 @@ public interface IUserRemoteService {
|
||||
@RemotePutMethod("/update-password/{userId}")
|
||||
SuccessResult updatePassword(@RemoteServerParams String userCenter, @RemotePathParams("userId") String userId, @RemoteQueryParams("access_token") String accessToken, @RemoteJsonBodyParams UpdatePasswordVO updatePasswordVO);
|
||||
|
||||
@RemotePostMethod("/list/phones/{phones}")
|
||||
List<UserDTO> listByUserPhones(@RemoteServerParams String userCenter, @RemotePathParams("userId") String userId, @RemoteQueryParams("access_token") String accessToken, @RemoteJsonBodyParams IdsVO idsVO);
|
||||
}
|
||||
|
@ -188,6 +188,16 @@ public class UserServiceImpl extends DefaultBaseService implements IUserService
|
||||
return new ArrayList<>(userIdSet);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<UserDTO> listByUserPhones(List<String> phones) {
|
||||
if (phones.isEmpty()) {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
IdsVO idsVO = new IdsVO();
|
||||
idsVO.setIds(phones);
|
||||
return userRemoteService.listByUserPhones(apiPathProperties.getUserCenter(), securityComponent.getCurrentUser().getUserId(), OAuth2ClientTokenManager.getInstance().getToken().getAccessToken(), idsVO);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updatePassword(UpdatePasswordVO updatePasswordVO) {
|
||||
userRemoteService.updatePassword(apiPathProperties.getUserCenter(), securityComponent.getCurrentUser().getUserId(), OAuth2ClientTokenManager.getInstance().getToken().getAccessToken(), updatePasswordVO);
|
||||
|
@ -140,6 +140,16 @@ public class UserResourceController extends DefaultBaseController {
|
||||
return userService.listByUsernames(idsVO.getIds());
|
||||
}
|
||||
|
||||
@ApiOperation(value = "通过手机号列表获取用户列表", notes = "通过手机号列表获取用户列表接口")
|
||||
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
|
||||
@PostMapping("list/phones")
|
||||
public List<UserDTO> listByPhones(@RequestBody IdsVO idsVO) {
|
||||
if (idsVO.getIds().isEmpty()) {
|
||||
throw new ParamsException("手机号列表不能为空");
|
||||
}
|
||||
return userService.listByUserPhones(idsVO.getIds());
|
||||
}
|
||||
|
||||
@ApiOperation(value = "获取密码状态", notes = "获取密码状态接口")
|
||||
@ApiImplicitParams({@ApiImplicitParam(name = "userId", value = "用户ID", paramType = "path"),})
|
||||
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
|
||||
|
@ -241,6 +241,14 @@ public interface IUserService extends IUserBaseService, IUserCheckService {
|
||||
*/
|
||||
UserPO getPOByUsername(String username);
|
||||
|
||||
/**
|
||||
* 用户详情
|
||||
*
|
||||
* @param phone 用户手机号
|
||||
* @return
|
||||
*/
|
||||
UserPO getPOByPhone(String phone);
|
||||
|
||||
/**
|
||||
* 更新登陆信息
|
||||
*
|
||||
|
@ -115,6 +115,12 @@ public class UserServiceImpl extends DefaultBaseService implements IUserService
|
||||
if (userDTO != null) {
|
||||
throw new SearchException("用户已经存在");
|
||||
}
|
||||
if (StringUtils.isBlank(userVO.getUserPhone())) {
|
||||
UserPO userPO = getPOByPhone(userVO.getUserPhone());
|
||||
if (userPO != null) {
|
||||
throw new SearchException("手机号已经存在");
|
||||
}
|
||||
}
|
||||
userVO.setUserPassword(passwordEncoder.encode(DigestUtils.md5Hex(DigestUtils.md5Hex(DigestUtils.md5Hex(userVO.getUserPassword())))));
|
||||
String userId = UUIDUtil.getUUID();
|
||||
Map<String, Object> params = HashMapUtil.beanToMap(userVO);
|
||||
@ -146,6 +152,12 @@ public class UserServiceImpl extends DefaultBaseService implements IUserService
|
||||
if (!StringUtils.isBlank(userVO.getUserPassword())) {
|
||||
userVO.setUserPassword(passwordEncoder.encode(DigestUtils.md5Hex(DigestUtils.md5Hex(DigestUtils.md5Hex(userVO.getUserPassword())))));
|
||||
}
|
||||
if (StringUtils.isBlank(userVO.getUserPhone())) {
|
||||
UserPO userPO = getPOByPhone(userVO.getUserPhone());
|
||||
if (userPO != null) {
|
||||
throw new SearchException("手机号已经存在");
|
||||
}
|
||||
}
|
||||
Map<String, Object> params = HashMapUtil.beanToMap(userVO);
|
||||
setUpdateInfo(params);
|
||||
params.put("userId", userId);
|
||||
@ -408,6 +420,13 @@ public class UserServiceImpl extends DefaultBaseService implements IUserService
|
||||
return userDao.getPO(params);
|
||||
}
|
||||
|
||||
@Override
|
||||
public UserPO getPOByPhone(String phone) {
|
||||
Map<String, Object> params = getHashMap(2);
|
||||
params.put("userPhone", phone);
|
||||
return userDao.getPO(params);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateLoginInfo(Map<String, Object> params) throws UpdateException {
|
||||
userDao.updateLoginInfo(params);
|
||||
@ -687,6 +706,16 @@ public class UserServiceImpl extends DefaultBaseService implements IUserService
|
||||
return new ArrayList<>(userIdSet);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<UserDTO> listByUserPhones(List<String> userPhones) {
|
||||
if (userPhones.isEmpty()) {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
Map<String, Object> params = getHashMap(2);
|
||||
params.put("userPhones", userPhones);
|
||||
return userDao.list(params);
|
||||
}
|
||||
|
||||
/**
|
||||
* Excel导入错误对象
|
||||
*
|
||||
|
@ -307,6 +307,10 @@
|
||||
AND
|
||||
user_username = #{userUsername}
|
||||
</if>
|
||||
<if test="userPhone != null and userPhone != ''">
|
||||
AND
|
||||
user_phone = #{userPhone}
|
||||
</if>
|
||||
<if test="userUKey != null and userUKey != ''">
|
||||
AND
|
||||
user_ukey = #{userUKey}
|
||||
@ -428,6 +432,13 @@
|
||||
AND
|
||||
user_type != #{excludeUserType}
|
||||
</if>
|
||||
<if test="userPhones != null and userPhones.size > 0">
|
||||
AND
|
||||
user_phone IN
|
||||
<foreach collection="userPhones" index="index" open="(" separator="," close=")">
|
||||
#{userPhones[${index}]}
|
||||
</foreach>
|
||||
</if>
|
||||
<choose>
|
||||
<when test="sort != null and (sort == 'userUsername' or sort == 'userName' or sort == 'userPhone' or sort == 'userEmail' or sort == 'userState' or sort == 'lastLoginAddress' or sort == 'lastLoginTime')">
|
||||
ORDER BY
|
||||
|
Loading…
Reference in New Issue
Block a user