用户登录接口

This commit is contained in:
nicole 2023-12-22 21:42:39 +08:00
parent 391544d485
commit 484e7fa450
2 changed files with 32 additions and 6 deletions

View File

@ -4,6 +4,7 @@ import com.zjyr.beidouservice.common.impl.ErrorCode;
import com.zjyr.beidouservice.config.CommonConfigure;
import com.zjyr.beidouservice.pojo.MyResp;
import com.zjyr.beidouservice.pojo.dto.LoginRspDTO;
import com.zjyr.beidouservice.pojo.dto.auth.UserLoginReqDTO;
import com.zjyr.beidouservice.pojo.po.MulReturnType;
import com.zjyr.beidouservice.service.UserAccountService;
import com.zjyr.beidouservice.validation.TokenAuthInterface;
@ -13,6 +14,7 @@ import org.springframework.stereotype.Component;
import org.springframework.stereotype.Controller;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
@ -46,18 +48,15 @@ public class AuthController {
*/
@PostMapping("/login")
@ResponseBody
public MyResp<LoginRspDTO> userLogin(
//@Validated(ValidGroups.LoginReqValid.class)
//@RequestBody ProtocolReqDTO<LoginReq> mr
)
public MyResp userLogin(@RequestBody UserLoginReqDTO userLoginReqDTO)
throws NoSuchAlgorithmException {
LoginRspDTO rspInfo = LoginRspDTO.builder()
.userName("username")
.build();
// 登录
MulReturnType<ErrorCode, String> ret = userAccountService.loginService("admin", "2DC5B63023999B5BC57EB6B74B2232E3");
MulReturnType<ErrorCode, String> ret = userAccountService.loginService(userLoginReqDTO.getUsername(), userLoginReqDTO.getPasswd());
//MulReturnType<ErrorCode, String> ret = userAccountService.loginService("admin", "2DC5B63023999B5BC57EB6B74B2232E3");
// 登录错误
if (ret.getFirstParam() != ErrorCode.ERR_OK) {

View File

@ -0,0 +1,27 @@
package com.zjyr.beidouservice.pojo.dto.auth;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
@Schema(title = "用户登录请求体")
public class UserLoginReqDTO {
/**
* The Username.
*/
@Schema(title = "用户名", example = "test")
private String username;
/**
* The Password.
*/
@Schema(title = "密码", example = "test")
private String passwd;
}