完整管理员登陆接口的开发
This commit is contained in:
@@ -0,0 +1,35 @@
|
||||
package cn.iocoder.mall.managementweb.controller.passport;
|
||||
|
||||
import cn.iocoder.common.framework.util.HttpUtil;
|
||||
import cn.iocoder.common.framework.vo.CommonResult;
|
||||
import cn.iocoder.mall.managementweb.controller.passport.dto.AdminPassportLoginDTO;
|
||||
import cn.iocoder.mall.managementweb.controller.passport.vo.AdminPassportVO;
|
||||
import cn.iocoder.mall.managementweb.manager.admin.AdminPassportManager;
|
||||
import io.swagger.annotations.Api;
|
||||
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;
|
||||
|
||||
import static cn.iocoder.common.framework.vo.CommonResult.success;
|
||||
|
||||
@Api(tags = "管理员 Passport API")
|
||||
@RestController
|
||||
@RequestMapping("/passport")
|
||||
public class AdminPassportController {
|
||||
|
||||
@Autowired
|
||||
private AdminPassportManager adminPassportManager;
|
||||
|
||||
@PostMapping("/login")
|
||||
@ApiOperation("账号密码登陆")
|
||||
// @RequiresNone TODO 晚点加上
|
||||
public CommonResult<AdminPassportVO> login(AdminPassportLoginDTO loginDTO,
|
||||
HttpServletRequest request) {
|
||||
return success(adminPassportManager.login(loginDTO, HttpUtil.getIp(request)));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
package cn.iocoder.mall.managementweb.controller.passport.dto;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
import org.hibernate.validator.constraints.Length;
|
||||
|
||||
import javax.validation.constraints.NotEmpty;
|
||||
import javax.validation.constraints.Pattern;
|
||||
import java.io.Serializable;
|
||||
|
||||
@ApiModel("管理登录 DTO")
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
public class AdminPassportLoginDTO implements Serializable {
|
||||
|
||||
@ApiModelProperty(value = "用户名", required = true, example = "yudaoyuanma")
|
||||
@NotEmpty(message = "登陆账号不能为空")
|
||||
@Length(min = 5, max = 16, message = "账号长度为 5-16 位")
|
||||
@Pattern(regexp = "^[A-Za-z0-9]+$", message = "账号格式为数字以及字母")
|
||||
private String username;
|
||||
|
||||
@ApiModelProperty(value = "密码", required = true, example = "buzhidao")
|
||||
@NotEmpty(message = "密码不能为空")
|
||||
@Length(min = 4, max = 16, message = "密码长度为 4-16 位")
|
||||
private String password;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
package cn.iocoder.mall.managementweb.controller.passport.vo;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
@ApiModel("管理员通信证信息 VO")
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
public class AdminPassportVO {
|
||||
|
||||
@ApiModel("认证信息")
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
public static class Authentication {
|
||||
|
||||
@ApiModelProperty(value = "访问令牌", required = true, example = "001e8f49b20e47f7b3a2de774497cd50")
|
||||
private String accessToken;
|
||||
@ApiModelProperty(value = "刷新令牌", required = true, example = "001e8f49b20e47f7b3a2de774497cd50")
|
||||
private String refreshToken;
|
||||
@ApiModelProperty(value = "过期时间", required = true)
|
||||
private Date expiresTime;
|
||||
|
||||
}
|
||||
|
||||
@ApiModel("管理员信息")
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
public static class Admin {
|
||||
|
||||
@ApiModelProperty(value = "用户编号", required = true, example = "1")
|
||||
private Integer id;
|
||||
@ApiModelProperty(value = "真实姓名", required = true, example = "小王")
|
||||
private String name;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 管理员信息
|
||||
*/
|
||||
private Admin admin;
|
||||
/**
|
||||
* 认证信息
|
||||
*/
|
||||
private Authentication authorization;
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user