Skip to content

Commit

Permalink
πŸ”€ [Merge] Merge 8th to dev (#1175)
Browse files Browse the repository at this point in the history
Co-authored-by: taehyeon <[email protected]>
Co-authored-by: wonie <[email protected]>
Co-authored-by: wonie <[email protected]>
Co-authored-by: seyeon22222 <[email protected]>
Co-authored-by: seykim <[email protected]>
  • Loading branch information
6 people authored Feb 27, 2025
1 parent 1cf85b0 commit 6ccedab
Show file tree
Hide file tree
Showing 13 changed files with 36 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ private PrivateScheduleAdminDetailResDto(PrivateSchedule privateSchedule, Schedu
this.link = privateSchedule.getPublicSchedule().getLink();
this.groupTitle = scheduleGroup.getTitle();
this.groupBackgroundColor = scheduleGroup.getBackgroundColor();
this.isAlarm = privateSchedule.isAlarm();
this.isAlarm = privateSchedule.getAlarm();
this.startTime = privateSchedule.getPublicSchedule().getStartTime();
this.endTime = privateSchedule.getPublicSchedule().getEndTime();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ public static ImportedScheduleUpdateResDto toDto(PrivateSchedule privateSchedule
.status(privateSchedule.getStatus())
.startTime(privateSchedule.getPublicSchedule().getStartTime())
.endTime(privateSchedule.getPublicSchedule().getEndTime())
.alarm(privateSchedule.isAlarm())
.alarm(privateSchedule.getAlarm())
.groupId(privateSchedule.getGroupId())
.build();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ public static PrivateScheduleDetailResDto toDto(PrivateSchedule privateSchedule,
.status(privateSchedule.getStatus())
.startTime(privateSchedule.getPublicSchedule().getStartTime())
.endTime(privateSchedule.getPublicSchedule().getEndTime())
.alarm(privateSchedule.isAlarm())
.alarm(privateSchedule.getAlarm())
.groupTitle(scheduleGroup.getTitle())
.groupColor(scheduleGroup.getBackgroundColor())
.build();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ public static PrivateSchedulePeriodResDto toDto(PrivateSchedule privateSchedule,
.status(privateSchedule.getStatus())
.startTime(privateSchedule.getPublicSchedule().getStartTime())
.endTime(privateSchedule.getPublicSchedule().getEndTime())
.alarm(privateSchedule.isAlarm())
.alarm(privateSchedule.getAlarm())
.groupTitle(scheduleGroup.getTitle())
.groupColor(scheduleGroup.getBackgroundColor())
.groupId(scheduleGroup.getId())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ public static PrivateScheduleUpdateResDto toDto(PrivateSchedule privateSchedule)
.status(privateSchedule.getStatus())
.startTime(privateSchedule.getPublicSchedule().getStartTime())
.endTime(privateSchedule.getPublicSchedule().getEndTime())
.alarm(privateSchedule.isAlarm())
.alarm(privateSchedule.getAlarm())
.groupId(privateSchedule.getGroupId())
.build();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import gg.data.calendar.PrivateSchedule;
import gg.data.calendar.ScheduleGroup;
import gg.data.calendar.type.DetailClassification;
import gg.data.calendar.type.ScheduleStatus;
import gg.repo.calendar.PrivateScheduleRepository;
import gg.repo.calendar.ScheduleGroupRepository;
import gg.utils.exception.ErrorCode;
Expand All @@ -26,8 +27,8 @@ public class ImportedScheduleService {
@Transactional
public ImportedScheduleUpdateResDto updateImportedSchedule(UserDto userDto,
ImportedScheduleUpdateReqDto importedScheduleUpdateReqDto, Long privateScheduleId) {
PrivateSchedule privateSchedule = privateScheduleRepository.findById(privateScheduleId)
.orElseThrow(() -> new NotExistException(ErrorCode.PRIVATE_SCHEDULE_NOT_FOUND));
PrivateSchedule privateSchedule = privateScheduleRepository.findByIdAndStatusNot(privateScheduleId,
ScheduleStatus.DELETE).orElseThrow(() -> new NotExistException(ErrorCode.PRIVATE_SCHEDULE_NOT_FOUND));
validateAuthor(userDto.getIntraId(), privateSchedule.getUser().getIntraId());
ScheduleGroup scheduleGroup = scheduleGroupRepository.findById(importedScheduleUpdateReqDto.getGroupId())
.orElseThrow(() -> new NotExistException(ErrorCode.SCHEDULE_GROUP_NOT_FOUND));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import gg.data.calendar.PublicSchedule;
import gg.data.calendar.ScheduleGroup;
import gg.data.calendar.type.DetailClassification;
import gg.data.calendar.type.ScheduleStatus;
import gg.data.user.User;
import gg.repo.calendar.PrivateScheduleRepository;
import gg.repo.calendar.PublicScheduleRepository;
Expand Down Expand Up @@ -57,8 +58,7 @@ public void createPrivateSchedule(UserDto userDto, PrivateScheduleCreateReqDto p

@Transactional
public PrivateScheduleUpdateResDto updatePrivateSchedule(UserDto userDto,
PrivateScheduleUpdateReqDto privateScheduleUpdateReqDto,
Long privateScheduleId) {
PrivateScheduleUpdateReqDto privateScheduleUpdateReqDto, Long privateScheduleId) {
validateTimeRange(privateScheduleUpdateReqDto.getStartTime(), privateScheduleUpdateReqDto.getEndTime());
PrivateSchedule privateSchedule = privateScheduleRepository.findById(privateScheduleId)
.orElseThrow(() -> new NotExistException(ErrorCode.PRIVATE_SCHEDULE_NOT_FOUND));
Expand All @@ -83,8 +83,8 @@ public void deletePrivateSchedule(UserDto userDto, Long privateScheduleId) {
}

public PrivateScheduleDetailResDto getPrivateScheduleDetail(UserDto userDto, Long privateScheduleId) {
PrivateSchedule privateSchedule = privateScheduleRepository.findById(privateScheduleId)
.orElseThrow(() -> new NotExistException(ErrorCode.PRIVATE_SCHEDULE_NOT_FOUND));
PrivateSchedule privateSchedule = privateScheduleRepository.findByIdAndStatusNot(privateScheduleId,
ScheduleStatus.DELETE).orElseThrow(() -> new NotExistException(ErrorCode.PRIVATE_SCHEDULE_NOT_FOUND));
ScheduleGroup scheduleGroup = scheduleGroupRepository.findById(privateSchedule.getGroupId())
.orElseThrow(() -> new NotExistException(ErrorCode.SCHEDULE_GROUP_NOT_FOUND));
validateAuthor(userDto.getIntraId(), privateSchedule.getUser().getIntraId());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import gg.data.calendar.type.DetailClassification;
import gg.data.calendar.type.EventTag;
import gg.data.calendar.type.JobTag;
import gg.data.calendar.type.ScheduleStatus;
import gg.data.calendar.type.TechTag;
import gg.data.user.User;
import gg.repo.calendar.PrivateScheduleRepository;
Expand Down Expand Up @@ -60,7 +61,8 @@ public void createJobPublicSchedule(PublicScheduleCreateJobReqDto req, Long user
public PublicSchedule updatePublicSchedule(Long scheduleId, PublicScheduleUpdateReqDto req, Long userId) {
tagErrorCheck(req.getClassification(), req.getEventTag(), req.getJobTag(), req.getTechTag());
User user = userRepository.getById(userId);
PublicSchedule existingSchedule = publicScheduleRepository.findById(scheduleId)
PublicSchedule existingSchedule = publicScheduleRepository.findByIdAndStatusNot(scheduleId,
ScheduleStatus.DELETE)
.orElseThrow(() -> new NotExistException(ErrorCode.PUBLIC_SCHEDULE_NOT_FOUND));
checkAuthor(existingSchedule.getAuthor(), user);
checkAuthor(req.getAuthor(), user);
Expand All @@ -73,7 +75,8 @@ public PublicSchedule updatePublicSchedule(Long scheduleId, PublicScheduleUpdate
@Transactional
public void deletePublicSchedule(Long scheduleId, Long userId) {
User user = userRepository.getById(userId);
PublicSchedule existingSchedule = publicScheduleRepository.findById(scheduleId)
PublicSchedule existingSchedule = publicScheduleRepository.findByIdAndStatusNot(scheduleId,
ScheduleStatus.DELETE)
.orElseThrow(() -> new NotExistException(ErrorCode.PUBLIC_SCHEDULE_NOT_FOUND));
checkAuthor(existingSchedule.getAuthor(), user);

Expand All @@ -88,9 +91,9 @@ public void deletePublicSchedule(Long scheduleId, Long userId) {

public PublicSchedule getPublicScheduleDetailRetrieve(Long scheduleId, Long userId) {
User user = userRepository.getById(userId);
PublicSchedule publicRetrieveSchedule = publicScheduleRepository.findById(scheduleId)
PublicSchedule publicRetrieveSchedule = publicScheduleRepository.findByIdAndStatusNot(scheduleId,
ScheduleStatus.DELETE)
.orElseThrow(() -> new NotExistException(ErrorCode.PUBLIC_SCHEDULE_NOT_FOUND));
// checkAuthor(publicRetrieveSchedule.getAuthor(), user);
return publicRetrieveSchedule;
}

Expand All @@ -107,7 +110,8 @@ public List<PublicSchedulePeriodRetrieveResDto> retrieveNonPrivateSchedulePeriod
public void addPublicScheduleToPrivateSchedule(Long scheduleId, Long groupId, UserDto userDto) {
User user = userRepository.getById(userDto.getId());
Long userId = userDto.getId();
PublicSchedule publicSchedule = publicScheduleRepository.findById(scheduleId)
PublicSchedule publicSchedule = publicScheduleRepository.findByIdAndStatusNot(scheduleId,
ScheduleStatus.DELETE)
.orElseThrow(() -> new NotExistException(ErrorCode.PUBLIC_SCHEDULE_NOT_FOUND));
scheduleGroupRepository.findByIdAndUserId(groupId, userId)
.orElseThrow(() -> new NotExistException(ErrorCode.SCHEDULE_GROUP_NOT_FOUND));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ void success() throws Exception {
//then
PrivateSchedule updated = privateScheduleRepository.findById(privateSchedule.getId()).orElseThrow();
Assertions.assertThat(privateSchedule.getGroupId()).isEqualTo(updated.getGroupId());
Assertions.assertThat(privateSchedule.isAlarm()).isEqualTo(updated.isAlarm());
Assertions.assertThat(privateSchedule.getAlarm()).isEqualTo(updated.getAlarm());
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ void success() throws Exception {
assertThat(schedules.size()).isEqualTo(1);
PrivateSchedule privateSchedule = schedules.get(0);
Assertions.assertThat(privateSchedule.getGroupId()).isEqualTo(scheduleGroup.getId());
Assertions.assertThat(privateSchedule.isAlarm()).isEqualTo(reqDto.isAlarm());
Assertions.assertThat(privateSchedule.getAlarm()).isEqualTo(reqDto.isAlarm());
}

@Test
Expand Down Expand Up @@ -176,7 +176,7 @@ void success() throws Exception {
//then
PrivateSchedule updated = privateScheduleRepository.findById(privateSchedule.getId()).orElseThrow();
Assertions.assertThat(privateSchedule.getGroupId()).isEqualTo(updated.getGroupId());
Assertions.assertThat(privateSchedule.isAlarm()).isEqualTo(updated.isAlarm());
Assertions.assertThat(privateSchedule.getAlarm()).isEqualTo(updated.getAlarm());
Assertions.assertThat(privateSchedule.getGroupId()).isEqualTo(updated.getGroupId());
Assertions.assertThat(privateSchedule.getPublicSchedule()).isEqualTo(updated.getPublicSchedule());
}
Expand Down Expand Up @@ -386,7 +386,7 @@ void success() throws Exception {
PrivateScheduleDetailResDto dto = objectMapper.readValue(response, PrivateScheduleDetailResDto.class);
//then
Assertions.assertThat(privateSchedule.getId()).isEqualTo(dto.getId());
Assertions.assertThat(privateSchedule.isAlarm()).isEqualTo(dto.isAlarm());
Assertions.assertThat(privateSchedule.getAlarm()).isEqualTo(dto.isAlarm());
Assertions.assertThat(scheduleGroup.getTitle()).isEqualTo(dto.getGroupTitle());
Assertions.assertThat(scheduleGroup.getBackgroundColor()).isEqualTo(dto.getGroupColor());
Assertions.assertThat(publicSchedule.getClassification()).isEqualTo(dto.getClassification());
Expand Down
6 changes: 3 additions & 3 deletions gg-data/src/main/java/gg/data/calendar/PrivateSchedule.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public class PrivateSchedule extends BaseTimeEntity {
private PublicSchedule publicSchedule;

@Column(nullable = false)
private boolean alarm;
private Boolean alarm;

@Column(nullable = false)
private Long groupId;
Expand All @@ -47,15 +47,15 @@ public class PrivateSchedule extends BaseTimeEntity {
@Column(nullable = false, columnDefinition = "VARCHAR(50)")
private ScheduleStatus status;

public PrivateSchedule(User user, PublicSchedule publicSchedule, boolean alarm, Long groupId) {
public PrivateSchedule(User user, PublicSchedule publicSchedule, Boolean alarm, Long groupId) {
this.user = user;
this.publicSchedule = publicSchedule;
this.alarm = alarm;
this.groupId = groupId;
this.status = ScheduleStatus.ACTIVATE;
}

public void update(boolean alarm, Long groupId) {
public void update(Boolean alarm, Long groupId) {
this.alarm = alarm;
this.groupId = groupId;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import java.time.LocalDateTime;
import java.util.List;
import java.util.Optional;

import javax.transaction.Transactional;

Expand All @@ -18,12 +19,15 @@

@Repository
public interface PrivateScheduleRepository extends JpaRepository<PrivateSchedule, Long> {
Optional<PrivateSchedule> findByIdAndStatusNot(Long id, ScheduleStatus status);

List<PrivateSchedule> findByPublicSchedule(PublicSchedule publicSchedule);

@Query("SELECT pr FROM PrivateSchedule pr "
+ "JOIN pr.publicSchedule pu "
+ "WHERE NOT (pu.startTime > :endTime OR pu.endTime < :startTime) "
+ "AND pr.user = :user")
+ "AND pr.user = :user "
+ "AND pr.status <> gg.data.calendar.type.ScheduleStatus.DELETE")
List<PrivateSchedule> findOverlappingSchedulesByUser(LocalDateTime startTime, LocalDateTime endTime, User user);

@Modifying(clearAutomatically = true)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import java.time.LocalDateTime;
import java.util.List;
import java.util.Optional;

import javax.transaction.Transactional;

Expand All @@ -28,6 +29,8 @@ List<PublicSchedule> findByEndTimeGreaterThanEqualAndStartTimeLessThanEqualAndCl
List<PublicSchedule> findByEndTimeGreaterThanEqualAndStartTimeLessThanEqualAndClassificationNot(
LocalDateTime start, LocalDateTime end, DetailClassification classification);

Optional<PublicSchedule> findByIdAndStatusNot(Long id, ScheduleStatus status);

boolean existsByTitleAndStartTime(String title, LocalDateTime beginAt);

@Modifying(clearAutomatically = true)
Expand Down

0 comments on commit 6ccedab

Please sign in to comment.