-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[FEAT] 프로젝트 매칭 요청 생성 API 작성, API 관련 Swagger 작성, 불필요한 에러코드 제거, 에러코드 관련…
… 오류메시지 샘플 작성
- Loading branch information
Showing
4 changed files
with
100 additions
and
3 deletions.
There are no files selected for viewing
56 changes: 56 additions & 0 deletions
56
src/main/java/io/oeid/mogakgo/common/swagger/template/ProjectJoinRequestSwagger.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
package io.oeid.mogakgo.common.swagger.template; | ||
|
||
import io.oeid.mogakgo.core.properties.swagger.error.SwaggerProjectErrorExamples; | ||
import io.oeid.mogakgo.core.properties.swagger.error.SwaggerProjectJoinRequestErrorExamples; | ||
import io.oeid.mogakgo.core.properties.swagger.error.SwaggerUserErrorExamples; | ||
import io.oeid.mogakgo.domain.project_join_req.application.dto.req.ProjectJoinCreateReq; | ||
import io.oeid.mogakgo.domain.project_join_req.presentation.dto.res.ProjectJoinRequestAPIRes; | ||
import io.oeid.mogakgo.exception.dto.ErrorResponse; | ||
import io.swagger.v3.oas.annotations.Operation; | ||
import io.swagger.v3.oas.annotations.Parameter; | ||
import io.swagger.v3.oas.annotations.media.Content; | ||
import io.swagger.v3.oas.annotations.media.ExampleObject; | ||
import io.swagger.v3.oas.annotations.media.Schema; | ||
import io.swagger.v3.oas.annotations.responses.ApiResponse; | ||
import io.swagger.v3.oas.annotations.responses.ApiResponses; | ||
import io.swagger.v3.oas.annotations.tags.Tag; | ||
import org.springframework.http.ResponseEntity; | ||
|
||
@Tag(name = "Project Join Request", description = "프로젝트 매칭 요청 관련 API") | ||
public interface ProjectJoinRequestSwagger { | ||
|
||
@Operation(summary = "프로젝트 매칭 요청 생성", description = "회원이 프로젝트 매칭 요청을 생성할 때 사용하는 API") | ||
@ApiResponses(value = { | ||
@ApiResponse(responseCode = "201", description = "프로젝트 매칭 요청 생성 성공", | ||
content = @Content(schema = @Schema(implementation = ProjectJoinRequestAPIRes.class))), | ||
@ApiResponse(responseCode = "400", description = "요청한 데이터가 유효하지 않음", | ||
content = @Content( | ||
mediaType = "application/json", | ||
schema = @Schema(implementation = ErrorResponse.class), | ||
examples = { | ||
@ExampleObject(name = "E090101", | ||
value = SwaggerProjectJoinRequestErrorExamples.PROJECT_JOIN_REQUEST_ALREADY_EXIST), | ||
@ExampleObject(name = "E090103", | ||
value = SwaggerProjectJoinRequestErrorExamples.PROJECT_JOIN_REQUEST_INVALID_REGION) | ||
})), | ||
@ApiResponse(responseCode = "403", description = "프로젝트 매칭 요청 권한이 없음", | ||
content = @Content( | ||
mediaType = "application/json", | ||
schema = @Schema(implementation = ErrorResponse.class), | ||
examples = @ExampleObject(name = "E090201", | ||
value = SwaggerProjectJoinRequestErrorExamples.PROJECT_JOIN_REQUEST_FORBIDDEN_OPERATION))), | ||
@ApiResponse(responseCode = "404", description = "요청한 데이터가 존재하지 않음", | ||
content = @Content( | ||
mediaType = "application/json", | ||
schema = @Schema(implementation = ErrorResponse.class), | ||
examples = { | ||
@ExampleObject(name = "E020301", value = SwaggerUserErrorExamples.USER_NOT_FOUND), | ||
@ExampleObject(name = "E030301", value = SwaggerProjectErrorExamples.PROJECT_NOT_FOUND) | ||
})), | ||
}) | ||
ResponseEntity<ProjectJoinRequestAPIRes> create( | ||
@Parameter(hidden = true) Long userId, | ||
ProjectJoinCreateReq request | ||
); | ||
|
||
} |
12 changes: 12 additions & 0 deletions
12
...io/oeid/mogakgo/core/properties/swagger/error/SwaggerProjectJoinRequestErrorExamples.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package io.oeid.mogakgo.core.properties.swagger.error; | ||
|
||
public class SwaggerProjectJoinRequestErrorExamples { | ||
|
||
public static final String PROJECT_JOIN_REQUEST_ALREADY_EXIST = "{\"timestamp\":\"2024-02-17T10:07:31.404Z\",\"statusCode\":403,\"code\":\"E090201\",\"message\":\"프로젝트 생성자는 해당 프로젝트에 매칭 요청을 보낼 수 없습니다.\"}"; | ||
public static final String PROJECT_JOIN_REQUEST_FORBIDDEN_OPERATION = "{\"timestamp\":\"2024-02-17T10:07:31.404Z\",\"statusCode\":403,\"code\":\"E090101\",\"message\":\"이미 매칭 요청을 보낸 프로젝트에 매칭 요청을 보낼 수 없습니다..\"}"; | ||
public static final String PROJECT_JOIN_REQUEST_INVALID_REGION = "{\"timestamp\":\"2024-02-17T10:07:31.404Z\",\"statusCode\":403,\"code\":\"E090102\",\"message\":\"프로젝트 매칭 서비스는 동네 인증되지 않은 구역에서 진행할 수 없습니다..\"}"; | ||
private SwaggerProjectJoinRequestErrorExamples() { | ||
|
||
} | ||
|
||
} |
30 changes: 30 additions & 0 deletions
30
...va/io/oeid/mogakgo/domain/project_join_req/presentation/ProjectJoinRequestController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package io.oeid.mogakgo.domain.project_join_req.presentation; | ||
|
||
import io.oeid.mogakgo.common.annotation.UserId; | ||
import io.oeid.mogakgo.common.swagger.template.ProjectJoinRequestSwagger; | ||
import io.oeid.mogakgo.domain.project_join_req.application.ProjectJoinRequestService; | ||
import io.oeid.mogakgo.domain.project_join_req.application.dto.req.ProjectJoinCreateReq; | ||
import io.oeid.mogakgo.domain.project_join_req.presentation.dto.res.ProjectJoinRequestAPIRes; | ||
import jakarta.validation.Valid; | ||
import lombok.RequiredArgsConstructor; | ||
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; | ||
|
||
@RestController | ||
@RequestMapping("/api/v1/project-join-request") | ||
@RequiredArgsConstructor | ||
public class ProjectJoinRequestController implements ProjectJoinRequestSwagger { | ||
|
||
private final ProjectJoinRequestService projectJoinRequestService; | ||
|
||
@PostMapping | ||
public ResponseEntity<ProjectJoinRequestAPIRes> create( | ||
@UserId Long userId, @Valid @RequestBody ProjectJoinCreateReq request | ||
) { | ||
return ResponseEntity.status(201) | ||
.body(ProjectJoinRequestAPIRes.from(projectJoinRequestService.create(userId, request))); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters