feat:add phone query api

This commit is contained in:
zzs 2025-03-06 15:44:20 +08:00
parent 154b2ac47a
commit 8e3966b54b
3 changed files with 33 additions and 0 deletions

View File

@ -170,4 +170,17 @@ public class UserController {
return success(userService.importUserList(list, updateSupport));
}
@GetMapping("/get/phone")
@Operation(summary = "手机号查询用户")
@Parameter(name = "phone", description = "手机号", required = true, example = "15898763434")
@PreAuthorize("@ss.hasPermission('system:user:query')")
public CommonResult<UserRespVO> getUser(@RequestParam("phone") String phone) {
AdminUserDO user = userService.getUserByPhone(phone);
if (user == null) {
return success(null);
}
// 拼接数据
DeptDO dept = deptService.getDept(user.getDeptId());
return success(UserConvert.INSTANCE.convert(user, dept));
}
}

View File

@ -214,4 +214,6 @@ public interface AdminUserService {
*/
AdminUserDO getUserByOpenId(String openId);
AdminUserDO getUserByPhone(String phone);
}

View File

@ -529,4 +529,22 @@ public class AdminUserServiceImpl implements AdminUserService {
return user;
}
}
@Override
public AdminUserDO getUserByPhone(String phone) {
LambdaQueryWrapperX<AdminUserDO> queryWrapperX = new LambdaQueryWrapperX<>();
queryWrapperX.eq(AdminUserDO::getMobile, phone);
List<AdminUserDO> users = userMapper.selectList(queryWrapperX);
if (users.isEmpty()) {
return null;
}
AdminUserDO user = users.get(0);
Integer status = user.getStatus();
if (Objects.equals(status, CommonStatusEnum.DISABLE.getStatus())) {
throw exception(AUTH_LOGIN_USER_DISABLED);
} else {
return user;
}
}
}