From 0335395776e31684631e927c987ef3bbe20c438a Mon Sep 17 00:00:00 2001 From: Gary Date: Mon, 22 Jan 2024 11:28:15 +0800 Subject: [PATCH] 1.add getSupportedCountryCode interface 2.disable findUserByIds --- .../luoo/user/controller/LoginController.java | 44 ++++++++++++------- .../controller/UserCollectController.java | 13 +++--- .../main/java/com/luoo/user/dao/UserDao.java | 6 ++- .../com/luoo/user/service/UserService.java | 14 +++--- 4 files changed, 47 insertions(+), 30 deletions(-) diff --git a/luoo_user/src/main/java/com/luoo/user/controller/LoginController.java b/luoo_user/src/main/java/com/luoo/user/controller/LoginController.java index 14dd09f..ec0f91f 100644 --- a/luoo_user/src/main/java/com/luoo/user/controller/LoginController.java +++ b/luoo_user/src/main/java/com/luoo/user/controller/LoginController.java @@ -1,7 +1,9 @@ package com.luoo.user.controller; import java.io.IOException; +import java.util.Arrays; import java.util.Date; +import java.util.List; import java.util.concurrent.TimeUnit; import javax.servlet.http.HttpServletRequest; @@ -44,7 +46,7 @@ import util.StringTools; @RequestMapping("/user") @Api(tags = "LoginController") public class LoginController extends BaseController{ - + private static final List DEFAULT_SUPPORTED_COUNTRY_CODES=Arrays.asList("+86"); @Autowired private UserInfoService userInfoService; @@ -68,11 +70,13 @@ public class LoginController extends BaseController{ */ @ApiOperation(value = "1.发送短信验证码", notes = "有效期15分钟,一个手机号一天内最多发送50个请求") @ApiImplicitParams({ @ApiImplicitParam(name = "mobile", value = "手机号", required = true), - @ApiImplicitParam(name = "deviceId", value = "设备id,最长32位", required = true)}) + @ApiImplicitParam(name = "countryCode", value = "国家码,默认为‘+86’", required = false, defaultValue="+86"), + @ApiImplicitParam(name = "deviceId", value = "设备id", required = true)}) @PostMapping("/sendsms") @GlobalInterceptor(frequencyType = RequestFrequencyTypeEnum.DAY, requestFrequencyThreshold = 50) public Result sendSms( - @VerifyParam(required = true, max = 32) @RequestParam("deviceId") String deviceId, + @VerifyParam(required = true) @RequestParam("deviceId") String deviceId, + @RequestParam(name="countryCode",defaultValue="+86") String countryCode, @VerifyParam(required = true, regex = VerifyRegexEnum.MOBILE) @RequestParam("mobile") String mobile) { userInfoService.sendSms(deviceId,mobile); return Result.success(); @@ -81,15 +85,15 @@ public class LoginController extends BaseController{ @ApiOperation(value = "2.登录/注册", notes = "成功后返回token") @ApiImplicitParams({ @ApiImplicitParam(name = "mobile", value = "手机号", required = true), @ApiImplicitParam(name = "mobileCheckCode", value = "6位验证码", required = true), - @ApiImplicitParam(name = "deviceId", value = "设备id,最长32位", required = true), - @ApiImplicitParam(name = "deviceBrand", value = "设备品牌,最长30位", required = false) }) + @ApiImplicitParam(name = "deviceId", value = "设备id", required = true), + @ApiImplicitParam(name = "deviceBrand", value = "设备品牌", required = false) }) @PostMapping("/appLogin") @GlobalInterceptor public Result appLogin(HttpServletRequest request, @VerifyParam(required = true, regex = VerifyRegexEnum.MOBILE) @RequestParam("mobile") String mobile, @VerifyParam(required = true, regex = VerifyRegexEnum.MOBILE_CHECK_CODE) @RequestParam("mobileCheckCode") String mobileCheckCode, - @VerifyParam(required = true, max = 32) @RequestParam("deviceId") String deviceId, - @VerifyParam(max = 30) @RequestParam("deviceBrand") String deviceBrand) { + @VerifyParam(required = true) @RequestParam("deviceId") String deviceId, + @RequestParam("deviceBrand") String deviceBrand) { // 得到缓存中的验证码 String redisMobileCheckCodeKey = Constants.REDIS_KEY_MOBILE_CHECK_CODE + deviceId; try { @@ -118,13 +122,13 @@ public class LoginController extends BaseController{ */ @ApiOperation(value = "3.token续期", notes = "有效期7天") @ApiImplicitParams({ - @ApiImplicitParam(name = "deviceId", value = "设备id,最长32位", required = true), - @ApiImplicitParam(name = "deviceBrand", value = "设备品牌,最长30位", required = false) }) + @ApiImplicitParam(name = "deviceId", value = "设备id", required = true), + @ApiImplicitParam(name = "deviceBrand", value = "设备品牌", required = false) }) @PostMapping("/autoLogin") @GlobalInterceptor public Result autoLogin(HttpServletRequest request,@RequestHeader(value = "token", required = false) String token, - @VerifyParam(required = true, max = 32) @RequestParam("deviceId") String deviceId, - @VerifyParam(max = 30) @RequestParam("deviceBrand") String deviceBrand) { + @VerifyParam(required = true) @RequestParam("deviceId") String deviceId, + @RequestParam("deviceBrand") String deviceBrand) { return Result.success(userInfoService.autoLogin(token,deviceId,deviceBrand,getIpAddr(request))); } @@ -133,11 +137,11 @@ public class LoginController extends BaseController{ */ @ApiOperation(value = "4.获取图形验证码", notes = "4.三次短信验证失败后,获取图形验证码,有效期10分钟") @ApiImplicitParams({ - @ApiImplicitParam(name = "deviceId", value = "设备id,最长32位", required = true)}) + @ApiImplicitParam(name = "deviceId", value = "设备id", required = true)}) @GetMapping("/imageCheckCode/{deviceId}") @GlobalInterceptor public void imageCheckCode(HttpServletResponse response, - @VerifyParam(required = true, max = 32) @PathVariable("deviceId") String deviceId) + @VerifyParam(required = true) @PathVariable("deviceId") String deviceId) throws IOException { CreateImageCode vCode = new CreateImageCode(130, 38, 5, 10); response.setHeader("Pragma", "no-cache"); @@ -157,8 +161,8 @@ public class LoginController extends BaseController{ HttpServletRequest request, @VerifyParam(required = true, regex = VerifyRegexEnum.MOBILE) @RequestParam("mobile") String mobile, @VerifyParam(required = true, regex = VerifyRegexEnum.MOBILE_CHECK_CODE) @RequestParam("mobileCheckCode") String mobileCheckCode, - @VerifyParam(required = true, max = 32) @RequestParam("deviceId") String deviceId, - @VerifyParam(max = 30) @RequestParam("deviceBrand") String deviceBrand, + @VerifyParam(required = true) @RequestParam("deviceId") String deviceId, + @RequestParam("deviceBrand") String deviceBrand, @VerifyParam(required = true) @RequestParam("imageCheckCode") String imageCheckCode) { // 得到缓存中的验证码 String redisImageCheckCodeKey = Constants.REDIS_KEY_IMAGE_CHECK_CODE + deviceId; @@ -173,6 +177,16 @@ public class LoginController extends BaseController{ return appLogin(request, mobile, mobileCheckCode, deviceId, deviceBrand); } + /** + * 获取支持的手机号国家码 + */ + @ApiOperation(value = "6.获取支持的手机号国家码", notes = "v1仅支持'+86'") + @GetMapping("/supportedCountryCode") + @GlobalInterceptor + public Result> getSupportedCountryCode(){ + return Result.success(DEFAULT_SUPPORTED_COUNTRY_CODES); + } + /** * 删除 * diff --git a/luoo_user/src/main/java/com/luoo/user/controller/UserCollectController.java b/luoo_user/src/main/java/com/luoo/user/controller/UserCollectController.java index 4b78db0..e8b4217 100644 --- a/luoo_user/src/main/java/com/luoo/user/controller/UserCollectController.java +++ b/luoo_user/src/main/java/com/luoo/user/controller/UserCollectController.java @@ -55,11 +55,12 @@ public class UserCollectController { return Result.success(); } - @ApiOperation(value = "根据 IDs 获取用户简要信息") - @GetMapping("/findUserByIds") - public Result> findUserByIds(@RequestBody List ids) { - List userByIds = userService.findUserByIds(ids); - return Result.success(userByIds); - } + /* + * @ApiOperation(value = "根据 IDs 获取用户简要信息") + * + * @GetMapping("/findUserByIds") public Result> + * findUserByIds(@RequestBody List ids) { List userByIds = + * userService.findUserByIds(ids); return Result.success(userByIds); } + */ } diff --git a/luoo_user/src/main/java/com/luoo/user/dao/UserDao.java b/luoo_user/src/main/java/com/luoo/user/dao/UserDao.java index c35d279..46b9f8f 100644 --- a/luoo_user/src/main/java/com/luoo/user/dao/UserDao.java +++ b/luoo_user/src/main/java/com/luoo/user/dao/UserDao.java @@ -30,6 +30,8 @@ public interface UserDao extends JpaRepository,JpaSpecificationExec public long countByNickname(String nickName); - @Query("SELECT * FROM tb_user m WHERE m.id IN ?1") - List findUserByIds(List ids); + /* + * @Query("SELECT * FROM tb_user m WHERE m.id IN ?1") List + * findUserByIds(List ids); + */ } diff --git a/luoo_user/src/main/java/com/luoo/user/service/UserService.java b/luoo_user/src/main/java/com/luoo/user/service/UserService.java index f89a4ea..c824f29 100644 --- a/luoo_user/src/main/java/com/luoo/user/service/UserService.java +++ b/luoo_user/src/main/java/com/luoo/user/service/UserService.java @@ -300,11 +300,11 @@ public class UserService { } - public List findUserByIds(List ids) { - List userByIds = userDao.findUserByIds(ids); - if (CollectionUtils.isEmpty(userByIds)){ - return new ArrayList<>(); - } - return userByIds.stream().map(User::converSimpleUser).collect(Collectors.toList()); - } + /* + * public List findUserByIds(List ids) { List + * userByIds = userDao.findUserByIds(ids); if + * (CollectionUtils.isEmpty(userByIds)){ return new ArrayList<>(); } return + * userByIds.stream().map(User::converSimpleUser).collect(Collectors.toList()); + * } + */ }