From 0ee8625abd06c05a134266403017f9ad82b8ce25 Mon Sep 17 00:00:00 2001 From: whitemark Date: Sun, 31 Dec 2023 22:48:44 +0900 Subject: [PATCH] =?UTF-8?q?[feature/#204]=20ClubHistory=20controller=20?= =?UTF-8?q?=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../repository/ClubHistoryRepository.java | 7 + .../club/usecase/ClubHistoryService.java | 21 +++ .../club/usecase/ClubHistoryServiceImpl.java | 42 ++++++ .../api/web/ClubHistoryController.java | 127 ++++++++++++++++++ 4 files changed, 197 insertions(+) create mode 100644 resource-server/src/main/java/com/inhabas/api/domain/club/repository/ClubHistoryRepository.java create mode 100644 resource-server/src/main/java/com/inhabas/api/domain/club/usecase/ClubHistoryService.java create mode 100644 resource-server/src/main/java/com/inhabas/api/domain/club/usecase/ClubHistoryServiceImpl.java create mode 100644 resource-server/src/main/java/com/inhabas/api/web/ClubHistoryController.java diff --git a/resource-server/src/main/java/com/inhabas/api/domain/club/repository/ClubHistoryRepository.java b/resource-server/src/main/java/com/inhabas/api/domain/club/repository/ClubHistoryRepository.java new file mode 100644 index 00000000..e8f76221 --- /dev/null +++ b/resource-server/src/main/java/com/inhabas/api/domain/club/repository/ClubHistoryRepository.java @@ -0,0 +1,7 @@ +package com.inhabas.api.domain.club.repository; + +import com.inhabas.api.domain.club.domain.entity.ClubHistory; +import org.springframework.data.jpa.repository.JpaRepository; + +public interface ClubHistoryRepository extends JpaRepository { +} diff --git a/resource-server/src/main/java/com/inhabas/api/domain/club/usecase/ClubHistoryService.java b/resource-server/src/main/java/com/inhabas/api/domain/club/usecase/ClubHistoryService.java new file mode 100644 index 00000000..327fbd1f --- /dev/null +++ b/resource-server/src/main/java/com/inhabas/api/domain/club/usecase/ClubHistoryService.java @@ -0,0 +1,21 @@ +package com.inhabas.api.domain.club.usecase; + +import com.inhabas.api.domain.club.dto.ClubHistoryDto; +import com.inhabas.api.domain.club.dto.SaveClubHistoryDto; + +import java.util.List; + +public interface ClubHistoryService { + + Long writeClubHistory(SaveClubHistoryDto saveClubHistoryDto); + + ClubHistoryDto findClubHistory(Long clubHistoryId); + + List getClubHistories(); + + void updateClubHistory(Long clubHistoryId, SaveClubHistoryDto saveClubHistoryDto); + + void deleteClubHistories(Long clubHistoryId); + +} + diff --git a/resource-server/src/main/java/com/inhabas/api/domain/club/usecase/ClubHistoryServiceImpl.java b/resource-server/src/main/java/com/inhabas/api/domain/club/usecase/ClubHistoryServiceImpl.java new file mode 100644 index 00000000..b03f12f0 --- /dev/null +++ b/resource-server/src/main/java/com/inhabas/api/domain/club/usecase/ClubHistoryServiceImpl.java @@ -0,0 +1,42 @@ +package com.inhabas.api.domain.club.usecase; + +import com.inhabas.api.domain.club.dto.ClubHistoryDto; +import com.inhabas.api.domain.club.dto.SaveClubHistoryDto; +import com.inhabas.api.domain.club.repository.ClubHistoryRepository; +import lombok.RequiredArgsConstructor; +import org.springframework.stereotype.Service; + +import java.util.List; + +@Service +@RequiredArgsConstructor +public class ClubHistoryServiceImpl implements ClubHistoryService { + + private final ClubHistoryRepository clubHistoryRepository; + + + @Override + public Long writeClubHistory(SaveClubHistoryDto saveClubHistoryDto) { + return null; + } + + @Override + public ClubHistoryDto findClubHistory(Long clubHistoryId) { + return null; + } + + @Override + public List getClubHistories() { + return null; + } + + @Override + public void updateClubHistory(Long clubHistoryId, SaveClubHistoryDto saveClubHistoryDto) { + + } + + @Override + public void deleteClubHistories(Long clubHistoryId) { + + } +} diff --git a/resource-server/src/main/java/com/inhabas/api/web/ClubHistoryController.java b/resource-server/src/main/java/com/inhabas/api/web/ClubHistoryController.java new file mode 100644 index 00000000..be4114c5 --- /dev/null +++ b/resource-server/src/main/java/com/inhabas/api/web/ClubHistoryController.java @@ -0,0 +1,127 @@ +package com.inhabas.api.web; + +import com.inhabas.api.auth.domain.error.ErrorResponse; +import com.inhabas.api.domain.club.dto.ClubHistoryDto; +import com.inhabas.api.domain.club.dto.SaveClubHistoryDto; +import com.inhabas.api.domain.club.usecase.ClubHistoryService; +import io.swagger.v3.oas.annotations.Operation; +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 lombok.RequiredArgsConstructor; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.*; +import org.springframework.web.servlet.support.ServletUriComponentsBuilder; + +import javax.validation.Valid; +import java.net.URI; +import java.util.List; + +@Tag(name = "동아리 소개", description = "동아리 소개 관련 조회, 수정") +@RestController +@RequiredArgsConstructor +public class ClubHistoryController { + + private final ClubHistoryService clubHistoryService; + + @Operation(summary = "동아리 연혁 조회", + description = "동아리 연혁 조회") + @ApiResponses(value = { + @ApiResponse(responseCode = "200", content = { @Content( + schema = @Schema(implementation = ClubHistoryDto.class, + type = "array")) }), + }) + @GetMapping("/club/histories") + public ResponseEntity> getClubHistories() { + + List clubHistoryDtoList = clubHistoryService.getClubHistories(); + return ResponseEntity.ok(clubHistoryDtoList); + + } + + @Operation(summary = "동아리 연혁 단일 조회", + description = "동아리 연혁 단일 조회") + @ApiResponses(value = { + @ApiResponse(responseCode = "200", content = { @Content( + schema = @Schema(implementation = ClubHistoryDto.class)) + }), + }) + @GetMapping("/club/history/{clubHistoryId}") + public ResponseEntity findClubHistory(@PathVariable Long clubHistoryId) { + + ClubHistoryDto clubHistoryDto = clubHistoryService.findClubHistory(clubHistoryId); + return ResponseEntity.ok(clubHistoryDto); + + } + + @Operation(summary = "동아리 연혁 생성", + description = "동아리 연혁 생성") + @ApiResponses(value = { + @ApiResponse(responseCode = "201", description = "'Location' 헤더에 생성된 리소스의 URI가 포함됩니다."), + @ApiResponse(responseCode = "400 ", description = "입력값이 없거나, 타입이 유효하지 않습니다.", content = @Content( + schema = @Schema(implementation = ErrorResponse.class), + examples = @ExampleObject( + value = "{\"status\": 400, \"code\": \"G003\", \"message\": \"입력값이 없거나, 타입이 유효하지 않습니다.\"}" + ) + )) + }) + @PostMapping("/club/history") + public ResponseEntity writeClubHistories(@Valid SaveClubHistoryDto saveClubHistoryDto) { + + Long newClubHistoryId = clubHistoryService.writeClubHistory(saveClubHistoryDto); + URI location = ServletUriComponentsBuilder.fromCurrentRequest() + .path("/club/history/{clubHistoryId}") + .buildAndExpand(newClubHistoryId) + .toUri(); + return ResponseEntity.created(location).build(); + + } + + @Operation(summary = "동아리 연혁 수정", + description = "동아리 연혁 수정") + @ApiResponses(value = { + @ApiResponse(responseCode = "204"), + @ApiResponse(responseCode = "400 ", description = "입력값이 없거나, 타입이 유효하지 않습니다.", content = @Content( + schema = @Schema(implementation = ErrorResponse.class), + examples = @ExampleObject( + value = "{\"status\": 400, \"code\": \"G003\", \"message\": \"입력값이 없거나, 타입이 유효하지 않습니다.\"}" + ) + )), + @ApiResponse(responseCode = "404", description = "데이터가 존재하지 않습니다.", content = @Content( + schema = @Schema(implementation = ErrorResponse.class), + examples = @ExampleObject( + value = "{\"status\": 404, \"code\": \"G004\", \"message\": \"데이터가 존재하지 않습니다.\"}" + ) + )) + }) + @PutMapping("/club/history/{clubHistoryId}") + public ResponseEntity updateClubHistory(@PathVariable Long clubHistoryId, @Valid SaveClubHistoryDto saveClubHistoryDto) { + + clubHistoryService.updateClubHistory(clubHistoryId, saveClubHistoryDto); + return ResponseEntity.noContent().build(); + + } + + @Operation(summary = "동아리 연혁 삭제", + description = "동아리 연혁 삭제") + @ApiResponses(value = { + @ApiResponse(responseCode = "204"), + @ApiResponse(responseCode = "404", description = "데이터가 존재하지 않습니다.", content = @Content( + schema = @Schema(implementation = ErrorResponse.class), + examples = @ExampleObject( + value = "{\"status\": 404, \"code\": \"G004\", \"message\": \"데이터가 존재하지 않습니다.\"}" + ) + )) + }) + @DeleteMapping ("/club/{clubHistoryId}") + public ResponseEntity deleteClubHistory(@PathVariable Long clubHistoryId) { + + clubHistoryService.deleteClubHistories(clubHistoryId); + return ResponseEntity.noContent().build(); + + } + +}