-
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.
Browse files
Browse the repository at this point in the history
…handler [FEAT] API 응답 통일 & 에러 핸들러 설정
- Loading branch information
Showing
40 changed files
with
294 additions
and
74 deletions.
There are no files selected for viewing
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
2 changes: 1 addition & 1 deletion
2
src/main/java/com/umc/networkingService/domain/album/entity/Album.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
2 changes: 1 addition & 1 deletion
2
src/main/java/com/umc/networkingService/domain/album/entity/AlbumComment.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
2 changes: 1 addition & 1 deletion
2
src/main/java/com/umc/networkingService/domain/album/entity/AlbumHeart.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
2 changes: 1 addition & 1 deletion
2
src/main/java/com/umc/networkingService/domain/album/entity/AlbumImage.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
2 changes: 1 addition & 1 deletion
2
src/main/java/com/umc/networkingService/domain/board/entity/Board.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
2 changes: 1 addition & 1 deletion
2
src/main/java/com/umc/networkingService/domain/board/entity/BoardCheck.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
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
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
2 changes: 1 addition & 1 deletion
2
src/main/java/com/umc/networkingService/domain/board/entity/BoardImage.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
2 changes: 1 addition & 1 deletion
2
src/main/java/com/umc/networkingService/domain/branch/entity/Branch.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
2 changes: 1 addition & 1 deletion
2
src/main/java/com/umc/networkingService/domain/branch/entity/BranchUniversity.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
3 changes: 2 additions & 1 deletion
3
src/main/java/com/umc/networkingService/domain/friend/entity/Friend.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
2 changes: 1 addition & 1 deletion
2
src/main/java/com/umc/networkingService/domain/inviteCode/entity/InviteCode.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
2 changes: 1 addition & 1 deletion
2
src/main/java/com/umc/networkingService/domain/mascot/entity/Mascot.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
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
2 changes: 1 addition & 1 deletion
2
src/main/java/com/umc/networkingService/domain/member/entity/MemberPoint.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
2 changes: 1 addition & 1 deletion
2
src/main/java/com/umc/networkingService/domain/message/entity/Message.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
2 changes: 1 addition & 1 deletion
2
src/main/java/com/umc/networkingService/domain/message/entity/MessageRoom.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
2 changes: 1 addition & 1 deletion
2
src/main/java/com/umc/networkingService/domain/project/entity/Project.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
2 changes: 1 addition & 1 deletion
2
src/main/java/com/umc/networkingService/domain/project/entity/ProjectHeart.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
2 changes: 1 addition & 1 deletion
2
src/main/java/com/umc/networkingService/domain/project/entity/ProjectMember.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
2 changes: 1 addition & 1 deletion
2
src/main/java/com/umc/networkingService/domain/proposal/entity/Proposal.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
2 changes: 1 addition & 1 deletion
2
src/main/java/com/umc/networkingService/domain/proposal/entity/proposalImage.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
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
2 changes: 1 addition & 1 deletion
2
src/main/java/com/umc/networkingService/domain/session/entity/Session.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
59 changes: 42 additions & 17 deletions
59
src/main/java/com/umc/networkingService/domain/test/controller/TestController.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 |
---|---|---|
@@ -1,35 +1,60 @@ | ||
package com.umc.networkingService.domain.test.controller; | ||
|
||
import com.umc.networkingService.domain.test.dto.TestRequest; | ||
import com.umc.networkingService.domain.test.dto.TestResponse; | ||
import com.umc.networkingService.domain.test.service.TestService; | ||
import com.umc.networkingService.global.common.base.BaseResponse; | ||
import io.swagger.v3.oas.annotations.Hidden; | ||
import io.swagger.v3.oas.annotations.Operation; | ||
import io.swagger.v3.oas.annotations.Parameter; | ||
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 jakarta.validation.Valid; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.web.bind.annotation.GetMapping; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
import org.springframework.web.bind.annotation.RequestParam; | ||
import org.springframework.web.bind.annotation.RestController; | ||
import org.springframework.web.bind.annotation.*; | ||
|
||
@Tag(name = "예제 API", description = "Swagger 테스트용 API") | ||
@Tag(name = "예제 API", description = "테스트용 API") | ||
@RestController | ||
@RequiredArgsConstructor | ||
@RequestMapping("/test") | ||
public class TestController { | ||
@Operation(summary = "문자열 반복", description = "파라미터로 받은 문자열을 2번 반복합니다.") | ||
@Parameter(name = "str", description = "2번 반복할 문자열") | ||
@GetMapping("/returnStr") | ||
public String returnStr(@RequestParam String str) { | ||
return str + "\n" + str; | ||
private final TestService testService; | ||
|
||
|
||
@Operation(summary = "성공적인 응답 반환 API", description = "테스트 문자열을 반환하는 API입니다.") | ||
@ApiResponse(responseCode = "200", description = "테스트 문자열을 성공적으로 반환") | ||
@GetMapping("/success") | ||
public BaseResponse<TestResponse.TempTestDTO> successResponseAPI() { | ||
return BaseResponse.onSuccess(TestResponse.TempTestDTO.builder().testString("This is Test!").build()); | ||
} | ||
|
||
@GetMapping("/example") | ||
public String example() { | ||
return "예시 API"; | ||
|
||
|
||
@Operation(summary = "예외처리 API", description = "flag 값에 따라 예외를 발생시키는 API입니다.") | ||
@Parameter(name = "flag", description = "1인 경우 예외처리", example = "1", required = true) | ||
@ApiResponses(value = { | ||
@ApiResponse(responseCode = "COMMON200", description = "성공"), | ||
@ApiResponse(responseCode = "TEMP4001", description = "예외 처리 테스트입니다.") | ||
}) | ||
@GetMapping("/exception") | ||
public BaseResponse<TestResponse.TempExceptionDTO> exceptionAPI(@RequestParam Integer flag) { | ||
testService.CheckFlag(flag); | ||
return BaseResponse.onSuccess(TestResponse.TempExceptionDTO.builder() | ||
.flag(flag) | ||
.build()); | ||
} | ||
|
||
@Hidden | ||
@GetMapping("/ignore") | ||
public String ignore() { | ||
return "무시되는 API"; | ||
@Operation(summary = "유효성 검사 API", description = "요청 객체의 유효성을 검사하는 API입니다.") | ||
@ApiResponses(value = { | ||
@ApiResponse(responseCode = "COMMON200", description = "성공"), | ||
@ApiResponse(responseCode = "COMMON400", description = "testString가 공백일 경우") | ||
}) | ||
@PostMapping("/validation") | ||
public BaseResponse<TestResponse.TempTestDTO> testValidationAPI( | ||
@RequestBody @Valid TestRequest.TempTestRequest request) { | ||
return BaseResponse.onSuccess(TestResponse.TempTestDTO.builder() | ||
.testString(request.getTestString()) | ||
.build()); | ||
} | ||
} |
19 changes: 19 additions & 0 deletions
19
src/main/java/com/umc/networkingService/domain/test/dto/TestRequest.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,19 @@ | ||
package com.umc.networkingService.domain.test.dto; | ||
|
||
import jakarta.validation.constraints.NotBlank; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Builder; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
|
||
public class TestRequest { | ||
|
||
@Builder | ||
@Getter | ||
@NoArgsConstructor | ||
@AllArgsConstructor | ||
public static class TempTestRequest { | ||
@NotBlank(message = "testString은 필수입니다.") | ||
private String testString; | ||
} | ||
} |
25 changes: 25 additions & 0 deletions
25
src/main/java/com/umc/networkingService/domain/test/dto/TestResponse.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,25 @@ | ||
package com.umc.networkingService.domain.test.dto; | ||
|
||
import lombok.AllArgsConstructor; | ||
import lombok.Builder; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
|
||
public class TestResponse { | ||
|
||
@Builder | ||
@Getter | ||
@NoArgsConstructor | ||
@AllArgsConstructor | ||
public static class TempTestDTO { | ||
String testString; | ||
} | ||
|
||
@Builder | ||
@Getter | ||
@NoArgsConstructor | ||
@AllArgsConstructor | ||
public static class TempExceptionDTO { | ||
Integer flag; | ||
} | ||
} |
15 changes: 15 additions & 0 deletions
15
src/main/java/com/umc/networkingService/domain/test/service/TestService.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,15 @@ | ||
package com.umc.networkingService.domain.test.service; | ||
|
||
import com.umc.networkingService.global.common.exception.RestApiException; | ||
import com.umc.networkingService.global.common.exception.ErrorCode; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.stereotype.Service; | ||
|
||
@Service | ||
@RequiredArgsConstructor | ||
public class TestService { | ||
public void CheckFlag(Integer flag) { | ||
if (flag == 1) | ||
throw new RestApiException(ErrorCode.TEMP_EXCEPTION); | ||
} | ||
} |
2 changes: 1 addition & 1 deletion
2
src/main/java/com/umc/networkingService/domain/todayILearned/entity/TodayILearned.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
2 changes: 1 addition & 1 deletion
2
src/main/java/com/umc/networkingService/domain/todayILearned/entity/TodayILearnedFile.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
2 changes: 1 addition & 1 deletion
2
src/main/java/com/umc/networkingService/domain/todoList/entity/ToDoList.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
Oops, something went wrong.