mirror of
https://gitee.com/log4j/pig.git
synced 2024-12-23 05:00:23 +08:00
commit
3a979e3923
@ -53,8 +53,8 @@ public interface RemoteUserService {
|
||||
* @param from 调用标志
|
||||
* @return R
|
||||
*/
|
||||
@GetMapping("/app/info/{mobile}")
|
||||
R<UserInfo> infoByMobile(@PathVariable("mobile") String mobile, @RequestHeader(SecurityConstants.FROM) String from);
|
||||
@GetMapping("/app/info/{phone}")
|
||||
R<UserInfo> infoByMobile(@PathVariable("phone") String phone, @RequestHeader(SecurityConstants.FROM) String from);
|
||||
|
||||
/**
|
||||
* 根据部门id,查询对应的用户 id 集合
|
||||
|
@ -56,8 +56,8 @@ public class RemoteUserServiceFallbackImpl implements RemoteUserService {
|
||||
* @return R
|
||||
*/
|
||||
@Override
|
||||
public R<UserInfo> infoByMobile(String mobile, String from) {
|
||||
log.error("feign 查询用户信息失败手机号码:{}", mobile, cause);
|
||||
public R<UserInfo> infoByMobile(String phone, String from) {
|
||||
log.error("feign 查询用户信息失败手机号码:{}", phone, cause);
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@ -39,11 +39,11 @@ public class AppController {
|
||||
* @return 用户信息
|
||||
*/
|
||||
@Inner
|
||||
@GetMapping("/info/{mobile}")
|
||||
public R infoByMobile(@PathVariable String mobile) {
|
||||
SysUser user = userService.getOne(Wrappers.<SysUser>query().lambda().eq(SysUser::getPhone, mobile));
|
||||
@GetMapping("/info/{phone}")
|
||||
public R infoByMobile(@PathVariable String phone) {
|
||||
SysUser user = userService.getOne(Wrappers.<SysUser>query().lambda().eq(SysUser::getPhone, phone));
|
||||
if (user == null) {
|
||||
return R.failed(String.format("用户信息为空 %s", mobile));
|
||||
return R.failed(String.format("用户信息为空 %s", phone));
|
||||
}
|
||||
return R.ok(userService.getUserInfo(user));
|
||||
}
|
||||
|
@ -47,7 +47,7 @@ public class OauthClientDetailsController {
|
||||
|
||||
/**
|
||||
* 通过ID查询
|
||||
* @param id clientId
|
||||
* @param clientId 客户端id
|
||||
* @return SysOauthClientDetails
|
||||
*/
|
||||
@GetMapping("/{clientId}")
|
||||
|
@ -50,29 +50,29 @@ public class AppServiceImpl implements AppService {
|
||||
|
||||
/**
|
||||
* 发送手机验证码 TODO: 调用短信网关发送验证码,测试返回前端
|
||||
* @param mobile mobile
|
||||
* @param phone 手机号
|
||||
* @return code
|
||||
*/
|
||||
@Override
|
||||
public R<Boolean> sendSmsCode(String mobile) {
|
||||
public R<Boolean> sendSmsCode(String phone) {
|
||||
List<SysUser> userList = userMapper
|
||||
.selectList(Wrappers.<SysUser>query().lambda().eq(SysUser::getPhone, mobile));
|
||||
.selectList(Wrappers.<SysUser>query().lambda().eq(SysUser::getPhone, phone));
|
||||
|
||||
if (CollUtil.isEmpty(userList)) {
|
||||
log.info("手机号未注册:{}", mobile);
|
||||
log.info("手机号未注册:{}", phone);
|
||||
return R.ok(Boolean.FALSE, "手机号未注册");
|
||||
}
|
||||
|
||||
Object codeObj = redisTemplate.opsForValue().get(CacheConstants.DEFAULT_CODE_KEY + mobile);
|
||||
Object codeObj = redisTemplate.opsForValue().get(CacheConstants.DEFAULT_CODE_KEY + phone);
|
||||
|
||||
if (codeObj != null) {
|
||||
log.info("手机号验证码未过期:{},{}", mobile, codeObj);
|
||||
log.info("手机号验证码未过期:{},{}", phone, codeObj);
|
||||
return R.ok(Boolean.FALSE, "验证码发送过频繁");
|
||||
}
|
||||
|
||||
String code = RandomUtil.randomNumbers(Integer.parseInt(SecurityConstants.CODE_SIZE));
|
||||
log.info("手机号生成验证码成功:{},{}", mobile, code);
|
||||
redisTemplate.opsForValue().set(CacheConstants.DEFAULT_CODE_KEY + mobile, code, SecurityConstants.CODE_TIME,
|
||||
log.info("手机号生成验证码成功:{},{}", phone, code);
|
||||
redisTemplate.opsForValue().set(CacheConstants.DEFAULT_CODE_KEY + phone, code, SecurityConstants.CODE_TIME,
|
||||
TimeUnit.SECONDS);
|
||||
return R.ok(Boolean.TRUE, code);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user