-
Notifications
You must be signed in to change notification settings - Fork 2
feat/#KD-48 : Schedule API 구현 #286
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 3 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
aa8f9fa
feat/KD-48-api: service 삭제, 수정 로직 예외 처리추가
dkdltm221 4a9f36e
feat/KD-48-api: schedule 관리자용 api 추가 생성,수정,삭제 로직
dkdltm221 8023816
feat/KD-48-api: schedule 조회 로직 구현
dkdltm221 60fd79e
feat/KD-48-api: schedule 테스트코드 작성
dkdltm221 2c9a60d
chore/KD-48-api: scheduleService -> ScheduleCommandService로 이름변경
dkdltm221 03668a5
feat/KD-48-api: Builder 어노테이션 추가
dkdltm221 445081f
feat/KD-48-api: SecurityConfig public-endPoint scheduls 추가
dkdltm221 0d5c7b4
feat/KD-48-api: schedule test코드 추가
dkdltm221 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
52 changes: 52 additions & 0 deletions
52
aics-admin/src/main/java/kgu/developers/admin/schedule/application/ScheduleAdminFacade.java
This file contains hidden or 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 kgu.developers.admin.schedule.application; | ||
|
|
||
| import kgu.developers.admin.schedule.presentation.request.ScheduleContentUpdateRequest; | ||
| import kgu.developers.admin.schedule.presentation.request.ScheduleCreateRequest; | ||
| import kgu.developers.admin.schedule.presentation.request.ScheduleUpdateRequest; | ||
| import kgu.developers.admin.schedule.presentation.response.SchedulePersistResponse; | ||
| import kgu.developers.domain.schedule.application.command.ScheduleService; | ||
| import kgu.developers.domain.schedule.application.query.ScheduleQueryService; | ||
| import kgu.developers.domain.schedule.domain.Schedule; | ||
| import kgu.developers.domain.schedule.domain.SubmissionType; | ||
| import lombok.RequiredArgsConstructor; | ||
| import org.springframework.stereotype.Component; | ||
| import org.springframework.transaction.annotation.Transactional; | ||
|
|
||
| @Component | ||
| @Transactional | ||
| @RequiredArgsConstructor | ||
| public class ScheduleAdminFacade { | ||
| private final ScheduleService scheduleService; | ||
| private final ScheduleQueryService scheduleQueryService; | ||
|
|
||
| public SchedulePersistResponse createSchedule(ScheduleCreateRequest request) { | ||
| Long id = scheduleService.createSchedule( | ||
| request.submissionType(), | ||
| request.title(), | ||
| request.content(), | ||
| request.startDate(), | ||
| request.endDate() | ||
| ); | ||
| return SchedulePersistResponse.from(id); | ||
| } | ||
|
|
||
| public void updateSchedule(Long scheduleId, ScheduleUpdateRequest request) { | ||
| Schedule schedule = scheduleQueryService.getScheduleManagement(scheduleId); | ||
| scheduleService.updateSchedule( | ||
| schedule, | ||
| request.submissionType(), | ||
| request.title(), | ||
| request.startDate(), | ||
| request.endDate() | ||
| ); | ||
| } | ||
|
|
||
| public void updateScheduleContent(SubmissionType submissionType, ScheduleContentUpdateRequest request) { | ||
| Schedule schedule =scheduleQueryService.getBySubmissionType(submissionType); | ||
| scheduleService.updateScheduleContent(schedule,request.content()); | ||
| } | ||
|
|
||
| public void deleteSchedule(Long scheduleId) { | ||
| scheduleService.deleteSchedule(scheduleId); | ||
| } | ||
| } | ||
84 changes: 84 additions & 0 deletions
84
...min/src/main/java/kgu/developers/admin/schedule/presentation/ScheduleAdminController.java
This file contains hidden or 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,84 @@ | ||
| package kgu.developers.admin.schedule.presentation; | ||
|
|
||
| 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.Schema; | ||
| import io.swagger.v3.oas.annotations.responses.ApiResponse; | ||
| import io.swagger.v3.oas.annotations.tags.Tag; | ||
| import jakarta.validation.Valid; | ||
| import jakarta.validation.constraints.Positive; | ||
| import kgu.developers.admin.schedule.presentation.request.ScheduleContentUpdateRequest; | ||
| import kgu.developers.admin.schedule.presentation.request.ScheduleCreateRequest; | ||
| import kgu.developers.admin.schedule.presentation.request.ScheduleUpdateRequest; | ||
| import kgu.developers.admin.schedule.presentation.response.SchedulePersistResponse; | ||
| import kgu.developers.domain.schedule.domain.SubmissionType; | ||
| import org.springframework.http.ResponseEntity; | ||
| import org.springframework.web.bind.annotation.PathVariable; | ||
| import org.springframework.web.bind.annotation.RequestBody; | ||
|
|
||
|
|
||
| @Tag(name = "Schedule", description = "일정 관리 API") | ||
| public interface ScheduleAdminController { | ||
|
|
||
| @Operation(summary = "일정 생성 API", description = """ | ||
| - Description : 이 API는 일정을 생성합니다. | ||
| - Assignee : 주윤빈 | ||
| """) | ||
| @ApiResponse( | ||
| responseCode = "201", | ||
| content = @Content(schema = @Schema(implementation = SchedulePersistResponse.class))) | ||
| ResponseEntity<SchedulePersistResponse> createSchedule( | ||
| @Parameter( | ||
| description = "일정 생성 request 객체 입니다.", | ||
| required = true | ||
| )@Valid @RequestBody | ||
| ScheduleCreateRequest request | ||
| ); | ||
|
|
||
| @Operation(summary = "일정 수정 API", description = """ | ||
| - Description : 이 API는 일정을 수정합니다. | ||
| - Assignee : 주윤빈 | ||
| """) | ||
| @ApiResponse(responseCode = "204") | ||
| ResponseEntity<Void> updateSchedule( | ||
| @Parameter( | ||
| description = "이 API는 제출 유형/제목/기간을 수정합니다.", | ||
| example = "1", | ||
| required = true | ||
| )@Positive @PathVariable Long scheduleId, | ||
| @Parameter( | ||
| description = "일정 수정 request 객체 입니다.", | ||
| required = true | ||
| )@Valid @RequestBody ScheduleUpdateRequest request | ||
| ); | ||
|
|
||
| @Operation(summary = "유형별 본문 수정 API",description = """ | ||
| -Description : 이 API는 제출 유형을 기준으로 본문만 수정합니다. | ||
| -Assignee : 주윤빈 | ||
| """) | ||
| @ApiResponse(responseCode = "204") | ||
| ResponseEntity<Void> updateScheduleContent( | ||
| @Parameter( | ||
| description = "본문을 수정할 제출 유형입니다.", | ||
| example = "MIDTHESIS", | ||
| required = true | ||
| )@PathVariable SubmissionType submissionType, | ||
| @Parameter(description = "본문 수정 request 객체 입니다.", | ||
| required = true | ||
| )@Valid @RequestBody ScheduleContentUpdateRequest request | ||
| ); | ||
|
|
||
| @Operation(summary = "일정 삭제 API", description = """ | ||
| - Description : 이 API는 일정을 삭제합니다. | ||
| - Assignee : 주윤빈 | ||
| """) | ||
| @ApiResponse(responseCode = "204") | ||
| ResponseEntity<Void> deleteSchedule( | ||
| @Parameter( | ||
| description = "삭제할 일정의 ID 입니다.", | ||
| example = "1", | ||
| required = true | ||
| )@Positive @PathVariable Long scheduleId | ||
| ); | ||
| } |
61 changes: 61 additions & 0 deletions
61
...src/main/java/kgu/developers/admin/schedule/presentation/ScheduleAdminControllerImpl.java
This file contains hidden or 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,61 @@ | ||
| package kgu.developers.admin.schedule.presentation; | ||
|
|
||
| import jakarta.validation.Valid; | ||
| import jakarta.validation.constraints.Positive; | ||
| import kgu.developers.admin.schedule.application.ScheduleAdminFacade; | ||
| import kgu.developers.admin.schedule.presentation.request.ScheduleContentUpdateRequest; | ||
| import kgu.developers.admin.schedule.presentation.request.ScheduleCreateRequest; | ||
| import kgu.developers.admin.schedule.presentation.request.ScheduleUpdateRequest; | ||
| import kgu.developers.admin.schedule.presentation.response.SchedulePersistResponse; | ||
| import kgu.developers.domain.schedule.domain.SubmissionType; | ||
| import lombok.RequiredArgsConstructor; | ||
| import org.springframework.http.ResponseEntity; | ||
| import org.springframework.security.access.prepost.PreAuthorize; | ||
| import org.springframework.web.bind.annotation.*; | ||
|
|
||
| import static org.springframework.http.HttpStatus.CREATED; | ||
|
|
||
| @RestController | ||
| @RequiredArgsConstructor | ||
| @RequestMapping("/api/v1/admin/schedules") | ||
| @PreAuthorize("hasRole('ROLE_ADMIN')") | ||
| public class ScheduleAdminControllerImpl implements ScheduleAdminController { | ||
| private final ScheduleAdminFacade scheduleAdminFacade; | ||
|
|
||
| @Override | ||
| @PostMapping | ||
| public ResponseEntity<SchedulePersistResponse> createSchedule( | ||
| @Valid @RequestBody ScheduleCreateRequest request | ||
| ){ | ||
| SchedulePersistResponse response = scheduleAdminFacade.createSchedule(request); | ||
| return ResponseEntity.status(CREATED).body(response); | ||
| } | ||
|
|
||
| @Override | ||
| @PatchMapping("/{scheduleId}") | ||
| public ResponseEntity<Void> updateSchedule( | ||
| @Positive @PathVariable Long scheduleId, | ||
| @Valid @RequestBody ScheduleUpdateRequest request | ||
| ){ | ||
| scheduleAdminFacade.updateSchedule(scheduleId, request); | ||
| return ResponseEntity.noContent().build(); | ||
| } | ||
|
|
||
| @Override | ||
| @PatchMapping("/type/{submissionType}/content") | ||
| public ResponseEntity<Void> updateScheduleContent( | ||
| @PathVariable SubmissionType submissionType, | ||
| @Valid @RequestBody ScheduleContentUpdateRequest request | ||
| ){ | ||
| scheduleAdminFacade.updateScheduleContent(submissionType, request); | ||
| return ResponseEntity.noContent().build(); | ||
| } | ||
| @Override | ||
| @DeleteMapping("/{scheduleId}") | ||
| public ResponseEntity<Void> deleteSchedule( | ||
| @Positive @PathVariable Long scheduleId | ||
| ){ | ||
| scheduleAdminFacade.deleteSchedule(scheduleId); | ||
| return ResponseEntity.noContent().build(); | ||
| } | ||
| } |
14 changes: 14 additions & 0 deletions
14
...java/kgu/developers/admin/schedule/presentation/request/ScheduleContentUpdateRequest.java
This file contains hidden or 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 kgu.developers.admin.schedule.presentation.request; | ||
|
|
||
| import io.swagger.v3.oas.annotations.media.Schema; | ||
| import jakarta.validation.constraints.NotBlank; | ||
|
|
||
| import static io.swagger.v3.oas.annotations.media.Schema.RequiredMode.REQUIRED; | ||
|
|
||
| public record ScheduleContentUpdateRequest( | ||
| @Schema(description = "일정 내용", example = "매학기 개강 후 2주 이내에 신청서를 작성하여 접수해야합니다.",requiredMode = REQUIRED) | ||
| @NotBlank | ||
| String content | ||
| ) { | ||
|
|
||
| } |
32 changes: 32 additions & 0 deletions
32
...c/main/java/kgu/developers/admin/schedule/presentation/request/ScheduleCreateRequest.java
This file contains hidden or 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,32 @@ | ||
| package kgu.developers.admin.schedule.presentation.request; | ||
| import static io.swagger.v3.oas.annotations.media.Schema.RequiredMode.REQUIRED; | ||
| import io.swagger.v3.oas.annotations.media.Schema; | ||
| import jakarta.validation.constraints.*; | ||
| import kgu.developers.domain.schedule.domain.SubmissionType; | ||
|
|
||
| import java.time.LocalDateTime; | ||
|
|
||
| public record ScheduleCreateRequest( | ||
| @Schema(description = "제출 유형", example = "SUBMITTED", requiredMode = REQUIRED) | ||
| @NotNull SubmissionType submissionType, | ||
|
|
||
| @Schema(description = "일정 제목", example = "중간논문 제출 안내",requiredMode = REQUIRED) | ||
| @NotBlank @Size(max=100,message = "일정 제목은 100자 이내여야 합니다.") String title, | ||
|
|
||
| @Schema(description = "일정 내용", example = "매학기 개강 후 2주 이내에 신청서를 작성하여 접수해야합니다.",requiredMode = REQUIRED) | ||
| @NotBlank String content, | ||
|
|
||
| @Schema(description = "시작 일시", example = "2025-04-15T00:00:00", requiredMode = REQUIRED) | ||
| @NotNull LocalDateTime startDate, | ||
|
|
||
| @Schema(description = "종료 일시", example = "2025-12-31T23:59:59", requiredMode = REQUIRED) | ||
| @NotNull LocalDateTime endDate | ||
| ) { | ||
| @AssertTrue(message = "종료 일시는 시작 일시 이후여야 합니다.") | ||
| public boolean isValidDateRange() { | ||
| if (startDate ==null || endDate == null) { | ||
| return true; | ||
| } | ||
| return !endDate.isBefore(startDate); | ||
| } | ||
| } |
36 changes: 36 additions & 0 deletions
36
...c/main/java/kgu/developers/admin/schedule/presentation/request/ScheduleUpdateRequest.java
This file contains hidden or 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,36 @@ | ||
| package kgu.developers.admin.schedule.presentation.request; | ||
|
|
||
| import io.swagger.v3.oas.annotations.media.Schema; | ||
| import jakarta.validation.constraints.*; | ||
| import kgu.developers.domain.schedule.domain.SubmissionType; | ||
|
|
||
| import java.time.LocalDateTime; | ||
|
|
||
| import static io.swagger.v3.oas.annotations.media.Schema.RequiredMode.REQUIRED; | ||
|
|
||
| public record ScheduleUpdateRequest( | ||
| @Schema(description = "제출 유형", example = "SUBMITTED", requiredMode = REQUIRED) | ||
| @NotNull | ||
| SubmissionType submissionType, | ||
|
|
||
| @Schema(description = "일정 제목", example = "중간논문 제출 안내",requiredMode = REQUIRED) | ||
| @NotBlank @Size(max=100,message = "일정 제목은 100자 이내여야 합니다.") | ||
| String title, | ||
|
|
||
|
|
||
| @Schema(description = "시작 일시", example = "2025-04-15T00:00:00", requiredMode = REQUIRED) | ||
| @NotNull | ||
| LocalDateTime startDate, | ||
|
|
||
| @Schema(description = "종료 일시", example = "2025-12-31T23:59:59", requiredMode = REQUIRED) | ||
| @NotNull | ||
| LocalDateTime endDate | ||
| ) { | ||
| @AssertTrue(message = "종료 일시는 시작 일시 이후여야 합니다.") | ||
|
dkdltm221 marked this conversation as resolved.
|
||
| public boolean isValidDateRange() { | ||
| if (startDate ==null || endDate == null) { | ||
| return true; | ||
| } | ||
| return !endDate.isBefore(startDate); | ||
| } | ||
| } | ||
18 changes: 18 additions & 0 deletions
18
...ain/java/kgu/developers/admin/schedule/presentation/response/SchedulePersistResponse.java
This file contains hidden or 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,18 @@ | ||
| package kgu.developers.admin.schedule.presentation.response; | ||
|
|
||
| import io.swagger.v3.oas.annotations.media.Schema; | ||
| import lombok.Builder; | ||
|
|
||
| import static io.swagger.v3.oas.annotations.media.Schema.RequiredMode.REQUIRED; | ||
|
|
||
| @Builder | ||
| public record SchedulePersistResponse( | ||
| @Schema(description = "일정 id", example = "1", requiredMode = REQUIRED) | ||
| Long scheduleId | ||
| ) { | ||
| public static SchedulePersistResponse from(Long scheduleId) { | ||
| return SchedulePersistResponse.builder() | ||
| .scheduleId(scheduleId) | ||
| .build(); | ||
| } | ||
| } |
32 changes: 32 additions & 0 deletions
32
aics-api/src/main/java/kgu/developers/api/schedule/application/ScheduleFacade.java
This file contains hidden or 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,32 @@ | ||
| package kgu.developers.api.schedule.application; | ||
|
|
||
| import kgu.developers.domain.schedule.application.command.ScheduleService; | ||
| import kgu.developers.domain.schedule.application.query.ScheduleQueryService; | ||
| import kgu.developers.domain.schedule.domain.Schedule; | ||
| import kgu.developers.domain.schedule.domain.SubmissionType; | ||
| import lombok.RequiredArgsConstructor; | ||
| import org.springframework.stereotype.Component; | ||
| import org.springframework.transaction.annotation.Transactional; | ||
|
|
||
| import java.util.List; | ||
|
|
||
| @Component | ||
| @RequiredArgsConstructor | ||
| @Transactional(readOnly = true) | ||
| public class ScheduleFacade { | ||
| private final ScheduleQueryService scheduleQueryService; | ||
|
|
||
| public List<Schedule> findAll() { | ||
| return scheduleQueryService.getAllScheduleManagements(); | ||
| } | ||
| public Schedule findBySubmissionType(SubmissionType submissionType) { | ||
| return scheduleQueryService.getBySubmissionType(submissionType); | ||
| } | ||
|
|
||
| public Schedule findById(Long id) { | ||
| return scheduleQueryService.getScheduleManagement(id); | ||
| } | ||
|
|
||
|
|
||
|
|
||
| } |
43 changes: 43 additions & 0 deletions
43
aics-api/src/main/java/kgu/developers/api/schedule/presentation/ScheduleController.java
This file contains hidden or 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,43 @@ | ||
| package kgu.developers.api.schedule.presentation; | ||
|
|
||
| import io.swagger.v3.oas.annotations.Operation; | ||
| import io.swagger.v3.oas.annotations.media.Content; | ||
| import io.swagger.v3.oas.annotations.media.Schema; | ||
| import io.swagger.v3.oas.annotations.responses.ApiResponse; | ||
| import io.swagger.v3.oas.annotations.tags.Tag; | ||
| import kgu.developers.api.schedule.presentation.response.ScheduleListResponse; | ||
| import kgu.developers.api.schedule.presentation.response.ScheduleSummaryResponse; | ||
| import kgu.developers.api.schedule.presentation.response.ScheduleTypeContentResponse; | ||
| import kgu.developers.domain.schedule.domain.SubmissionType; | ||
| import org.springframework.http.ResponseEntity; | ||
|
|
||
| @Tag(name = "Schedule", description = "일정관리 API") | ||
| public interface ScheduleController { | ||
|
|
||
| @Operation(summary = "전체 일정 조회 API", description = """ | ||
| - Description : 이 API는 모든 일정을 조회합니다. | ||
| - Assignee : 주윤빈 | ||
| """) | ||
| @ApiResponse( | ||
| responseCode = "200", | ||
| content = @Content(schema = @Schema(implementation = ScheduleListResponse.class))) | ||
| ResponseEntity<ScheduleListResponse> getScheduleList(); | ||
|
|
||
| @Operation(summary = "유형별 일정 본문 조회 API", description = """ | ||
| - Description : 이 API는 제출유형별 본문만 조회합니다. | ||
| - Assignee : 주윤빈 | ||
| """) | ||
| @ApiResponse( | ||
| responseCode = "200", | ||
| content = @Content(schema = @Schema(implementation = ScheduleTypeContentResponse.class))) | ||
| ResponseEntity<ScheduleTypeContentResponse> getSchedulesByType(SubmissionType type); | ||
|
|
||
| @Operation(summary = "단일 일정 조회 API", description = """ | ||
| - Description : 이 API는 단일 일정을 조회합니다. | ||
| - Assignee : 주윤빈 | ||
| """) | ||
| @ApiResponse( | ||
| responseCode = "200", | ||
| content = @Content(schema = @Schema(implementation = ScheduleSummaryResponse.class))) | ||
| ResponseEntity<ScheduleSummaryResponse> getScheduleById(Long id); | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.