1.move posted required attribute to request dto

main
Gary 9 months ago
parent f9086e7deb
commit e84548fd1b

@ -18,7 +18,9 @@ import org.springframework.web.bind.annotation.*;
import constants.Constants; import constants.Constants;
import controller.BaseController; import controller.BaseController;
import com.luoo.user.dto.request.LoginReq;
import com.luoo.user.dto.request.SendSmsReq; import com.luoo.user.dto.request.SendSmsReq;
import com.luoo.user.dto.request.TokenRefreshReq;
import com.luoo.user.dto.response.CountryCodeDTO; import com.luoo.user.dto.response.CountryCodeDTO;
import com.luoo.user.dto.response.CreateImageCode; import com.luoo.user.dto.response.CreateImageCode;
import com.luoo.user.pojo.UserInfo; import com.luoo.user.pojo.UserInfo;
@ -95,31 +97,24 @@ public class LoginController extends BaseController {
} }
@ApiOperation(value = "2.登录/注册", notes = "成功后返回authorization") @ApiOperation(value = "2.登录/注册", notes = "成功后返回authorization")
@ApiImplicitParams({ @ApiImplicitParam(name = "mobile", value = "手机号", required = true),
@ApiImplicitParam(name = "mobileCheckCode", value = "6位验证码", required = true),
@ApiImplicitParam(name = "deviceId", value = "设备id", required = true),
@ApiImplicitParam(name = "deviceBrand", value = "设备品牌", required = false) })
@PostMapping("/appLogin") @PostMapping("/appLogin")
@GlobalInterceptor(frequencyType = RequestFrequencyTypeEnum.HOUR, requestFrequencyThreshold = 12) @GlobalInterceptor(frequencyType = RequestFrequencyTypeEnum.HOUR, requestFrequencyThreshold = 12)
public Result<String> appLogin(HttpServletRequest request, public Result<String> appLogin(HttpServletRequest request,
@VerifyParam(required = true, regex = VerifyRegexEnum.MOBILE) @RequestParam("mobile") String mobile, @VerifyParam LoginReq loginReq) {
@VerifyParam(required = true, regex = VerifyRegexEnum.MOBILE_CHECK_CODE) @RequestParam("mobileCheckCode") String mobileCheckCode,
@VerifyParam(required = true) @RequestParam("deviceId") String deviceId,
@RequestParam("deviceBrand") String deviceBrand) {
// 得到缓存中的验证码 // 得到缓存中的验证码
String redisMobileCheckCodeKey = Constants.REDIS_KEY_MOBILE_CHECK_CODE + deviceId; String redisMobileCheckCodeKey = Constants.REDIS_KEY_MOBILE_CHECK_CODE + loginReq.getDeviceId();
try { try {
String redisMobileCheckCode = (String) redisTemplate.opsForValue().get(redisMobileCheckCodeKey); String redisMobileCheckCode = (String) redisTemplate.opsForValue().get(redisMobileCheckCodeKey);
if (StringTools.isEmpty(redisMobileCheckCode)) { if (StringTools.isEmpty(redisMobileCheckCode)) {
return Result.failed(StatusCode.USER_MOBILE_VERIFICATION_CODE_EXPIRED); return Result.failed(StatusCode.USER_MOBILE_VERIFICATION_CODE_EXPIRED);
} }
if (!redisMobileCheckCode.equals(mobileCheckCode)) { if (!redisMobileCheckCode.equals(loginReq.getMobileCheckCode())) {
return Result.failed(StatusCode.USER_MOBILE_VERIFICATION_CODE_MISMATCH); return Result.failed(StatusCode.USER_MOBILE_VERIFICATION_CODE_MISMATCH);
} }
UserInfo loginUserInfo = new UserInfo(); UserInfo loginUserInfo = new UserInfo();
loginUserInfo.setMobile(mobile); loginUserInfo.setMobile(loginReq.getMobile());
loginUserInfo.setLastUseDeviceId(deviceId); loginUserInfo.setLastUseDeviceId(loginReq.getDeviceId());
loginUserInfo.setLastUseDeviceBrand(deviceBrand); loginUserInfo.setLastUseDeviceBrand(loginReq.getDeviceBrand());
loginUserInfo.setLastLoginIp(getIpAddr(request)); loginUserInfo.setLastLoginIp(getIpAddr(request));
return Result.success(userInfoService.loginOrRegister(loginUserInfo)); return Result.success(userInfoService.loginOrRegister(loginUserInfo));
} finally { } finally {
@ -131,15 +126,12 @@ public class LoginController extends BaseController {
* authorization * authorization
*/ */
@ApiOperation(value = "3.token续期", notes = "有效期7天") @ApiOperation(value = "3.token续期", notes = "有效期7天")
@ApiImplicitParams({ @ApiImplicitParam(name = "deviceId", value = "设备id", required = true),
@ApiImplicitParam(name = "deviceBrand", value = "设备品牌", required = false) })
@PostMapping("/autoLogin") @PostMapping("/autoLogin")
@GlobalInterceptor @GlobalInterceptor
public Result<String> autoLogin(HttpServletRequest request, public Result<String> autoLogin(HttpServletRequest request,
@RequestHeader(value = "Authorization", required = false) String authorization, @RequestHeader(value = "Authorization", required = false) String authorization,
@VerifyParam(required = true) @RequestParam("deviceId") String deviceId, @VerifyParam TokenRefreshReq tokenRefreshReq) {
@RequestParam("deviceBrand") String deviceBrand) { return Result.success(userInfoService.autoLogin(authorization, tokenRefreshReq.getDeviceId(), tokenRefreshReq.getDeviceBrand(), getIpAddr(request)));
return Result.success(userInfoService.autoLogin(authorization, deviceId, deviceBrand, getIpAddr(request)));
} }
/** /**

@ -0,0 +1,33 @@
package com.luoo.user.dto.request;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Getter;
import lombok.Setter;
import java.io.Serializable;
import java.util.List;
import org.springframework.web.multipart.MultipartFile;
import annotation.VerifyParam;
/**
*
*/
@Getter
@Setter
@ApiModel
public class FeedbackReq implements Serializable {
private static final long serialVersionUID = 1L;
@ApiModelProperty(value = "反馈类型3个值0bug, 1建议2其它", required = true)
@VerifyParam(required = true)
private Integer type;
@ApiModelProperty(value = "反馈内容最多300字", required = true)
@VerifyParam(required = true, max = 300)
private String content;
@ApiModelProperty(value = "图片单张图片最大5M一次上传最多10张图片", required = false)
private List<MultipartFile> files;
@ApiModelProperty(value = "联系方式可选最多50字", required = false)
@VerifyParam(max = 50)
private String contact;
}

@ -0,0 +1,34 @@
package com.luoo.user.dto.request;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Getter;
import lombok.Setter;
import java.io.Serializable;
import annotation.VerifyParam;
import enums.VerifyRegexEnum;
/**
*
*/
@Getter
@Setter
@ApiModel
public class LoginReq implements Serializable {
private static final long serialVersionUID = 1L;
@ApiModelProperty(name = "mobile", value = "手机号", required = true)
@VerifyParam(required = true, regex = VerifyRegexEnum.MOBILE)
private String mobile;
@ApiModelProperty(name = "mobileCheckCode", value = "6位验证码", required = true)
@VerifyParam(required = true, regex = VerifyRegexEnum.MOBILE_CHECK_CODE)
String mobileCheckCode;
@ApiModelProperty(name = "deviceId", value = "设备id", required = true)
@VerifyParam(required = true)
private String deviceId;
@ApiModelProperty(name = "deviceBrand", value = "设备品牌", required = false)
String deviceBrand;
}

@ -0,0 +1,25 @@
package com.luoo.user.dto.request;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Getter;
import lombok.Setter;
import java.io.Serializable;
import annotation.VerifyParam;
/**
*
*/
@Getter
@Setter
@ApiModel
public class TokenRefreshReq implements Serializable {
private static final long serialVersionUID = 1L;
@ApiModelProperty(name = "deviceId", value = "设备id", required = true)
@VerifyParam(required = true)
String deviceId;
@ApiModelProperty(name = "deviceBrand", value = "设备品牌", required = false)
String deviceBrand;
}
Loading…
Cancel
Save