feat: 基础修改
This commit is contained in:
@@ -1,22 +1,47 @@
|
||||
package com.webgame.webgamebackend.controller;
|
||||
|
||||
import cn.dev33.satoken.annotation.SaIgnore;
|
||||
import com.webgame.webgamebackend.common.dto.ApiResponse;
|
||||
import com.webgame.webgamebackend.common.dto.account.LoginRequest;
|
||||
import com.webgame.webgamebackend.common.dto.account.LoginResponse;
|
||||
import com.webgame.webgamebackend.common.dto.account.RegisterRequest;
|
||||
import com.webgame.webgamebackend.service.AccountService;
|
||||
import jakarta.validation.Valid;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
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.RestController;
|
||||
|
||||
/**
|
||||
* 账号控制器
|
||||
*/
|
||||
@Validated
|
||||
@RestController
|
||||
@RequestMapping("/account")
|
||||
@RequiredArgsConstructor
|
||||
public class AccountController {
|
||||
|
||||
private final AccountService accountService;
|
||||
|
||||
/**
|
||||
* 登录
|
||||
*/
|
||||
@SaIgnore
|
||||
@PostMapping("/login")
|
||||
public String login() {
|
||||
return "login";
|
||||
public ApiResponse<LoginResponse> login(@Valid @RequestBody LoginRequest request) {
|
||||
LoginResponse result = accountService.login(request);
|
||||
return ApiResponse.ok(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* 注册
|
||||
*/
|
||||
@SaIgnore
|
||||
@PostMapping("/register")
|
||||
public ApiResponse<LoginResponse> register(@Valid @RequestBody RegisterRequest request) {
|
||||
LoginResponse result = accountService.register(request);
|
||||
return ApiResponse.ok(result);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user