diff --git a/src/main/java/com/ggang/be/api/facade/TimeTableFacade.java b/src/main/java/com/ggang/be/api/facade/TimeTableFacade.java index 61b443c..2fadf8a 100644 --- a/src/main/java/com/ggang/be/api/facade/TimeTableFacade.java +++ b/src/main/java/com/ggang/be/api/facade/TimeTableFacade.java @@ -16,12 +16,11 @@ public class TimeTableFacade { private final LectureTimeSlotService lectureTimeSlotService; private final UserService userService; - private final ReadCommonInvalidTimeVoMaker voMaker; public ReadInvalidTimeResponse readMyInvalidTime(final long userId) { UserEntity findUserEntity = userService.getUserById(userId); List lectureTimeSlotEntities = lectureTimeSlotService.readUserTime(findUserEntity); - return ReadInvalidTimeResponse.fromVo(voMaker.convertToCommonResponse(lectureTimeSlotEntities)); + return ReadInvalidTimeResponse.fromVo(ReadCommonInvalidTimeVoMaker.convertToCommonResponse(lectureTimeSlotEntities)); } } diff --git a/src/main/java/com/ggang/be/api/group/dto/ActiveGroupsResponse.java b/src/main/java/com/ggang/be/api/group/dto/ActiveGroupsResponse.java index dbedfac..c4a579c 100644 --- a/src/main/java/com/ggang/be/api/group/dto/ActiveGroupsResponse.java +++ b/src/main/java/com/ggang/be/api/group/dto/ActiveGroupsResponse.java @@ -2,7 +2,7 @@ import com.ggang.be.domain.constant.Category; import com.ggang.be.domain.constant.GroupType; -import com.ggang.be.domain.constant.WeekDate; +import com.ggang.be.domain.constant.WeekDay; import com.ggang.be.domain.group.dto.GroupVo; import java.time.LocalDate; @@ -14,7 +14,7 @@ public record ActiveGroupsResponse( int profileImg, GroupType groupType, String groupTitle, - WeekDate weekDay, + WeekDay weekDay, LocalDate weekDate, double startTime, double endTime, @@ -28,8 +28,8 @@ public static ActiveGroupsResponse fromGroupVo(GroupVo groupVo) { groupVo.profileImg(), groupVo.groupType(), groupVo.groupTitle(), + groupVo.weekDay(), groupVo.weekDate(), - groupVo.groupDate(), groupVo.startTime(), groupVo.endTime(), groupVo.location() diff --git a/src/main/java/com/ggang/be/api/group/dto/GroupResponse.java b/src/main/java/com/ggang/be/api/group/dto/GroupResponse.java index ff06cda..4871d31 100644 --- a/src/main/java/com/ggang/be/api/group/dto/GroupResponse.java +++ b/src/main/java/com/ggang/be/api/group/dto/GroupResponse.java @@ -3,7 +3,7 @@ import com.fasterxml.jackson.annotation.JsonProperty; import com.ggang.be.domain.constant.Category; import com.ggang.be.domain.constant.Status; -import com.ggang.be.domain.constant.WeekDate; +import com.ggang.be.domain.constant.WeekDay; public record GroupResponse( long groupId, @@ -18,7 +18,7 @@ public record GroupResponse( String introduction, Category category, int coverImg, - WeekDate weekDay, + WeekDay weekDay, String weekDate, double startTime, double endTime diff --git a/src/main/java/com/ggang/be/api/group/dto/LatestResponse.java b/src/main/java/com/ggang/be/api/group/dto/LatestResponse.java index 31906cd..031fa3f 100644 --- a/src/main/java/com/ggang/be/api/group/dto/LatestResponse.java +++ b/src/main/java/com/ggang/be/api/group/dto/LatestResponse.java @@ -2,7 +2,7 @@ import com.ggang.be.domain.constant.Category; import com.ggang.be.domain.constant.GroupType; -import com.ggang.be.domain.constant.WeekDate; +import com.ggang.be.domain.constant.WeekDay; import com.ggang.be.domain.group.dto.GroupVo; import java.time.LocalDate; @@ -15,8 +15,8 @@ public record LatestResponse( String nickname, GroupType groupType, String groupTitle, - WeekDate weekDate, - LocalDate groupDate, + WeekDay weekDay, + LocalDate weekDate, double startTime, double endTime, String location @@ -30,8 +30,8 @@ public static LatestResponse fromGroupVo(GroupVo groupVo) { groupVo.nickname(), groupVo.groupType(), groupVo.groupTitle(), + groupVo.weekDay(), groupVo.weekDate(), - groupVo.groupDate(), groupVo.startTime(), groupVo.endTime(), groupVo.location() diff --git a/src/main/java/com/ggang/be/api/group/dto/MyGroupResponse.java b/src/main/java/com/ggang/be/api/group/dto/MyGroupResponse.java index 04beefc..468c9f9 100644 --- a/src/main/java/com/ggang/be/api/group/dto/MyGroupResponse.java +++ b/src/main/java/com/ggang/be/api/group/dto/MyGroupResponse.java @@ -3,14 +3,14 @@ import com.ggang.be.domain.constant.Category; import com.ggang.be.domain.constant.GroupType; import com.ggang.be.domain.constant.Status; -import com.ggang.be.domain.constant.WeekDate; +import com.ggang.be.domain.constant.WeekDay; import com.ggang.be.domain.group.dto.GroupVo; import java.time.LocalDate; public record MyGroupResponse( - long groupId, Status status, Category category, int coverImg, GroupType groupType, - String groupTitle, WeekDate weekDay, LocalDate weekDate, double startTime, double endTime, String location + long groupId, Status status, Category category, int coverImg, GroupType groupType, + String groupTitle, WeekDay weekDay, LocalDate weekDate, double startTime, double endTime, String location ) { public static MyGroupResponse fromGroupVo(GroupVo groupVo) { return new MyGroupResponse( @@ -20,8 +20,8 @@ public static MyGroupResponse fromGroupVo(GroupVo groupVo) { groupVo.coverImg(), groupVo.groupType(), groupVo.groupTitle(), + groupVo.weekDay(), groupVo.weekDate(), - groupVo.groupDate(), groupVo.startTime(), groupVo.endTime(), groupVo.location() diff --git a/src/main/java/com/ggang/be/api/group/dto/NearestGroupResponse.java b/src/main/java/com/ggang/be/api/group/dto/NearestGroupResponse.java index 68ef2ff..3447251 100644 --- a/src/main/java/com/ggang/be/api/group/dto/NearestGroupResponse.java +++ b/src/main/java/com/ggang/be/api/group/dto/NearestGroupResponse.java @@ -2,14 +2,14 @@ import com.ggang.be.domain.constant.Category; import com.ggang.be.domain.constant.GroupType; -import com.ggang.be.domain.constant.WeekDate; +import com.ggang.be.domain.constant.WeekDay; public record NearestGroupResponse( long groupId, Category category, GroupType groupType, String groupTitle, - WeekDate weekDay, + WeekDay weekDay, String weekDate, int currentPeopleCount, int maxPeopleCount, diff --git a/src/main/java/com/ggang/be/api/group/dto/RegisterGongbaekRequest.java b/src/main/java/com/ggang/be/api/group/dto/RegisterGongbaekRequest.java index 9ee72e2..0b2bdf2 100644 --- a/src/main/java/com/ggang/be/api/group/dto/RegisterGongbaekRequest.java +++ b/src/main/java/com/ggang/be/api/group/dto/RegisterGongbaekRequest.java @@ -2,7 +2,7 @@ import com.ggang.be.domain.constant.Category; import com.ggang.be.domain.constant.GroupType; -import com.ggang.be.domain.constant.WeekDate; +import com.ggang.be.domain.constant.WeekDay; import com.ggang.be.domain.group.dto.RegisterGroupServiceRequest; import com.ggang.be.domain.timslot.gongbaekTimeSlot.dto.GongbaekTimeSlotRequest; import com.ggang.be.domain.timslot.lectureTimeSlot.dto.LectureTimeSlotRequest; @@ -16,7 +16,7 @@ public record RegisterGongbaekRequest( GroupType groupType, @DateTimeFormat(pattern = "yyyy-MM-dd") LocalDate weekDate, - WeekDate weekDay, + WeekDay weekDay, double startTime, double endTime, Category category, @@ -34,7 +34,7 @@ public static LectureTimeSlotRequest toLectureTimeSlotRequest( userEntity, request.startTime(), request.endTime(), - WeekDate.fromDayOfWeek(request.weekDate().getDayOfWeek()) + WeekDay.fromDayOfWeek(request.weekDate().getDayOfWeek()) ); else return LectureTimeSlotRequest.of( @@ -54,7 +54,7 @@ public static GongbaekTimeSlotRequest toGongbaekTimeSlotRequest( userEntity, request.startTime(), request.endTime(), - WeekDate.fromDayOfWeek(request.weekDate().getDayOfWeek()) + WeekDay.fromDayOfWeek(request.weekDate().getDayOfWeek()) ); } else { return new GongbaekTimeSlotRequest( diff --git a/src/main/java/com/ggang/be/api/mapper/GroupResponseMapper.java b/src/main/java/com/ggang/be/api/mapper/GroupResponseMapper.java index cf3a987..9157ee8 100644 --- a/src/main/java/com/ggang/be/api/mapper/GroupResponseMapper.java +++ b/src/main/java/com/ggang/be/api/mapper/GroupResponseMapper.java @@ -43,7 +43,7 @@ public static GroupResponse fromEveryGroup(EveryGroupDto dto) { dto.introduction(), dto.category(), dto.coverImg(), - dto.gongbaekTimeSlotEntity().getWeekDate(), + dto.gongbaekTimeSlotEntity().getWeekDay(), null, dto.gongbaekTimeSlotEntity().getStartTime(), dto.gongbaekTimeSlotEntity().getEndTime() diff --git a/src/main/java/com/ggang/be/api/user/vo/TimeTableVo.java b/src/main/java/com/ggang/be/api/user/vo/TimeTableVo.java index 92a0b82..4960707 100644 --- a/src/main/java/com/ggang/be/api/user/vo/TimeTableVo.java +++ b/src/main/java/com/ggang/be/api/user/vo/TimeTableVo.java @@ -1,9 +1,9 @@ package com.ggang.be.api.user.vo; -import com.ggang.be.domain.constant.WeekDate; +import com.ggang.be.domain.constant.WeekDay; import com.ggang.be.domain.timslot.lectureTimeSlot.vo.LectureTimeSlotVo; -public record TimeTableVo(WeekDate weekDay, +public record TimeTableVo(WeekDay weekDay, Double startTime, Double endTime) { diff --git a/src/main/java/com/ggang/be/domain/constant/WeekDate.java b/src/main/java/com/ggang/be/domain/constant/WeekDay.java similarity index 77% rename from src/main/java/com/ggang/be/domain/constant/WeekDate.java rename to src/main/java/com/ggang/be/domain/constant/WeekDay.java index c8f4a59..dba8a86 100644 --- a/src/main/java/com/ggang/be/domain/constant/WeekDate.java +++ b/src/main/java/com/ggang/be/domain/constant/WeekDay.java @@ -3,7 +3,7 @@ import java.time.DayOfWeek; import java.time.LocalDate; -public enum WeekDate { +public enum WeekDay { MON, TUE, WED, @@ -12,7 +12,7 @@ public enum WeekDate { SAT, SUN; - public static WeekDate fromDayOfWeek(DayOfWeek dayOfWeek) { + public static WeekDay fromDayOfWeek(DayOfWeek dayOfWeek) { return switch (dayOfWeek) { case MONDAY -> MON; case TUESDAY -> TUE; @@ -24,8 +24,8 @@ public static WeekDate fromDayOfWeek(DayOfWeek dayOfWeek) { }; } - public static DayOfWeek getDayOfWeekFromWeekDate(WeekDate weekDate) { - return switch (weekDate) { + public static DayOfWeek getDayOfWeekFromWeekDate(WeekDay weekDay) { + return switch (weekDay) { case MON -> DayOfWeek.MONDAY; case TUE -> DayOfWeek.TUESDAY; case WED -> DayOfWeek.WEDNESDAY; @@ -36,9 +36,9 @@ public static DayOfWeek getDayOfWeekFromWeekDate(WeekDate weekDate) { }; } - public static LocalDate getNextMeetingDate(WeekDate weekDate) { + public static LocalDate getNextMeetingDate(WeekDay weekDay) { LocalDate today = LocalDate.now(); - DayOfWeek targetDay = getDayOfWeekFromWeekDate(weekDate); + DayOfWeek targetDay = getDayOfWeekFromWeekDate(weekDay); LocalDate nextMeetingDate = today; while (nextMeetingDate.getDayOfWeek() != targetDay) { diff --git a/src/main/java/com/ggang/be/domain/group/dto/GroupVo.java b/src/main/java/com/ggang/be/domain/group/dto/GroupVo.java index 5095e40..19db486 100644 --- a/src/main/java/com/ggang/be/domain/group/dto/GroupVo.java +++ b/src/main/java/com/ggang/be/domain/group/dto/GroupVo.java @@ -3,7 +3,7 @@ import com.ggang.be.domain.constant.Category; import com.ggang.be.domain.constant.GroupType; import com.ggang.be.domain.constant.Status; -import com.ggang.be.domain.constant.WeekDate; +import com.ggang.be.domain.constant.WeekDay; import com.ggang.be.domain.group.everyGroup.dto.EveryGroupVo; import com.ggang.be.domain.group.onceGroup.dto.OnceGroupVo; @@ -12,7 +12,7 @@ public record GroupVo(long groupId, Status status, Category category, int coverImg, int profileImg, String nickname, GroupType groupType, - String groupTitle, WeekDate weekDate, LocalDate groupDate, double startTime, double endTime, String location, LocalDateTime createdAt) { + String groupTitle, WeekDay weekDay, LocalDate weekDate, double startTime, double endTime, String location, LocalDateTime createdAt) { public static GroupVo fromEveryGroup(EveryGroupVo everyGroupVo) { return new GroupVo( @@ -24,7 +24,7 @@ public static GroupVo fromEveryGroup(EveryGroupVo everyGroupVo) { everyGroupVo.nickname(), GroupType.WEEKLY, everyGroupVo.groupTitle(), - everyGroupVo.weekDate(), + everyGroupVo.weekDay(), null, everyGroupVo.startTime(), everyGroupVo.endTime(), @@ -43,7 +43,7 @@ public static GroupVo fromOnceGroup(OnceGroupVo onceGroupVo) { onceGroupVo.nickname(), GroupType.ONCE, onceGroupVo.groupTitle(), - WeekDate.fromDayOfWeek(onceGroupVo.dateTime().getDayOfWeek()), + WeekDay.fromDayOfWeek(onceGroupVo.dateTime().getDayOfWeek()), onceGroupVo.dateTime(), onceGroupVo.startTime(), onceGroupVo.endTime(), diff --git a/src/main/java/com/ggang/be/domain/group/dto/RegisterGroupServiceRequest.java b/src/main/java/com/ggang/be/domain/group/dto/RegisterGroupServiceRequest.java index 193934a..1aef056 100644 --- a/src/main/java/com/ggang/be/domain/group/dto/RegisterGroupServiceRequest.java +++ b/src/main/java/com/ggang/be/domain/group/dto/RegisterGroupServiceRequest.java @@ -2,7 +2,7 @@ import com.ggang.be.domain.constant.Category; import com.ggang.be.domain.constant.GroupType; -import com.ggang.be.domain.constant.WeekDate; +import com.ggang.be.domain.constant.WeekDay; import com.ggang.be.domain.user.UserEntity; import java.time.LocalDate; @@ -11,7 +11,7 @@ public record RegisterGroupServiceRequest( UserEntity userEntity, GroupType groupType, LocalDate weekDate, - WeekDate weekDay, + WeekDay weekDay, double startTime, double endTime, Category category, diff --git a/src/main/java/com/ggang/be/domain/group/everyGroup/dto/EveryGroupVo.java b/src/main/java/com/ggang/be/domain/group/everyGroup/dto/EveryGroupVo.java index 8efe105..c195dc7 100644 --- a/src/main/java/com/ggang/be/domain/group/everyGroup/dto/EveryGroupVo.java +++ b/src/main/java/com/ggang/be/domain/group/everyGroup/dto/EveryGroupVo.java @@ -3,14 +3,14 @@ import com.ggang.be.domain.constant.Category; import com.ggang.be.domain.constant.GroupType; import com.ggang.be.domain.constant.Status; -import com.ggang.be.domain.constant.WeekDate; +import com.ggang.be.domain.constant.WeekDay; import com.ggang.be.domain.group.everyGroup.EveryGroupEntity; import java.time.LocalDateTime; public record EveryGroupVo(long groupId, Status status, Category category, int coverImg, int profileImg, String nickname, GroupType groupType, - String groupTitle, WeekDate weekDate, double startTime, double endTime, String location, LocalDateTime createdAt) { + String groupTitle, WeekDay weekDay, double startTime, double endTime, String location, LocalDateTime createdAt) { public static EveryGroupVo of(EveryGroupEntity everyGroupEntity) { return new EveryGroupVo( everyGroupEntity.getId(), @@ -21,7 +21,7 @@ public static EveryGroupVo of(EveryGroupEntity everyGroupEntity) { everyGroupEntity.getUserEntity().getNickname(), GroupType.WEEKLY, everyGroupEntity.getTitle(), - everyGroupEntity.getGongbaekTimeSlotEntity().getWeekDate(), + everyGroupEntity.getGongbaekTimeSlotEntity().getWeekDay(), everyGroupEntity.getGongbaekTimeSlotEntity().getStartTime(), everyGroupEntity.getGongbaekTimeSlotEntity().getEndTime(), everyGroupEntity.getLocation(), diff --git a/src/main/java/com/ggang/be/domain/group/everyGroup/infra/EveryGroupRepository.java b/src/main/java/com/ggang/be/domain/group/everyGroup/infra/EveryGroupRepository.java index ac6ea27..77dcf6c 100644 --- a/src/main/java/com/ggang/be/domain/group/everyGroup/infra/EveryGroupRepository.java +++ b/src/main/java/com/ggang/be/domain/group/everyGroup/infra/EveryGroupRepository.java @@ -2,7 +2,7 @@ import com.ggang.be.domain.constant.Category; import com.ggang.be.domain.constant.Status; -import com.ggang.be.domain.constant.WeekDate; +import com.ggang.be.domain.constant.WeekDay; import com.ggang.be.domain.group.everyGroup.EveryGroupEntity; import com.ggang.be.domain.user.UserEntity; import jakarta.persistence.LockModeType; @@ -18,7 +18,7 @@ public interface EveryGroupRepository extends JpaRepository 0 THEN TRUE ELSE FALSE END " + "FROM every_group o " + "WHERE o.userEntity = :userEntity " + - "AND o.gongbaekTimeSlotEntity.weekDate = :weekDate " + + "AND o.gongbaekTimeSlotEntity.weekDay = :weekDay " + "AND o.status != :status " + "AND (" + " (o.gongbaekTimeSlotEntity.startTime <= :startTime AND o.gongbaekTimeSlotEntity.endTime > :startTime) " + @@ -26,7 +26,7 @@ public interface EveryGroupRepository extends JpaRepository :startTime AND o.gongbaekTimeSlotEntity.endTime < :endTime)" + ")") boolean isInTime(UserEntity userEntity, double startTime, double endTime, - WeekDate weekDate, Status status); + WeekDay weekDay, Status status); @Lock(LockModeType.PESSIMISTIC_WRITE) @Query("select o from every_group o join fetch o.gongbaekTimeSlotEntity where o.status!=:status") diff --git a/src/main/java/com/ggang/be/domain/group/onceGroup/dto/OnceGroupDto.java b/src/main/java/com/ggang/be/domain/group/onceGroup/dto/OnceGroupDto.java index 4112af9..4a743bc 100644 --- a/src/main/java/com/ggang/be/domain/group/onceGroup/dto/OnceGroupDto.java +++ b/src/main/java/com/ggang/be/domain/group/onceGroup/dto/OnceGroupDto.java @@ -2,7 +2,7 @@ import com.ggang.be.domain.constant.Category; import com.ggang.be.domain.constant.Status; -import com.ggang.be.domain.constant.WeekDate; +import com.ggang.be.domain.constant.WeekDay; import com.ggang.be.domain.group.onceGroup.OnceGroupEntity; import com.ggang.be.domain.timslot.gongbaekTimeSlot.GongbaekTimeSlotEntity; import com.ggang.be.domain.user.UserEntity; @@ -19,7 +19,7 @@ public record OnceGroupDto( String introduction, Category category, int coverImg, - WeekDate weekDay, + WeekDay weekDay, String weekDate, GongbaekTimeSlotEntity gongbaekTimeSlotEntity ) { @@ -37,12 +37,12 @@ public static OnceGroupDto toDto(OnceGroupEntity entity, UserEntity currentUser) entity.getIntroduction(), entity.getCategory(), entity.getCoverImg(), - WeekDate.fromDayOfWeek(entity.getGroupDate().getDayOfWeek()), + WeekDay.fromDayOfWeek(entity.getGroupDate().getDayOfWeek()), entity.getGroupDate().toString(), GongbaekTimeSlotEntity.builder() .startTime(entity.getGongbaekTimeSlotEntity().getStartTime()) .endTime(entity.getGongbaekTimeSlotEntity().getEndTime()) - .weekDate(WeekDate.fromDayOfWeek(entity.getGroupDate().getDayOfWeek())) + .weekDay(WeekDay.fromDayOfWeek(entity.getGroupDate().getDayOfWeek())) .userEntity(currentUser) .build() ); diff --git a/src/main/java/com/ggang/be/domain/group/vo/NearestGroup.java b/src/main/java/com/ggang/be/domain/group/vo/NearestGroup.java index 48a65f9..3384242 100644 --- a/src/main/java/com/ggang/be/domain/group/vo/NearestGroup.java +++ b/src/main/java/com/ggang/be/domain/group/vo/NearestGroup.java @@ -2,7 +2,7 @@ import com.ggang.be.domain.constant.Category; import com.ggang.be.domain.constant.GroupType; -import com.ggang.be.domain.constant.WeekDate; +import com.ggang.be.domain.constant.WeekDay; import com.ggang.be.domain.group.everyGroup.EveryGroupEntity; import com.ggang.be.domain.group.onceGroup.OnceGroupEntity; import java.time.LocalDate; @@ -11,7 +11,7 @@ public record NearestGroup(long groupId, Category category, GroupType groupType, String groupTitle, - WeekDate weekDay, + WeekDay weekDay, LocalDate weekDate, int currentPeopleCount, int maxPeopleCount, @@ -25,8 +25,8 @@ public static NearestGroup fromEveryEntity(EveryGroupEntity entity){ entity.getCategory(), GroupType.WEEKLY, entity.getTitle(), - entity.getGongbaekTimeSlotEntity().getWeekDate(), - WeekDate.getNextMeetingDate(entity.getGongbaekTimeSlotEntity().getWeekDate()), + entity.getGongbaekTimeSlotEntity().getWeekDay(), + WeekDay.getNextMeetingDate(entity.getGongbaekTimeSlotEntity().getWeekDay()), entity.getCurrentPeopleCount(), entity.getMaxPeopleCount(), entity.getGongbaekTimeSlotEntity().getStartTime(), @@ -41,7 +41,7 @@ public static NearestGroup fromOnceEntity(OnceGroupEntity entity){ entity.getCategory(), GroupType.ONCE, entity.getTitle(), - WeekDate.fromDayOfWeek(entity.getGroupDate().getDayOfWeek()), + WeekDay.fromDayOfWeek(entity.getGroupDate().getDayOfWeek()), entity.getGroupDate(), entity.getCurrentPeopleCount(), entity.getMaxPeopleCount(), diff --git a/src/main/java/com/ggang/be/domain/timslot/ReadCommonInvalidTimeVoMaker.java b/src/main/java/com/ggang/be/domain/timslot/ReadCommonInvalidTimeVoMaker.java index b8bda53..9524ebe 100644 --- a/src/main/java/com/ggang/be/domain/timslot/ReadCommonInvalidTimeVoMaker.java +++ b/src/main/java/com/ggang/be/domain/timslot/ReadCommonInvalidTimeVoMaker.java @@ -2,24 +2,22 @@ import com.ggang.be.domain.timslot.lectureTimeSlot.LectureTimeSlotEntity; import com.ggang.be.domain.timslot.vo.ReadCommonInvalidTimeVo; -import org.springframework.stereotype.Component; import java.util.Comparator; import java.util.List; import java.util.concurrent.atomic.AtomicInteger; -@Component public class ReadCommonInvalidTimeVoMaker { - public List convertToCommonResponse( + public static List convertToCommonResponse( List lectureTimeSlotEntities) { AtomicInteger atomicInteger = new AtomicInteger(0); return lectureTimeSlotEntities.stream() - .sorted(Comparator.comparing(LectureTimeSlotEntity::getWeekDate)) + .sorted(Comparator.comparing(LectureTimeSlotEntity::getWeekDay)) .map(entity -> makeReadCommonInvalidTimeVo(entity, atomicInteger)) .sorted(Comparator.comparing(ReadCommonInvalidTimeVo::idx)).toList(); } - private ReadCommonInvalidTimeVo makeReadCommonInvalidTimeVo(LectureTimeSlotEntity entity, + public static ReadCommonInvalidTimeVo makeReadCommonInvalidTimeVo(LectureTimeSlotEntity entity, AtomicInteger atomicInteger) { return ReadCommonInvalidTimeVo.fromLectureEntity(atomicInteger.getAndIncrement(), entity); diff --git a/src/main/java/com/ggang/be/domain/timslot/gongbaekTimeSlot/GongbaekTimeSlotEntity.java b/src/main/java/com/ggang/be/domain/timslot/gongbaekTimeSlot/GongbaekTimeSlotEntity.java index 31e9fe4..d2a7215 100644 --- a/src/main/java/com/ggang/be/domain/timslot/gongbaekTimeSlot/GongbaekTimeSlotEntity.java +++ b/src/main/java/com/ggang/be/domain/timslot/gongbaekTimeSlot/GongbaekTimeSlotEntity.java @@ -1,7 +1,7 @@ package com.ggang.be.domain.timslot.gongbaekTimeSlot; import com.ggang.be.domain.BaseTimeEntity; -import com.ggang.be.domain.constant.WeekDate; +import com.ggang.be.domain.constant.WeekDay; import com.ggang.be.domain.user.UserEntity; import jakarta.persistence.*; import lombok.AccessLevel; @@ -19,7 +19,7 @@ public class GongbaekTimeSlotEntity extends BaseTimeEntity { @Column(nullable = false) @Enumerated(EnumType.STRING) - private WeekDate weekDate; + private WeekDay weekDay; private double startTime; private double endTime; @@ -30,9 +30,9 @@ public class GongbaekTimeSlotEntity extends BaseTimeEntity { @Builder private GongbaekTimeSlotEntity( - WeekDate weekDate, double startTime, double endTime, UserEntity userEntity + WeekDay weekDay, double startTime, double endTime, UserEntity userEntity ) { - this.weekDate = weekDate; + this.weekDay = weekDay; this.startTime = startTime; this.endTime = endTime; this.userEntity = userEntity; diff --git a/src/main/java/com/ggang/be/domain/timslot/gongbaekTimeSlot/application/GongbaekTimeSlotServiceImpl.java b/src/main/java/com/ggang/be/domain/timslot/gongbaekTimeSlot/application/GongbaekTimeSlotServiceImpl.java index 232d3e0..9a5aa3b 100644 --- a/src/main/java/com/ggang/be/domain/timslot/gongbaekTimeSlot/application/GongbaekTimeSlotServiceImpl.java +++ b/src/main/java/com/ggang/be/domain/timslot/gongbaekTimeSlot/application/GongbaekTimeSlotServiceImpl.java @@ -24,7 +24,7 @@ public GongbaekTimeSlotEntity registerGongbaekTimeSlot(UserEntity userEntity, Go .userEntity(userEntity) .startTime(dto.startTime()) .endTime(dto.endTime()) - .weekDate(dto.weekDay()) + .weekDay(dto.weekDay()) .build(); return gongbaekTimeSlotRepository.save(buildEntity); diff --git a/src/main/java/com/ggang/be/domain/timslot/gongbaekTimeSlot/dto/GongbaekTimeSlotRequest.java b/src/main/java/com/ggang/be/domain/timslot/gongbaekTimeSlot/dto/GongbaekTimeSlotRequest.java index 75ba866..740ba2d 100644 --- a/src/main/java/com/ggang/be/domain/timslot/gongbaekTimeSlot/dto/GongbaekTimeSlotRequest.java +++ b/src/main/java/com/ggang/be/domain/timslot/gongbaekTimeSlot/dto/GongbaekTimeSlotRequest.java @@ -1,7 +1,7 @@ package com.ggang.be.domain.timslot.gongbaekTimeSlot.dto; -import com.ggang.be.domain.constant.WeekDate; +import com.ggang.be.domain.constant.WeekDay; import com.ggang.be.domain.user.UserEntity; -public record GongbaekTimeSlotRequest(UserEntity userEntity, double startTime, double endTime, WeekDate weekDay) { +public record GongbaekTimeSlotRequest(UserEntity userEntity, double startTime, double endTime, WeekDay weekDay) { } diff --git a/src/main/java/com/ggang/be/domain/timslot/lectureTimeSlot/LectureTimeSlotEntity.java b/src/main/java/com/ggang/be/domain/timslot/lectureTimeSlot/LectureTimeSlotEntity.java index fcebb59..7185f5a 100644 --- a/src/main/java/com/ggang/be/domain/timslot/lectureTimeSlot/LectureTimeSlotEntity.java +++ b/src/main/java/com/ggang/be/domain/timslot/lectureTimeSlot/LectureTimeSlotEntity.java @@ -2,7 +2,7 @@ import com.ggang.be.domain.BaseTimeEntity; -import com.ggang.be.domain.constant.WeekDate; +import com.ggang.be.domain.constant.WeekDay; import com.ggang.be.domain.user.UserEntity; import jakarta.persistence.*; import lombok.AccessLevel; @@ -20,7 +20,7 @@ public class LectureTimeSlotEntity extends BaseTimeEntity { @Column(nullable = false) @Enumerated(value = EnumType.STRING) - private WeekDate weekDate; + private WeekDay weekDay; private double startTime; private double endTime; @@ -30,9 +30,9 @@ public class LectureTimeSlotEntity extends BaseTimeEntity { private UserEntity userEntity; @Builder - private LectureTimeSlotEntity(WeekDate weekDate, double startTime, double endTime, + private LectureTimeSlotEntity(WeekDay weekDay, double startTime, double endTime, UserEntity userEntity) { - this.weekDate = weekDate; + this.weekDay = weekDay; this.startTime = startTime; this.endTime = endTime; this.userEntity = userEntity; diff --git a/src/main/java/com/ggang/be/domain/timslot/lectureTimeSlot/application/LectureTimeSlotServiceImpl.java b/src/main/java/com/ggang/be/domain/timslot/lectureTimeSlot/application/LectureTimeSlotServiceImpl.java index 6c12ef4..4fa6bae 100644 --- a/src/main/java/com/ggang/be/domain/timslot/lectureTimeSlot/application/LectureTimeSlotServiceImpl.java +++ b/src/main/java/com/ggang/be/domain/timslot/lectureTimeSlot/application/LectureTimeSlotServiceImpl.java @@ -32,7 +32,7 @@ public void saveLectureTimeSlot(List timeTableVos, UserEntity @Override public void isExistInLectureTImeSlot(UserEntity findUserEntity, LectureTimeSlotRequest dto) { if(lectureTimeSlotRepository.isInTime( - dto.startTime(), dto.endTime(), findUserEntity, dto.weekDate() + dto.startTime(), dto.endTime(), findUserEntity, dto.weekDay() )) throw new GongBaekException(ResponseError.TIME_SLOT_ALREADY_EXIST); } @@ -43,7 +43,7 @@ public boolean isActiveGroupsInLectureTimeSlot(UserEntity findUserEntity, GroupV groupVo.startTime(), groupVo.endTime(), findUserEntity, - groupVo.weekDate()); + groupVo.weekDay()); } @Override diff --git a/src/main/java/com/ggang/be/domain/timslot/lectureTimeSlot/dto/LectureTimeSlotRequest.java b/src/main/java/com/ggang/be/domain/timslot/lectureTimeSlot/dto/LectureTimeSlotRequest.java index 78f4325..49007f3 100644 --- a/src/main/java/com/ggang/be/domain/timslot/lectureTimeSlot/dto/LectureTimeSlotRequest.java +++ b/src/main/java/com/ggang/be/domain/timslot/lectureTimeSlot/dto/LectureTimeSlotRequest.java @@ -1,11 +1,11 @@ package com.ggang.be.domain.timslot.lectureTimeSlot.dto; -import com.ggang.be.domain.constant.WeekDate; +import com.ggang.be.domain.constant.WeekDay; import com.ggang.be.domain.user.UserEntity; -public record LectureTimeSlotRequest(UserEntity userEntity, double startTime, double endTime, WeekDate weekDate) { +public record LectureTimeSlotRequest(UserEntity userEntity, double startTime, double endTime, WeekDay weekDay) { - public static LectureTimeSlotRequest of(UserEntity userEntity, double startTime, double endTime, WeekDate weekDate) { - return new LectureTimeSlotRequest(userEntity, startTime, endTime, weekDate); + public static LectureTimeSlotRequest of(UserEntity userEntity, double startTime, double endTime, WeekDay weekDay) { + return new LectureTimeSlotRequest(userEntity, startTime, endTime, weekDay); } } diff --git a/src/main/java/com/ggang/be/domain/timslot/lectureTimeSlot/infra/LectureTimeSlotRepository.java b/src/main/java/com/ggang/be/domain/timslot/lectureTimeSlot/infra/LectureTimeSlotRepository.java index 76bf23e..ce74fd4 100644 --- a/src/main/java/com/ggang/be/domain/timslot/lectureTimeSlot/infra/LectureTimeSlotRepository.java +++ b/src/main/java/com/ggang/be/domain/timslot/lectureTimeSlot/infra/LectureTimeSlotRepository.java @@ -1,6 +1,6 @@ package com.ggang.be.domain.timslot.lectureTimeSlot.infra; -import com.ggang.be.domain.constant.WeekDate; +import com.ggang.be.domain.constant.WeekDay; import com.ggang.be.domain.timslot.lectureTimeSlot.LectureTimeSlotEntity; import com.ggang.be.domain.user.UserEntity; import org.springframework.data.jpa.repository.JpaRepository; @@ -13,13 +13,13 @@ public interface LectureTimeSlotRepository extends JpaRepository 0 THEN TRUE ELSE FALSE END " + "FROM lecture_time_slot l " + "WHERE l.userEntity = :userEntity " + - "AND l.weekDate = :weekDate " + + "AND l.weekDay = :weekDay " + "AND (" + " (l.startTime <= :startTime AND l.endTime > :startTime) " + " OR (l.startTime < :endTime AND l.endTime >= :endTime) " + " OR (l.startTime > :startTime AND l.endTime < :endTime)" + ")") - boolean isInTime(double startTime, double endTime, UserEntity userEntity, WeekDate weekDate); + boolean isInTime(double startTime, double endTime, UserEntity userEntity, WeekDay weekDay); List findAllByUserEntity(UserEntity userEntity); } diff --git a/src/main/java/com/ggang/be/domain/timslot/lectureTimeSlot/vo/LectureTimeSlotVo.java b/src/main/java/com/ggang/be/domain/timslot/lectureTimeSlot/vo/LectureTimeSlotVo.java index 698f822..d78c495 100644 --- a/src/main/java/com/ggang/be/domain/timslot/lectureTimeSlot/vo/LectureTimeSlotVo.java +++ b/src/main/java/com/ggang/be/domain/timslot/lectureTimeSlot/vo/LectureTimeSlotVo.java @@ -1,14 +1,14 @@ package com.ggang.be.domain.timslot.lectureTimeSlot.vo; -import com.ggang.be.domain.constant.WeekDate; +import com.ggang.be.domain.constant.WeekDay; import com.ggang.be.domain.timslot.lectureTimeSlot.LectureTimeSlotEntity; import com.ggang.be.domain.user.UserEntity; -public record LectureTimeSlotVo(WeekDate weekDate, Double startTime, Double endTime) { +public record LectureTimeSlotVo(WeekDay weekDay, Double startTime, Double endTime) { public static LectureTimeSlotEntity toEntity(LectureTimeSlotVo lectureTimeSlotVo, UserEntity userEntity) { return LectureTimeSlotEntity.builder(). - weekDate(lectureTimeSlotVo.weekDate()). + weekDay(lectureTimeSlotVo.weekDay()). startTime(lectureTimeSlotVo.startTime()). endTime(lectureTimeSlotVo.endTime()). userEntity(userEntity). diff --git a/src/main/java/com/ggang/be/domain/timslot/vo/ReadCommonInvalidTimeVo.java b/src/main/java/com/ggang/be/domain/timslot/vo/ReadCommonInvalidTimeVo.java index f679890..9e343a5 100644 --- a/src/main/java/com/ggang/be/domain/timslot/vo/ReadCommonInvalidTimeVo.java +++ b/src/main/java/com/ggang/be/domain/timslot/vo/ReadCommonInvalidTimeVo.java @@ -1,18 +1,18 @@ package com.ggang.be.domain.timslot.vo; -import com.ggang.be.domain.constant.WeekDate; +import com.ggang.be.domain.constant.WeekDay; import com.ggang.be.domain.timslot.lectureTimeSlot.LectureTimeSlotEntity; public record ReadCommonInvalidTimeVo( int idx, - WeekDate weekDate, + WeekDay weekDay, double startTime, double endTime ) { public static ReadCommonInvalidTimeVo fromLectureEntity( int idx, LectureTimeSlotEntity lectureTimeSlotEntity) { - return new ReadCommonInvalidTimeVo(idx, lectureTimeSlotEntity.getWeekDate(), + return new ReadCommonInvalidTimeVo(idx, lectureTimeSlotEntity.getWeekDay(), lectureTimeSlotEntity.getStartTime(), lectureTimeSlotEntity.getEndTime()); } } diff --git a/src/main/java/com/ggang/be/domain/userEveryGroup/application/UserEveryGroupServiceImpl.java b/src/main/java/com/ggang/be/domain/userEveryGroup/application/UserEveryGroupServiceImpl.java index 04434c7..6ff76e4 100644 --- a/src/main/java/com/ggang/be/domain/userEveryGroup/application/UserEveryGroupServiceImpl.java +++ b/src/main/java/com/ggang/be/domain/userEveryGroup/application/UserEveryGroupServiceImpl.java @@ -5,7 +5,7 @@ import com.ggang.be.api.exception.GongBaekException; import com.ggang.be.domain.group.vo.NearestGroup; import com.ggang.be.api.userEveryGroup.service.UserEveryGroupService; -import com.ggang.be.domain.constant.WeekDate; +import com.ggang.be.domain.constant.WeekDay; import com.ggang.be.domain.group.GroupVoMaker; import com.ggang.be.domain.group.dto.ReadEveryGroupMember; import com.ggang.be.domain.group.everyGroup.EveryGroupEntity; @@ -105,7 +105,7 @@ public void isValidCommentAccess(UserEntity userEntity, final long groupId) { private EveryGroupEntity getNearestGroup(List groups) { return groups.stream() - .min(Comparator.comparing(group -> WeekDate.getNextMeetingDate(group.getGongbaekTimeSlotEntity().getWeekDate()))) + .min(Comparator.comparing(group -> WeekDay.getNextMeetingDate(group.getGongbaekTimeSlotEntity().getWeekDay()))) .orElse(null); } diff --git a/src/main/java/com/ggang/be/global/util/TimeValidator.java b/src/main/java/com/ggang/be/global/util/TimeValidator.java index 21b3d9c..6467dcd 100644 --- a/src/main/java/com/ggang/be/global/util/TimeValidator.java +++ b/src/main/java/com/ggang/be/global/util/TimeValidator.java @@ -2,16 +2,16 @@ import com.ggang.be.api.common.ResponseError; import com.ggang.be.api.exception.GongBaekException; -import com.ggang.be.domain.constant.WeekDate; +import com.ggang.be.domain.constant.WeekDay; import lombok.extern.slf4j.Slf4j; import java.time.LocalDate; @Slf4j public class TimeValidator { - public static void isWeekDateRight(WeekDate writeWeekDate, LocalDate writeDate) { - WeekDate realWeekDate = WeekDate.fromDayOfWeek(writeDate.getDayOfWeek()); - if(!realWeekDate.equals(writeWeekDate)) { + public static void isWeekDateRight(WeekDay writeWeekDay, LocalDate writeDate) { + WeekDay realWeekDay = WeekDay.fromDayOfWeek(writeDate.getDayOfWeek()); + if(!realWeekDay.equals(writeWeekDay)) { log.error("weekDate and weekDay is not same"); throw new GongBaekException(ResponseError.BAD_REQUEST); } diff --git a/src/test/java/com/ggang/be/domain/gongbaekTImeSlot/GongbaekTimeSlotFixture.java b/src/test/java/com/ggang/be/domain/gongbaekTImeSlot/GongbaekTimeSlotFixture.java index 6bbe6cc..80bed54 100644 --- a/src/test/java/com/ggang/be/domain/gongbaekTImeSlot/GongbaekTimeSlotFixture.java +++ b/src/test/java/com/ggang/be/domain/gongbaekTImeSlot/GongbaekTimeSlotFixture.java @@ -1,6 +1,6 @@ package com.ggang.be.domain.gongbaekTImeSlot; -import com.ggang.be.domain.constant.WeekDate; +import com.ggang.be.domain.constant.WeekDay; import com.ggang.be.domain.timslot.gongbaekTimeSlot.GongbaekTimeSlotEntity; public class GongbaekTimeSlotFixture { @@ -9,7 +9,7 @@ public static GongbaekTimeSlotEntity getTestGongbaekTimeSlot() { return GongbaekTimeSlotEntity.builder() .startTime(10) .endTime(12) - .weekDate(WeekDate.MON) + .weekDay(WeekDay.MON) .build(); } diff --git a/src/test/java/com/ggang/be/domain/lectureTimeSlot/application/LectureTimeSlotServiceImplTest.java b/src/test/java/com/ggang/be/domain/lectureTimeSlot/application/LectureTimeSlotServiceImplTest.java index bc7c2db..c9e458a 100644 --- a/src/test/java/com/ggang/be/domain/lectureTimeSlot/application/LectureTimeSlotServiceImplTest.java +++ b/src/test/java/com/ggang/be/domain/lectureTimeSlot/application/LectureTimeSlotServiceImplTest.java @@ -6,7 +6,7 @@ import com.ggang.be.domain.constant.Gender; import com.ggang.be.domain.constant.Mbti; -import com.ggang.be.domain.constant.WeekDate; +import com.ggang.be.domain.constant.WeekDay; import com.ggang.be.domain.lectureTimeSlot.fixture.LectureTimeSlotFixture; import com.ggang.be.domain.timslot.lectureTimeSlot.LectureTimeSlotEntity; import com.ggang.be.domain.timslot.lectureTimeSlot.application.LectureTimeSlotServiceImpl; @@ -53,9 +53,9 @@ void saveLectureTimeSlot() { .build(); List lectureTimeSlotVos = List.of( - new LectureTimeSlotVo(WeekDate.MON, 9.0, 10.5), - new LectureTimeSlotVo(WeekDate.WED, 14.0, 15.5), - new LectureTimeSlotVo(WeekDate.FRI, 16.0, 17.0) + new LectureTimeSlotVo(WeekDay.MON, 9.0, 10.5), + new LectureTimeSlotVo(WeekDay.WED, 14.0, 15.5), + new LectureTimeSlotVo(WeekDay.FRI, 16.0, 17.0) ); List list = lectureTimeSlotVos.stream() diff --git a/src/test/java/com/ggang/be/domain/lectureTimeSlot/fixture/LectureTimeSlotFixture.java b/src/test/java/com/ggang/be/domain/lectureTimeSlot/fixture/LectureTimeSlotFixture.java index fbdf38b..8aa4c51 100644 --- a/src/test/java/com/ggang/be/domain/lectureTimeSlot/fixture/LectureTimeSlotFixture.java +++ b/src/test/java/com/ggang/be/domain/lectureTimeSlot/fixture/LectureTimeSlotFixture.java @@ -1,6 +1,6 @@ package com.ggang.be.domain.lectureTimeSlot.fixture; -import com.ggang.be.domain.constant.WeekDate; +import com.ggang.be.domain.constant.WeekDay; import com.ggang.be.domain.timslot.lectureTimeSlot.LectureTimeSlotEntity; import com.ggang.be.domain.user.fixture.UserEntityFixture; @@ -8,7 +8,7 @@ public class LectureTimeSlotFixture { public static LectureTimeSlotEntity makeLectureTimeSlotEntity() { return LectureTimeSlotEntity.builder() - .weekDate(WeekDate.MON) + .weekDay(WeekDay.MON) .startTime(9.0) .endTime(10.0) .userEntity(UserEntityFixture.create())