|
|
@ -1,7 +1,9 @@
|
|
|
|
package com.luoo.user.controller;
|
|
|
|
package com.luoo.user.controller;
|
|
|
|
|
|
|
|
|
|
|
|
import java.io.IOException;
|
|
|
|
import java.io.IOException;
|
|
|
|
|
|
|
|
import java.util.Arrays;
|
|
|
|
import java.util.Date;
|
|
|
|
import java.util.Date;
|
|
|
|
|
|
|
|
import java.util.List;
|
|
|
|
import java.util.concurrent.TimeUnit;
|
|
|
|
import java.util.concurrent.TimeUnit;
|
|
|
|
|
|
|
|
|
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
@ -44,7 +46,7 @@ import util.StringTools;
|
|
|
|
@RequestMapping("/user")
|
|
|
|
@RequestMapping("/user")
|
|
|
|
@Api(tags = "LoginController")
|
|
|
|
@Api(tags = "LoginController")
|
|
|
|
public class LoginController extends BaseController{
|
|
|
|
public class LoginController extends BaseController{
|
|
|
|
|
|
|
|
private static final List<String> DEFAULT_SUPPORTED_COUNTRY_CODES=Arrays.asList("+86");
|
|
|
|
@Autowired
|
|
|
|
@Autowired
|
|
|
|
private UserInfoService userInfoService;
|
|
|
|
private UserInfoService userInfoService;
|
|
|
|
|
|
|
|
|
|
|
@ -68,11 +70,13 @@ public class LoginController extends BaseController{
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
@ApiOperation(value = "1.发送短信验证码", notes = "有效期15分钟,一个手机号一天内最多发送50个请求")
|
|
|
|
@ApiOperation(value = "1.发送短信验证码", notes = "有效期15分钟,一个手机号一天内最多发送50个请求")
|
|
|
|
@ApiImplicitParams({ @ApiImplicitParam(name = "mobile", value = "手机号", required = true),
|
|
|
|
@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")
|
|
|
|
@PostMapping("/sendsms")
|
|
|
|
@GlobalInterceptor(frequencyType = RequestFrequencyTypeEnum.DAY, requestFrequencyThreshold = 50)
|
|
|
|
@GlobalInterceptor(frequencyType = RequestFrequencyTypeEnum.DAY, requestFrequencyThreshold = 50)
|
|
|
|
public Result<Void> sendSms(
|
|
|
|
public Result<Void> 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) {
|
|
|
|
@VerifyParam(required = true, regex = VerifyRegexEnum.MOBILE) @RequestParam("mobile") String mobile) {
|
|
|
|
userInfoService.sendSms(deviceId,mobile);
|
|
|
|
userInfoService.sendSms(deviceId,mobile);
|
|
|
|
return Result.success();
|
|
|
|
return Result.success();
|
|
|
@ -81,15 +85,15 @@ public class LoginController extends BaseController{
|
|
|
|
@ApiOperation(value = "2.登录/注册", notes = "成功后返回token")
|
|
|
|
@ApiOperation(value = "2.登录/注册", notes = "成功后返回token")
|
|
|
|
@ApiImplicitParams({ @ApiImplicitParam(name = "mobile", value = "手机号", required = true),
|
|
|
|
@ApiImplicitParams({ @ApiImplicitParam(name = "mobile", value = "手机号", required = true),
|
|
|
|
@ApiImplicitParam(name = "mobileCheckCode", value = "6位验证码", required = true),
|
|
|
|
@ApiImplicitParam(name = "mobileCheckCode", value = "6位验证码", required = true),
|
|
|
|
@ApiImplicitParam(name = "deviceId", value = "设备id,最长32位", required = true),
|
|
|
|
@ApiImplicitParam(name = "deviceId", value = "设备id", required = true),
|
|
|
|
@ApiImplicitParam(name = "deviceBrand", value = "设备品牌,最长30位", required = false) })
|
|
|
|
@ApiImplicitParam(name = "deviceBrand", value = "设备品牌", required = false) })
|
|
|
|
@PostMapping("/appLogin")
|
|
|
|
@PostMapping("/appLogin")
|
|
|
|
@GlobalInterceptor
|
|
|
|
@GlobalInterceptor
|
|
|
|
public Result appLogin(HttpServletRequest request,
|
|
|
|
public Result appLogin(HttpServletRequest request,
|
|
|
|
@VerifyParam(required = true, regex = VerifyRegexEnum.MOBILE) @RequestParam("mobile") String mobile,
|
|
|
|
@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, regex = VerifyRegexEnum.MOBILE_CHECK_CODE) @RequestParam("mobileCheckCode") String mobileCheckCode,
|
|
|
|
@VerifyParam(required = true, max = 32) @RequestParam("deviceId") String deviceId,
|
|
|
|
@VerifyParam(required = true) @RequestParam("deviceId") String deviceId,
|
|
|
|
@VerifyParam(max = 30) @RequestParam("deviceBrand") String deviceBrand) {
|
|
|
|
@RequestParam("deviceBrand") String deviceBrand) {
|
|
|
|
// 得到缓存中的验证码
|
|
|
|
// 得到缓存中的验证码
|
|
|
|
String redisMobileCheckCodeKey = Constants.REDIS_KEY_MOBILE_CHECK_CODE + deviceId;
|
|
|
|
String redisMobileCheckCodeKey = Constants.REDIS_KEY_MOBILE_CHECK_CODE + deviceId;
|
|
|
|
try {
|
|
|
|
try {
|
|
|
@ -118,13 +122,13 @@ public class LoginController extends BaseController{
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
@ApiOperation(value = "3.token续期", notes = "有效期7天")
|
|
|
|
@ApiOperation(value = "3.token续期", notes = "有效期7天")
|
|
|
|
@ApiImplicitParams({
|
|
|
|
@ApiImplicitParams({
|
|
|
|
@ApiImplicitParam(name = "deviceId", value = "设备id,最长32位", required = true),
|
|
|
|
@ApiImplicitParam(name = "deviceId", value = "设备id", required = true),
|
|
|
|
@ApiImplicitParam(name = "deviceBrand", value = "设备品牌,最长30位", required = false) })
|
|
|
|
@ApiImplicitParam(name = "deviceBrand", value = "设备品牌", required = false) })
|
|
|
|
@PostMapping("/autoLogin")
|
|
|
|
@PostMapping("/autoLogin")
|
|
|
|
@GlobalInterceptor
|
|
|
|
@GlobalInterceptor
|
|
|
|
public Result<String> autoLogin(HttpServletRequest request,@RequestHeader(value = "token", required = false) String token,
|
|
|
|
public Result<String> autoLogin(HttpServletRequest request,@RequestHeader(value = "token", required = false) String token,
|
|
|
|
@VerifyParam(required = true, max = 32) @RequestParam("deviceId") String deviceId,
|
|
|
|
@VerifyParam(required = true) @RequestParam("deviceId") String deviceId,
|
|
|
|
@VerifyParam(max = 30) @RequestParam("deviceBrand") String deviceBrand) {
|
|
|
|
@RequestParam("deviceBrand") String deviceBrand) {
|
|
|
|
return Result.success(userInfoService.autoLogin(token,deviceId,deviceBrand,getIpAddr(request)));
|
|
|
|
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分钟")
|
|
|
|
@ApiOperation(value = "4.获取图形验证码", notes = "4.三次短信验证失败后,获取图形验证码,有效期10分钟")
|
|
|
|
@ApiImplicitParams({
|
|
|
|
@ApiImplicitParams({
|
|
|
|
@ApiImplicitParam(name = "deviceId", value = "设备id,最长32位", required = true)})
|
|
|
|
@ApiImplicitParam(name = "deviceId", value = "设备id", required = true)})
|
|
|
|
@GetMapping("/imageCheckCode/{deviceId}")
|
|
|
|
@GetMapping("/imageCheckCode/{deviceId}")
|
|
|
|
@GlobalInterceptor
|
|
|
|
@GlobalInterceptor
|
|
|
|
public void imageCheckCode(HttpServletResponse response,
|
|
|
|
public void imageCheckCode(HttpServletResponse response,
|
|
|
|
@VerifyParam(required = true, max = 32) @PathVariable("deviceId") String deviceId)
|
|
|
|
@VerifyParam(required = true) @PathVariable("deviceId") String deviceId)
|
|
|
|
throws IOException {
|
|
|
|
throws IOException {
|
|
|
|
CreateImageCode vCode = new CreateImageCode(130, 38, 5, 10);
|
|
|
|
CreateImageCode vCode = new CreateImageCode(130, 38, 5, 10);
|
|
|
|
response.setHeader("Pragma", "no-cache");
|
|
|
|
response.setHeader("Pragma", "no-cache");
|
|
|
@ -157,8 +161,8 @@ public class LoginController extends BaseController{
|
|
|
|
HttpServletRequest request,
|
|
|
|
HttpServletRequest request,
|
|
|
|
@VerifyParam(required = true, regex = VerifyRegexEnum.MOBILE) @RequestParam("mobile") String mobile,
|
|
|
|
@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, regex = VerifyRegexEnum.MOBILE_CHECK_CODE) @RequestParam("mobileCheckCode") String mobileCheckCode,
|
|
|
|
@VerifyParam(required = true, max = 32) @RequestParam("deviceId") String deviceId,
|
|
|
|
@VerifyParam(required = true) @RequestParam("deviceId") String deviceId,
|
|
|
|
@VerifyParam(max = 30) @RequestParam("deviceBrand") String deviceBrand,
|
|
|
|
@RequestParam("deviceBrand") String deviceBrand,
|
|
|
|
@VerifyParam(required = true) @RequestParam("imageCheckCode") String imageCheckCode) {
|
|
|
|
@VerifyParam(required = true) @RequestParam("imageCheckCode") String imageCheckCode) {
|
|
|
|
// 得到缓存中的验证码
|
|
|
|
// 得到缓存中的验证码
|
|
|
|
String redisImageCheckCodeKey = Constants.REDIS_KEY_IMAGE_CHECK_CODE + deviceId;
|
|
|
|
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);
|
|
|
|
return appLogin(request, mobile, mobileCheckCode, deviceId, deviceBrand);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* 获取支持的手机号国家码
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
@ApiOperation(value = "6.获取支持的手机号国家码", notes = "v1仅支持'+86'")
|
|
|
|
|
|
|
|
@GetMapping("/supportedCountryCode")
|
|
|
|
|
|
|
|
@GlobalInterceptor
|
|
|
|
|
|
|
|
public Result<List<String>> getSupportedCountryCode(){
|
|
|
|
|
|
|
|
return Result.success(DEFAULT_SUPPORTED_COUNTRY_CODES);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* 删除
|
|
|
|
* 删除
|
|
|
|
*
|
|
|
|
*
|
|
|
|