Skip to content

Commit 4c90aa3

Browse files
authored
Merge pull request #17 from Partition-app/fix/calendar-isowner
fix: calendar isowner 추가
2 parents 1ec3e06 + d0f8f04 commit 4c90aa3

5 files changed

Lines changed: 12 additions & 7 deletions

File tree

src/main/java/com/partition/domain/calender/dto/response/CalendarDailyResponse.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,5 @@ public class CalendarDailyResponse {
1515
private String title; // 제목 (내용)
1616
private String assigneeName; // 담당자 또는 작성자 이름
1717
private Boolean isCompleted; // 완료 여부 (일정은 false)
18-
18+
private Boolean isOwner;
1919
}

src/main/java/com/partition/domain/calender/service/CalendarService.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ public List<CalendarDailyResponse> getDailyCalendar(Long userId, LocalDate date)
9999
.title(schedule.getContent())
100100
.assigneeName(schedule.getUser().getName())
101101
.isCompleted(false)
102+
.isOwner(Objects.equals(schedule.getUser().getId(), userId))
102103
.build())
103104
.toList();
104105

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,18 @@
11
package com.partition.domain.schedule.dto.request;
22

3+
import jakarta.validation.constraints.NotBlank;
34
import lombok.Getter;
45
import lombok.NoArgsConstructor;
56

67
import java.time.LocalDate;
8+
import java.time.LocalTime;
79

810
@Getter
911
@NoArgsConstructor
1012
public class ScheduleUpdateRequest {
11-
// 수정할 때 값이 안 넘어오면(null이면) 기존 값을 유지하기 위해 Validation 어노테이션을 뺐습니다.
13+
@NotBlank(message = "내용은 필수입니다.")
1214
private String content;
13-
private LocalDate date;
15+
16+
private LocalDate date; // 변경 없으면 null 가능
17+
private LocalTime time; // 시간을 지우려면 null로 보내면 됨
1418
}

src/main/java/com/partition/domain/schedule/exception/ScheduleErrorCode.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99
public enum ScheduleErrorCode implements BaseErrorCode {
1010

1111
SCHEDULE_NOT_FOUND(404, "해당 일정을 찾을 수 없습니다."),
12-
NO_PERMISSION_TO_MODIFY(403, "일정을 수정할 권한이 없습니다."),
13-
NO_PERMISSION_TO_DELETE(403, "일정을 삭제할 권한이 없습니다.");
12+
NO_PERMISSION(403, "해당 일정에 대한 권한이 없습니다.");
13+
1414

1515
private final int status;
1616
private final String message;

src/main/java/com/partition/domain/schedule/service/ScheduleService.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ public void updateSchedule(Long userId, Long scheduleId, ScheduleUpdateRequest r
4343

4444
// 작성자 본인 확인
4545
if (!schedule.getUser().getId().equals(userId)) {
46-
throw new CustomException(ScheduleErrorCode.NO_PERMISSION_TO_MODIFY);
46+
throw new CustomException(ScheduleErrorCode.NO_PERMISSION);
4747
}
4848

4949
// 내용과 날짜만 업데이트 (값이 null이면 엔티티 내부에서 무시됨)
@@ -57,7 +57,7 @@ public void deleteSchedule(Long userId, Long scheduleId) {
5757

5858
// 작성자 본인 확인
5959
if (!schedule.getUser().getId().equals(userId)) {
60-
throw new CustomException(ScheduleErrorCode.NO_PERMISSION_TO_DELETE);
60+
throw new CustomException(ScheduleErrorCode.NO_PERMISSION);
6161
}
6262

6363
scheduleRepository.delete(schedule);

0 commit comments

Comments
 (0)