Skip to content

Commit

Permalink
✨ [Feature] 개인일정 삭제 api 작성 #1058
Browse files Browse the repository at this point in the history
  • Loading branch information
taehyeon committed Dec 31, 2024
1 parent 6d74226 commit d9824eb
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PatchMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
Expand Down Expand Up @@ -42,4 +43,11 @@ public ResponseEntity<PrivateScheduleUpdateResDto> privateScheduleUpdate(
privateScheduleUpdateReqDto, id);
return ResponseEntity.status(HttpStatus.OK).body(privateScheduleUpdateResDto);
}

@PatchMapping("/{id}")
public ResponseEntity<Void> privateScheduleDelete(@Login @Parameter(hidden = true) UserDto userDto,
@PathVariable Long id) {
privateScheduleService.deletePrivateSchedule(userDto, id);
return ResponseEntity.status(HttpStatus.NO_CONTENT).build();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public class PrivateScheduleUpdateReqDto {
private Long groupId;

@Builder
public PrivateScheduleUpdateReqDto(EventTag eventTag, JobTag jobTag, TechTag techTag, String title, String content,
private PrivateScheduleUpdateReqDto(EventTag eventTag, JobTag jobTag, TechTag techTag, String title, String content,
String link, ScheduleStatus status, LocalDateTime startTime, LocalDateTime endTime, boolean alarm,
Long groupId) {
this.eventTag = eventTag;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,13 @@ public PrivateScheduleUpdateResDto updatePrivateSchedule(UserDto userDto,
return PrivateScheduleUpdateResDto.toDto(privateSchedule);
}

@Transactional
public void deletePrivateSchedule(UserDto userDto, Long privateScheduleId) {
PrivateSchedule privateSchedule = privateScheduleRepository.findById(privateScheduleId)
.orElseThrow(() -> new NotExistException(ErrorCode.PRIVATE_SCHEDULE_NOT_FOUND));
privateSchedule.delete();
}

public void validateTimeRange(LocalDateTime startTime, LocalDateTime endTime) {
if (endTime.isBefore(startTime)) {
throw new InvalidParameterException(ErrorCode.CALENDAR_BEFORE_DATE);
Expand Down
8 changes: 8 additions & 0 deletions gg-data/src/main/java/gg/data/calendar/PrivateSchedule.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import javax.persistence.ManyToOne;

import gg.data.BaseTimeEntity;
import gg.data.calendar.type.DetailClassification;
import gg.data.calendar.type.EventTag;
import gg.data.calendar.type.JobTag;
import gg.data.calendar.type.ScheduleStatus;
Expand Down Expand Up @@ -65,4 +66,11 @@ public void update(EventTag eventTag, JobTag jobTag, TechTag techTag, String tit
this.publicSchedule.update(publicSchedule.getClassification(), eventTag, jobTag, techTag, title, content, link,
startTime, endTime, status);
}

public void delete() {
this.status = ScheduleStatus.DELETE;
if (this.publicSchedule.getClassification() == DetailClassification.PRIVATE_SCHEDULE) {
publicSchedule.delete();
}
}
}
4 changes: 4 additions & 0 deletions gg-data/src/main/java/gg/data/calendar/PublicSchedule.java
Original file line number Diff line number Diff line change
Expand Up @@ -100,5 +100,9 @@ public void update(DetailClassification classification, EventTag eventTag, JobTa
this.endTime = endTime;
this.status = status;
}

public void delete() {
this.status = ScheduleStatus.DELETE;
}
}

0 comments on commit d9824eb

Please sign in to comment.