[api] 테스트 커밋
This commit is contained in:
+1
-1
@@ -46,7 +46,7 @@ dependencies {
|
||||
implementation 'org.mariadb.jdbc:mariadb-java-client'
|
||||
|
||||
// swagger
|
||||
implementation 'org.springdoc:springdoc-openapi-starter-webmvc-ui:2.6.0'
|
||||
implementation 'org.springdoc:springdoc-openapi-starter-webmvc-ui:2.8.0'
|
||||
|
||||
// MyBatis (Boot 3 전용)
|
||||
implementation 'org.mybatis.spring.boot:mybatis-spring-boot-starter:3.0.3'
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
package com.alist.api.modules.auth;
|
||||
|
||||
import org.springframework.http.ResponseEntity;
|
||||
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;
|
||||
|
||||
import com.alist.api.common.response.ApiResponse;
|
||||
import com.alist.api.common.response.ApiResponseCode;
|
||||
import com.alist.api.config.jwt.JwtTokenProvider;
|
||||
import com.alist.api.modules.auth.form.TokenForm;
|
||||
|
||||
import jakarta.validation.Valid;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/auth")
|
||||
public class AuthController {
|
||||
private final JwtTokenProvider jwtTokenProvider;
|
||||
|
||||
public AuthController(JwtTokenProvider jwtTokenProvider) {
|
||||
this.jwtTokenProvider = jwtTokenProvider;
|
||||
}
|
||||
|
||||
@PostMapping("/token")
|
||||
public ResponseEntity<ApiResponse<String>> token(@Valid @RequestBody TokenForm tokenForm) {
|
||||
String accessToken = jwtTokenProvider.createToken(tokenForm.getUserId());
|
||||
|
||||
return ApiResponse.entity(accessToken, ApiResponseCode.CODE_2001, "엑세스 토큰");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package com.alist.api.modules.auth.form;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@Schema(description = "토큰 요청 폼")
|
||||
public class TokenForm {
|
||||
|
||||
@NotBlank(message = "사용자명은 필수입니다.")
|
||||
@Schema(description = "사용자명", example = "user123")
|
||||
private String userId;
|
||||
}
|
||||
@@ -2,8 +2,10 @@ package com.alist.api;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.test.context.ActiveProfiles;
|
||||
|
||||
@SpringBootTest
|
||||
@ActiveProfiles("local")
|
||||
class ApiApplicationTests {
|
||||
|
||||
@Test
|
||||
|
||||
Reference in New Issue
Block a user