重写用户快速登录逻辑
This commit is contained in:
@@ -0,0 +1,42 @@
|
||||
package cn.iocoder.mall.userweb.controller.passport;
|
||||
|
||||
import cn.iocoder.common.framework.util.HttpUtil;
|
||||
import cn.iocoder.common.framework.vo.CommonResult;
|
||||
import cn.iocoder.mall.userweb.controller.passport.dto.UserPassportLoginBySmsDTO;
|
||||
import cn.iocoder.mall.userweb.controller.passport.dto.UserPassportSendSmsCodeDTO;
|
||||
import cn.iocoder.mall.userweb.controller.passport.vo.UserPassportVO;
|
||||
import cn.iocoder.mall.userweb.manager.passport.UserPassportManager;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/passport")
|
||||
public class UserPassportController {
|
||||
|
||||
@Autowired
|
||||
private UserPassportManager userPassportManager;
|
||||
|
||||
@PostMapping("/login_by_sms")
|
||||
@ApiOperation("手机验证码登陆")
|
||||
// @RequiresNone TODO 晚点加上
|
||||
public CommonResult<UserPassportVO> loginBySms(UserPassportLoginBySmsDTO loginBySmsDTO,
|
||||
HttpServletRequest request) {
|
||||
return CommonResult.success(userPassportManager.loginBySms(loginBySmsDTO, HttpUtil.getIp(request)));
|
||||
}
|
||||
|
||||
@PostMapping("/send_sms_code")
|
||||
@ApiOperation("发送手机验证码")
|
||||
// @RequiresNone TODO 晚点加上
|
||||
public CommonResult<Boolean> sendSmsCode(UserPassportSendSmsCodeDTO sendSmsCodeDTO,
|
||||
HttpServletRequest request) {
|
||||
userPassportManager.sendSmsCode(sendSmsCodeDTO, HttpUtil.getIp(request));
|
||||
// 返回成功
|
||||
return CommonResult.success(true);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
package cn.iocoder.mall.userweb.controller.passport.dto;
|
||||
|
||||
import cn.iocoder.common.framework.validator.Mobile;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.io.Serializable;
|
||||
|
||||
@ApiModel("用户短信验证码登陆 DTO")
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
public class UserPassportLoginBySmsDTO implements Serializable {
|
||||
|
||||
@ApiModelProperty(value = "手机号", example = "15601691234")
|
||||
@Mobile
|
||||
private String mobile;
|
||||
@ApiModelProperty(value = "验证码", example = "1234")
|
||||
@NotNull(message = "验证码不能为空")
|
||||
private String code;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
package cn.iocoder.mall.userweb.controller.passport.dto;
|
||||
|
||||
import cn.iocoder.common.framework.validator.Mobile;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
@ApiModel("发送手机验证码 DTO")
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
public class UserPassportSendSmsCodeDTO {
|
||||
|
||||
@ApiModelProperty(value = "手机号", example = "15601691234")
|
||||
@Mobile
|
||||
private String mobile;
|
||||
@ApiModelProperty(value = "发送场景", example = "1", notes = "对应 UserSmsSceneEnum 枚举")
|
||||
@NotNull(message = "发送场景不能为空")
|
||||
private Integer scene;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,72 @@
|
||||
package cn.iocoder.mall.userweb.controller.passport.vo;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 用户通信证信息
|
||||
*/
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
public class UserPassportVO {
|
||||
|
||||
/**
|
||||
* 认证信息
|
||||
*/
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
public static class Authentication {
|
||||
|
||||
/**
|
||||
* 访问令牌
|
||||
*/
|
||||
private String accessToken;
|
||||
/**
|
||||
* 刷新令牌
|
||||
*/
|
||||
private String refreshToken;
|
||||
/**
|
||||
* 账号编号
|
||||
*/
|
||||
private Integer accountId;
|
||||
/**
|
||||
* 过期时间
|
||||
*/
|
||||
private Date expiresTime;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 用户信息
|
||||
*/
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
public static class User {
|
||||
|
||||
/**
|
||||
* 用户编号
|
||||
*/
|
||||
private Integer id;
|
||||
/**
|
||||
* 昵称
|
||||
*/
|
||||
private String nickname;
|
||||
/**
|
||||
* 头像
|
||||
*/
|
||||
private String avatar;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 用户信息
|
||||
*/
|
||||
private User user;
|
||||
/**
|
||||
* 认证信息
|
||||
*/
|
||||
private Authentication authorization;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
package cn.iocoder.mall.userweb.controller.user;
|
||||
|
||||
public class UserController {
|
||||
}
|
||||
Reference in New Issue
Block a user