-
Notifications
You must be signed in to change notification settings - Fork 1
[FEAT] 캘린더 기능을 추가합니다. #281
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 all commits
Commits
Show all changes
58 commits
Select commit
Hold shift + click to select a range
d7bf4b4
refactor: class 및 Entity 이름 변경
rlajm1203 2bcface
style: spotlessApply
rlajm1203 d765cec
feat: CalendarType, Model 정의
rlajm1203 5a3cf71
feat: Calendar Repository 정의
rlajm1203 5cf8d82
feat: Calendar Entity 정의
rlajm1203 c7d0025
feat: CalendarCreateUsecase 정의 및 구현
rlajm1203 3bd196f
feat: CalendarValidator 구현
rlajm1203 91de791
feat: Calendar 예외 정의
rlajm1203 bf39662
feat: CalendarCreateCommand 로 수정
rlajm1203 e0f34d7
refactor: 메소드명 변경
rlajm1203 f4f7649
refactor: content 필드 제거
rlajm1203 76aa60f
refactor: 오타 수정
rlajm1203 c8b369c
feat: CalendarController 추가
rlajm1203 c859bb4
refactor: 예외 메세지 수정
rlajm1203 94a4a1b
refactor: BaseEntity 상속
rlajm1203 180cdfa
feat: toLocalDateTime 메소드 추가
rlajm1203 9a50965
refactor: 시간 필드, ms 단위로 변경
rlajm1203 78efc58
feat: 필터 체인 설정 추가
rlajm1203 6bbfe59
rename: usecase 이름 수정
rlajm1203 9506d8b
feat: toMillis 메소드 추가
rlajm1203 c397b63
feat: CalendarResponse 정의
rlajm1203 93ef38d
feat: findBetween 메소드 추가
rlajm1203 e65f8a9
feat: CalendarQuery 정의
rlajm1203 b544582
refactor: load 메소드 정의 및 적용
rlajm1203 7674109
feat: findNameById 메소드 추가
rlajm1203 8446665
feat: Calendar 조회 API 추가
rlajm1203 fe7b19e
style: spotlessApply
rlajm1203 6f772ab
refactor: queryString Wrapper 타입으로 변경
rlajm1203 cd0df60
comment: 클래스 설명 주석 추가
rlajm1203 2d36528
feat: DateUtil 클래스 정의
rlajm1203 cd8e64c
feat: 윤년,30일,31일 고려한 로직 추가
rlajm1203 8898f05
refactor: 칼렌더 조회 쿼리 수정
rlajm1203 177c850
style: spotlessApply
rlajm1203 47126bd
refactor: 응답에 id 추가
rlajm1203 7e2cbbb
refactor: toEntity 메소드 수정
rlajm1203 a048e52
feat: Calendar Update 기능 추가
rlajm1203 03fb8d5
style: spotlessApply
rlajm1203 b2fb8dd
refactor: calendar api prefix 수정
rlajm1203 881b39a
refactor: 시큐리티 필터체인 Calendars 엔드포인트 수정
rlajm1203 b65a898
feat: Calendar 삭제 기능 구현
rlajm1203 b886212
feat: 특정 날짜 사이의 시작하지 않은 행사 조회 메소드 추가
rlajm1203 5e2c1c9
feat: D-Day API 구현
rlajm1203 372f0c6
style: spotlessApply
rlajm1203 c641357
feat: durationValidate 추가
rlajm1203 6412c5e
style: spotlessApply
rlajm1203 e7aadf1
refactor: 상태코드, 에러코드 수정
rlajm1203 9438bb9
refactor: 에러 메세지 수정
rlajm1203 a0de9dd
refactor: 에러 메세지, 에러 코드 수정
rlajm1203 bc94d9c
refactor: 캘린더 수정 권한 검증 로직 수정
rlajm1203 e370f0a
refactor: 캘린더 수정 트랜잭션 설정
rlajm1203 8057b24
refactor: 수정,삭제 검증로직 구조 변경
rlajm1203 f33a5a4
style: spotlessApply
rlajm1203 2fdddee
refactor: @repository 로 변경
rlajm1203 3595f60
refactor: measure 양수만 받도록 수정
rlajm1203 fcdc3a2
refactor: NPE 방지 설정
rlajm1203 dcab43e
refactor: 잘못된 DTO impl 수정
rlajm1203 739cf0c
refactor: start,end date 로직 수정
rlajm1203 0753606
style: spotlessApply
rlajm1203 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
6 changes: 6 additions & 0 deletions
6
eeos/src/main/java/com/blackcompany/eeos/calendar/application/dto/CalendarCreateCommand.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,6 @@ | ||
| package com.blackcompany.eeos.calendar.application.dto; | ||
|
|
||
| import com.blackcompany.eeos.common.support.dto.AbstractRequestDto; | ||
|
|
||
| public record CalendarCreateCommand(String title, String url, String type, Long startAt, Long endAt) | ||
| implements AbstractRequestDto {} |
3 changes: 3 additions & 0 deletions
3
eeos/src/main/java/com/blackcompany/eeos/calendar/application/dto/CalendarQuery.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,3 @@ | ||
| package com.blackcompany.eeos.calendar.application.dto; | ||
|
|
||
| public record CalendarQuery(Integer year, Integer month, Integer date, Integer duration) {} |
19 changes: 19 additions & 0 deletions
19
eeos/src/main/java/com/blackcompany/eeos/calendar/application/dto/CalendarResponse.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,19 @@ | ||
| package com.blackcompany.eeos.calendar.application.dto; | ||
|
|
||
| import com.blackcompany.eeos.calendar.application.model.CalendarModel; | ||
| import com.blackcompany.eeos.common.support.dto.AbstractResponseDto; | ||
| import com.blackcompany.eeos.common.utils.DateConverter; | ||
|
|
||
| public record CalendarResponse( | ||
| Long id, String title, String url, String type, Long startAt, Long endAt, String writer) | ||
| implements AbstractResponseDto { | ||
|
|
||
| public static CalendarResponse toResponse(CalendarModel model, String writerName) { | ||
| Long startAt = DateConverter.toMillis(model.getStartAt()); | ||
| Long endAt = DateConverter.toMillis(model.getEndAt()); | ||
| String type = model.getType().name(); | ||
|
|
||
| return new CalendarResponse( | ||
| model.getId(), model.getTitle(), model.getUrl(), type, startAt, endAt, writerName); | ||
| } | ||
| } |
6 changes: 6 additions & 0 deletions
6
eeos/src/main/java/com/blackcompany/eeos/calendar/application/dto/CalendarResponses.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,6 @@ | ||
| package com.blackcompany.eeos.calendar.application.dto; | ||
|
|
||
| import com.blackcompany.eeos.common.support.dto.AbstractResponseDto; | ||
| import java.util.List; | ||
|
|
||
| public record CalendarResponses(List<CalendarResponse> calendars) implements AbstractResponseDto {} |
6 changes: 6 additions & 0 deletions
6
eeos/src/main/java/com/blackcompany/eeos/calendar/application/dto/CalendarUpdateCommand.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,6 @@ | ||
| package com.blackcompany.eeos.calendar.application.dto; | ||
|
|
||
| import com.blackcompany.eeos.common.support.dto.AbstractRequestDto; | ||
|
|
||
| public record CalendarUpdateCommand(String title, String url, String type, Long startAt, Long endAt) | ||
| implements AbstractRequestDto {} |
21 changes: 21 additions & 0 deletions
21
...ava/com/blackcompany/eeos/calendar/application/exception/DeniedCalendarTypeException.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,21 @@ | ||
| package com.blackcompany.eeos.calendar.application.exception; | ||
|
|
||
| import com.blackcompany.eeos.common.exception.BusinessException; | ||
| import com.blackcompany.eeos.member.application.model.Department; | ||
| import org.springframework.http.HttpStatus; | ||
|
|
||
| public class DeniedCalendarTypeException extends BusinessException { | ||
|
|
||
| private static final String FAIL_CODE = "10001"; | ||
| private final Department department; | ||
|
|
||
| public DeniedCalendarTypeException(Department department) { | ||
| super(FAIL_CODE, HttpStatus.BAD_REQUEST); | ||
| this.department = department; | ||
| } | ||
|
|
||
| @Override | ||
| public String getMessage() { | ||
| return String.format("%s 부서는 해당 타입의 칼렌더를 생성할 수 없습니다.", department.name()); | ||
| } | ||
| } |
18 changes: 18 additions & 0 deletions
18
...a/com/blackcompany/eeos/calendar/application/exception/DeniedCalendarUpdateException.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 com.blackcompany.eeos.calendar.application.exception; | ||
|
|
||
| import com.blackcompany.eeos.common.exception.BusinessException; | ||
| import org.springframework.http.HttpStatus; | ||
|
|
||
| public class DeniedCalendarUpdateException extends BusinessException { | ||
|
|
||
| private static final String FAIL_CODE = "10002"; | ||
|
|
||
| public DeniedCalendarUpdateException() { | ||
| super(FAIL_CODE, HttpStatus.UNAUTHORIZED); | ||
| } | ||
|
|
||
| @Override | ||
| public String getMessage() { | ||
| return "캘린더를 수정할 권한이 없습니다."; | ||
| } | ||
| } |
18 changes: 18 additions & 0 deletions
18
.../main/java/com/blackcompany/eeos/calendar/application/exception/InvalidDateException.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 com.blackcompany.eeos.calendar.application.exception; | ||
|
|
||
| import com.blackcompany.eeos.common.exception.BusinessException; | ||
| import org.springframework.http.HttpStatus; | ||
|
|
||
| public class InvalidDateException extends BusinessException { | ||
|
|
||
| private static final String FAIL_CODE = "10003"; | ||
|
|
||
| public InvalidDateException() { | ||
| super(FAIL_CODE, HttpStatus.BAD_REQUEST); | ||
| } | ||
|
|
||
| @Override | ||
| public String getMessage() { | ||
| return "행사 시작 날짜는 행사 종료 날짜보다 이후일 수 없습니다."; | ||
| } | ||
| } |
20 changes: 20 additions & 0 deletions
20
...a/com/blackcompany/eeos/calendar/application/exception/NotFoundCalendarTypeException.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,20 @@ | ||
| package com.blackcompany.eeos.calendar.application.exception; | ||
|
|
||
| import com.blackcompany.eeos.common.exception.BusinessException; | ||
| import lombok.Getter; | ||
| import org.springframework.http.HttpStatus; | ||
|
|
||
| @Getter | ||
| public class NotFoundCalendarTypeException extends BusinessException { | ||
|
|
||
| private static final String FAIL_CODE = "10000"; | ||
|
|
||
| public NotFoundCalendarTypeException() { | ||
| super(FAIL_CODE, HttpStatus.BAD_REQUEST); | ||
| } | ||
|
|
||
| @Override | ||
| public String getMessage() { | ||
| return "캘린더 타입이 존재하지 않습니다."; | ||
| } | ||
| } |
88 changes: 88 additions & 0 deletions
88
eeos/src/main/java/com/blackcompany/eeos/calendar/application/model/CalendarModel.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,88 @@ | ||
| package com.blackcompany.eeos.calendar.application.model; | ||
|
|
||
| import java.time.LocalDateTime; | ||
| import lombok.AccessLevel; | ||
| import lombok.AllArgsConstructor; | ||
| import lombok.Builder; | ||
| import lombok.Getter; | ||
| import lombok.NoArgsConstructor; | ||
|
|
||
| @Getter | ||
| @Builder | ||
| @AllArgsConstructor(access = AccessLevel.PRIVATE) | ||
| @NoArgsConstructor(access = AccessLevel.PRIVATE) | ||
| public class CalendarModel { | ||
|
|
||
| private Long id; | ||
| private String title; | ||
| private Long writer; | ||
| private LocalDateTime startAt; | ||
| private LocalDateTime endAt; | ||
| private CalendarType type; | ||
| private String url; | ||
|
|
||
| public boolean isWriter(Long updater) { | ||
| return this.writer.equals(updater); | ||
| } | ||
|
|
||
| public CalendarModel updateTitle(String title) { | ||
| this.title = title; | ||
| return this; | ||
| } | ||
|
|
||
| public CalendarModel updateStartAt(LocalDateTime startAt) { | ||
| this.startAt = startAt; | ||
| return this; | ||
| } | ||
|
|
||
| public CalendarModel updateEndAt(LocalDateTime endAt) { | ||
| this.endAt = endAt; | ||
| return this; | ||
| } | ||
|
|
||
| public CalendarModel updateType(String type) { | ||
| this.type = CalendarType.findByName(type); | ||
| return this; | ||
| } | ||
|
|
||
| public CalendarModel updateUrl(String url) { | ||
| this.url = url; | ||
| return this; | ||
| } | ||
|
|
||
| public static CalendarModel create( | ||
| String title, | ||
| LocalDateTime startAt, | ||
| LocalDateTime endAt, | ||
| String type, | ||
| String url, | ||
| Long writer) { | ||
| return CalendarModel.builder() | ||
| .title(title) | ||
| .writer(writer) | ||
| .startAt(startAt) | ||
| .endAt(endAt) | ||
| .url(url) | ||
| .type(CalendarType.findByName(type)) | ||
| .build(); | ||
| } | ||
|
|
||
| public static CalendarModel load( | ||
| Long id, | ||
| String title, | ||
| LocalDateTime startAt, | ||
| LocalDateTime endAt, | ||
| CalendarType type, | ||
| String url, | ||
| Long writer) { | ||
| return CalendarModel.builder() | ||
| .id(id) | ||
| .title(title) | ||
| .writer(writer) | ||
| .startAt(startAt) | ||
| .endAt(endAt) | ||
| .url(url) | ||
| .type(type) | ||
| .build(); | ||
| } | ||
| } |
19 changes: 19 additions & 0 deletions
19
eeos/src/main/java/com/blackcompany/eeos/calendar/application/model/CalendarType.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,19 @@ | ||
| package com.blackcompany.eeos.calendar.application.model; | ||
|
|
||
| import com.blackcompany.eeos.calendar.application.exception.NotFoundCalendarTypeException; | ||
| import java.util.Arrays; | ||
|
|
||
| public enum CalendarType { | ||
| EVENT, | ||
| PRESENTATION, | ||
| ETC; | ||
|
|
||
| CalendarType() {} | ||
|
|
||
| public static CalendarType findByName(String name) { | ||
| return Arrays.stream(CalendarType.values()) | ||
| .filter(calendarType -> calendarType.name().equalsIgnoreCase(name)) | ||
| .findFirst() | ||
| .orElseThrow(NotFoundCalendarTypeException::new); | ||
| } | ||
| } |
18 changes: 18 additions & 0 deletions
18
...c/main/java/com/blackcompany/eeos/calendar/application/repository/CalendarRepository.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 com.blackcompany.eeos.calendar.application.repository; | ||
|
|
||
| import com.blackcompany.eeos.calendar.application.model.CalendarModel; | ||
| import java.time.LocalDateTime; | ||
| import java.util.List; | ||
|
|
||
| public interface CalendarRepository { | ||
|
|
||
| Long save(CalendarModel calendar); | ||
|
|
||
| CalendarModel findById(Long id); | ||
|
|
||
| List<CalendarModel> findByBetweenDate(LocalDateTime startAt, LocalDateTime endAt); | ||
|
|
||
| List<CalendarModel> findNotStarted(LocalDateTime from, LocalDateTime to); | ||
|
|
||
| void delete(Long id); | ||
| } |
94 changes: 94 additions & 0 deletions
94
.../main/java/com/blackcompany/eeos/calendar/application/service/CalendarCommandService.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,94 @@ | ||
| package com.blackcompany.eeos.calendar.application.service; | ||
|
|
||
| import com.blackcompany.eeos.calendar.application.dto.CalendarCreateCommand; | ||
| import com.blackcompany.eeos.calendar.application.dto.CalendarUpdateCommand; | ||
| import com.blackcompany.eeos.calendar.application.model.CalendarModel; | ||
| import com.blackcompany.eeos.calendar.application.repository.CalendarRepository; | ||
| import com.blackcompany.eeos.calendar.application.usecase.CreateCalendarUsecase; | ||
| import com.blackcompany.eeos.calendar.application.usecase.DeleteCalendarUsecase; | ||
| import com.blackcompany.eeos.calendar.application.usecase.UpdateCalendarUsecase; | ||
| import com.blackcompany.eeos.calendar.application.validator.CalendarValidator; | ||
| import com.blackcompany.eeos.common.utils.DateConverter; | ||
| import com.blackcompany.eeos.common.utils.RequestScope; | ||
| import com.blackcompany.eeos.member.application.model.MemberModel; | ||
| import com.blackcompany.eeos.member.application.repository.MemberRepository; | ||
| import java.time.LocalDateTime; | ||
| import lombok.RequiredArgsConstructor; | ||
| import lombok.extern.slf4j.Slf4j; | ||
| import org.springframework.stereotype.Service; | ||
| import org.springframework.transaction.annotation.Transactional; | ||
|
|
||
| @Service | ||
| @RequiredArgsConstructor | ||
| @Slf4j | ||
| public class CalendarCommandService | ||
| implements CreateCalendarUsecase, UpdateCalendarUsecase, DeleteCalendarUsecase { | ||
|
|
||
| private final MemberRepository memberRepository; | ||
| private final CalendarRepository repository; | ||
| private final CalendarValidator validator; | ||
|
|
||
| @Override | ||
| @Transactional | ||
| public Long create(CalendarCreateCommand command) { | ||
| Long memberId = RequestScope.getMemberId(); | ||
| CalendarModel calendar = newCalendar(command, memberId); | ||
| MemberModel member = memberRepository.findById(memberId); | ||
|
|
||
| validator.typeValidate(calendar, member.getDepartment()); | ||
| validator.durationValidate(calendar); | ||
|
|
||
| return repository.save(calendar); | ||
| } | ||
|
|
||
| @Override | ||
| @Transactional | ||
| public Long update(Long calendarId, CalendarUpdateCommand command) { | ||
| Long memberId = RequestScope.getMemberId(); | ||
|
|
||
| CalendarModel model = repository.findById(calendarId); | ||
|
|
||
| updateCalendar(memberId, command, model); | ||
|
|
||
| repository.save(model); | ||
|
|
||
| return model.getId(); | ||
| } | ||
|
|
||
| @Override | ||
| @Transactional | ||
| public void delete(Long calendarId) { | ||
| Long memberId = RequestScope.getMemberId(); | ||
|
|
||
| CalendarModel model = repository.findById(calendarId); | ||
|
|
||
| validator.updateValidate(model, memberId); | ||
|
|
||
| repository.delete(calendarId); | ||
| } | ||
|
|
||
| private void updateCalendar(Long memberId, CalendarUpdateCommand command, CalendarModel model) { | ||
| MemberModel member = memberRepository.findById(memberId); | ||
|
|
||
| validator.updateValidate(model, memberId); | ||
| validator.typeValidate(model, member.getDepartment()); | ||
| validator.durationValidate(model); | ||
|
|
||
| LocalDateTime startAt = DateConverter.toLocalDateTime(command.startAt()); | ||
| LocalDateTime endAt = DateConverter.toLocalDateTime(command.endAt()); | ||
|
|
||
| model | ||
| .updateEndAt(endAt) | ||
| .updateStartAt(startAt) | ||
| .updateTitle(command.title()) | ||
| .updateUrl(command.url()) | ||
| .updateType(command.type()); | ||
| } | ||
|
|
||
| private CalendarModel newCalendar(CalendarCreateCommand command, Long memberId) { | ||
| LocalDateTime startAt = DateConverter.toLocalDateTime(command.startAt()); | ||
| LocalDateTime endAt = DateConverter.toLocalDateTime(command.endAt()); | ||
| return CalendarModel.create( | ||
| command.title(), startAt, endAt, command.type(), command.url(), memberId); | ||
| } | ||
| } | ||
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.