-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor : Admin 도메인을 AdminFindingGame, AdminRacingGame 도메인으로 분리 (CC-…
…132) (#26) * refactor : Admin 도메인을 AdminFindingGame, AdminRacingGame 도메인으로 분리 (CC-132) * feat : S3 이미지 업로드 에러코드 추가 (CC-132) * rename : HealthTestController 의 패키지명을 api로 변경 (CC-132) * feat : S3 이미지 업로드 응답/요청 객체 생성 (CC-132) * feat : S3 이미지 api에 ResponseEntity 추가 (CC-132) * teat : S3 이미지 업로드 실패 테스트코드 (CC-132) * teat : S3 이미지 업로드 성공 테스트코드 작성 (CC-132) * teat : 테스트코드 실행을 위한 환경 구성 (CC-132) * teat : 테스트코드 실행을 위한 환경 구성 삭제 (CC-132) * test : S3 이미지 업로드 성공 테스트 코드 작성 (CC-132) * refactor : admin 디렉터리 내부로 통합 (CC-132)
- Loading branch information
Showing
19 changed files
with
368 additions
and
221 deletions.
There are no files selected for viewing
52 changes: 52 additions & 0 deletions
52
src/main/java/ai/softeer/caecae/admin/api/AdminFindingGameController.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,52 @@ | ||
package ai.softeer.caecae.admin.api; | ||
|
||
import ai.softeer.caecae.admin.domain.dto.request.FindingGameDailyAnswerRequestDto; | ||
import ai.softeer.caecae.admin.domain.dto.response.FindingGameDailyAnswerResponseDto; | ||
import ai.softeer.caecae.admin.service.AdminFindingGameService; | ||
import ai.softeer.caecae.findinggame.service.FindingGameService; | ||
import ai.softeer.caecae.global.dto.response.SuccessResponse; | ||
import ai.softeer.caecae.global.enums.SuccessCode; | ||
import ai.softeer.caecae.racinggame.domain.dto.request.RegisterFindingGamePeriodRequestDto; | ||
import ai.softeer.caecae.racinggame.domain.dto.response.RegisterFindingGamePeriodResponseDto; | ||
import ai.softeer.caecae.racinggame.service.RacingGameInfoService; | ||
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/admin/finding") | ||
@RequiredArgsConstructor | ||
public class AdminFindingGameController { | ||
private final RacingGameInfoService racingGameService; | ||
private final FindingGameService findingGameService; | ||
private final AdminFindingGameService adminFindingGameService; | ||
|
||
/** | ||
* 어드민이 숨은캐스퍼찾기 게임 기간을 등록하는 api | ||
* | ||
* @param req 게임 시작 날짜 | ||
* @return 등록된 게임 시작 날짜, 종료 날짜(+6일) | ||
*/ | ||
@PostMapping("/period") | ||
public ResponseEntity<SuccessResponse<RegisterFindingGamePeriodResponseDto>> | ||
registerFindingGamePeriod(@RequestBody RegisterFindingGamePeriodRequestDto req) { | ||
RegisterFindingGamePeriodResponseDto res = adminFindingGameService.registerFindingGamePeriod(req); | ||
return SuccessResponse.of(SuccessCode.CREATED, res); | ||
} | ||
|
||
/** | ||
* 어드민이 숨은캐스퍼찾기 날짜별 정답을 등록하는 api | ||
* | ||
* @param req | ||
* @return | ||
*/ | ||
@PostMapping("/answer") | ||
public ResponseEntity<SuccessResponse<FindingGameDailyAnswerResponseDto>> | ||
saveFindingGameDailyInfo(@RequestBody FindingGameDailyAnswerRequestDto req) { | ||
FindingGameDailyAnswerResponseDto res = adminFindingGameService.saveFindingGameDailyAnswer(req); | ||
return SuccessResponse.of(SuccessCode.OK, res); | ||
} | ||
} |
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
21 changes: 15 additions & 6 deletions
21
src/main/java/ai/softeer/caecae/admin/api/S3Controller.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,21 +1,30 @@ | ||
package ai.softeer.caecae.admin.api; | ||
|
||
import ai.softeer.caecae.global.utils.S3Service; | ||
import ai.softeer.caecae.admin.domain.dto.response.S3ResponseDto; | ||
import ai.softeer.caecae.admin.service.S3Service; | ||
import ai.softeer.caecae.global.dto.response.SuccessResponse; | ||
import ai.softeer.caecae.global.enums.SuccessCode; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.http.ResponseEntity; | ||
import org.springframework.web.bind.annotation.PostMapping; | ||
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.multipart.MultipartFile; | ||
|
||
@RestController | ||
@RequiredArgsConstructor | ||
@RequestMapping("/api/admin/s3") | ||
public class S3Controller { | ||
// TBD : Admin의 컨트롤러들, 이미지 업로드 등의 기능을 일반 사용자가 이용 못하게 막아야 하지 않는가? | ||
private final S3Service s3Service; | ||
|
||
@PostMapping("/api/s3") | ||
public String upload(@RequestParam("file") MultipartFile file) { | ||
String filePath = s3Service.uploadFile(file); | ||
return filePath + "created!"; | ||
//TODO : ResponseEntity 생성하기 | ||
@PostMapping("") | ||
public ResponseEntity<SuccessResponse<S3ResponseDto>> upload( | ||
@RequestParam("file") MultipartFile file, | ||
String directory | ||
) { | ||
S3ResponseDto res = s3Service.uploadFile(file, directory); | ||
return SuccessResponse.of(SuccessCode.CREATED, res); | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
src/main/java/ai/softeer/caecae/admin/domain/dto/request/S3RequestDto.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,11 @@ | ||
package ai.softeer.caecae.admin.domain.dto.request; | ||
|
||
import lombok.Builder; | ||
import org.springframework.web.multipart.MultipartFile; | ||
|
||
// S3에 이미지를 업로드 할 때 사용하는 요청 객체 | ||
@Builder | ||
public record S3RequestDto( | ||
MultipartFile file | ||
) { | ||
} |
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
10 changes: 10 additions & 0 deletions
10
src/main/java/ai/softeer/caecae/admin/domain/dto/response/S3ResponseDto.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,10 @@ | ||
package ai.softeer.caecae.admin.domain.dto.response; | ||
|
||
import lombok.Builder; | ||
|
||
// S3에 이미지를 업로드 한 후 받는 응답 객체 | ||
@Builder | ||
public record S3ResponseDto( | ||
String imageUrl | ||
) { | ||
} |
14 changes: 14 additions & 0 deletions
14
src/main/java/ai/softeer/caecae/admin/domain/exception/AdminFindingGameException.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,14 @@ | ||
package ai.softeer.caecae.admin.domain.exception; | ||
|
||
import ai.softeer.caecae.global.enums.ErrorCode; | ||
import lombok.Getter; | ||
|
||
@Getter | ||
public class AdminFindingGameException extends RuntimeException { | ||
private final ErrorCode errorCode; | ||
|
||
public AdminFindingGameException(ErrorCode errorCode) { | ||
super(errorCode.getMessage()); | ||
this.errorCode = errorCode; | ||
} | ||
} |
21 changes: 21 additions & 0 deletions
21
src/main/java/ai/softeer/caecae/admin/domain/exception/AdminFindingGameExceptionHandler.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,21 @@ | ||
package ai.softeer.caecae.admin.domain.exception; | ||
|
||
import ai.softeer.caecae.global.dto.response.ErrorResponse; | ||
import lombok.extern.slf4j.Slf4j; | ||
import org.springframework.http.ResponseEntity; | ||
import org.springframework.web.bind.annotation.ControllerAdvice; | ||
import org.springframework.web.bind.annotation.ExceptionHandler; | ||
|
||
/** | ||
* FindingGame 도메인에서 에러를 핸들링하여 HttpResponse 를 반환하는 핸들러 | ||
*/ | ||
@Slf4j | ||
@ControllerAdvice | ||
public class AdminFindingGameExceptionHandler { | ||
// FindingGameException 에 대한 에러 핸들링 | ||
@ExceptionHandler(value = AdminFindingGameException.class) | ||
public ResponseEntity<ErrorResponse> handleFindingGameException(AdminFindingGameException adminException) { | ||
log.error(adminException.getMessage(), adminException); | ||
return ErrorResponse.of(adminException.getErrorCode()); | ||
} | ||
} |
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
Oops, something went wrong.