forked from InhaBas/Inhabas.com-api
-
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.
[feature/InhaBas#204] ClubHistory controller 구현
- Loading branch information
Showing
4 changed files
with
197 additions
and
0 deletions.
There are no files selected for viewing
7 changes: 7 additions & 0 deletions
7
...ce-server/src/main/java/com/inhabas/api/domain/club/repository/ClubHistoryRepository.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,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<ClubHistory, Long> { | ||
} |
21 changes: 21 additions & 0 deletions
21
resource-server/src/main/java/com/inhabas/api/domain/club/usecase/ClubHistoryService.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 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<ClubHistoryDto> getClubHistories(); | ||
|
||
void updateClubHistory(Long clubHistoryId, SaveClubHistoryDto saveClubHistoryDto); | ||
|
||
void deleteClubHistories(Long clubHistoryId); | ||
|
||
} | ||
|
42 changes: 42 additions & 0 deletions
42
...urce-server/src/main/java/com/inhabas/api/domain/club/usecase/ClubHistoryServiceImpl.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,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<ClubHistoryDto> getClubHistories() { | ||
return null; | ||
} | ||
|
||
@Override | ||
public void updateClubHistory(Long clubHistoryId, SaveClubHistoryDto saveClubHistoryDto) { | ||
|
||
} | ||
|
||
@Override | ||
public void deleteClubHistories(Long clubHistoryId) { | ||
|
||
} | ||
} |
127 changes: 127 additions & 0 deletions
127
resource-server/src/main/java/com/inhabas/api/web/ClubHistoryController.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,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<List<ClubHistoryDto>> getClubHistories() { | ||
|
||
List<ClubHistoryDto> 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<ClubHistoryDto> 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<ClubHistoryDto> 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<Void> 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<Void> deleteClubHistory(@PathVariable Long clubHistoryId) { | ||
|
||
clubHistoryService.deleteClubHistories(clubHistoryId); | ||
return ResponseEntity.noContent().build(); | ||
|
||
} | ||
|
||
} |