Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
seonwoo-jung committed Jun 12, 2024
2 parents 4e172b7 + d04e6f1 commit 9297806
Show file tree
Hide file tree
Showing 13 changed files with 79 additions and 45 deletions.
2 changes: 1 addition & 1 deletion src/main/java/com/tobe/healthy/config/error/ErrorCode.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public enum ErrorCode {
DATETIME_NOT_VALID(BAD_REQUEST, "C_026", "시작날짜와 종료날짜가 유효하지 않습니다."),
COURSE_ALREADY_EXISTS(BAD_REQUEST, "C_027", "잔여 수강권이 존재합니다."),
COURSE_NOT_FOUND(NOT_FOUND, "C_028", "수강권이 존재하지 않습니다."),
COURSE_IS_USING(BAD_REQUEST, "C_029", "사용중인 수강권은 삭제할 수 없습니다."),
COURSE_IS_USING(BAD_REQUEST, "C_029", "진행중이거나 만료된 수강권은 삭제할 수 없습니다."),
LESSON_CNT_NOT_VALID(BAD_REQUEST, "C_030", "수강권 횟수가 유효하지 않습니다."),
LIKE_ALREADY_EXISTS(BAD_REQUEST, "C_031", "이미 좋아요 하였습니다."),
DATE_NOT_VALID(BAD_REQUEST, "C_032", "날짜가 유효하지 않습니다."),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,12 +77,14 @@ private BooleanExpression courseTrainerIdEq(Long trainerId) {
}

private BooleanExpression convertDateFormat(String searchDate) {
if (ObjectUtils.isEmpty(searchDate)) return null;
StringTemplate stringTemplate = Expressions.stringTemplate(
"DATE_FORMAT({0}, {1})"
, courseHistory.createdAt
, ConstantImpl.create("%Y-%m"));
return stringTemplate.eq(searchDate);
if (!ObjectUtils.isEmpty(searchDate)){
StringTemplate stringTemplate = Expressions.stringTemplate(
"DATE_FORMAT({0}, {1})"
, courseHistory.createdAt
, ConstantImpl.create("%Y-%m"));
return stringTemplate.eq(searchDate);
}
return null;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -171,8 +171,8 @@ public void deleteDiet(Member member, Long dietId) {
}

public DietDto addDiet(Member member, DietAddCommand command) {
DietUploadDaysResult result = getDietUploadDays(member.getId(), null, null);
if(result.getUploadDays().contains(command.getEatDate())) throw new CustomException(DIET_ALREADY_EXISTS);
List<String> uploadDays = dietRepository.getDietUploadDays(member.getId(), null, null);
if(uploadDays.contains(command.getEatDate())) throw new CustomException(DIET_ALREADY_EXISTS);

TrainerMemberMapping mapping = mappingRepository.findTop1ByMemberIdOrderByCreatedAtDesc(member.getId()).orElse(null);
Member trainer = mapping == null ? null : mapping.getTrainer();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,9 +147,6 @@ public void resetPassword(String password) {
}

public void registerGym(Gym gym) {
if (this.gym == gym) {
throw new CustomException(UNCHANGED_GYM_ID);
}
this.gym = gym;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,10 @@ public MemberDetailResult getMemberOfTrainer(Long memberId) {
}

private BooleanExpression scheduleReservationStatusEq(ReservationStatus status) {
return schedule.reservationStatus.eq(status);
if(!ObjectUtils.isEmpty(status)){
return schedule.reservationStatus.eq(status);
}
return null;
}

@Override
Expand Down Expand Up @@ -204,19 +207,31 @@ private OrderSpecifier sortBy(String sortValue) {
}

private BooleanExpression memberDelYnEq(boolean bool) {
return member.delYn.eq(bool);
if(!ObjectUtils.isEmpty(bool)){
return member.delYn.eq(bool);
}
return null;
}

private BooleanExpression mappingTrainerIdEq(Long trainerId) {
return trainerMemberMapping.trainer.id.eq(trainerId);
if(!ObjectUtils.isEmpty(trainerId)){
return trainerMemberMapping.trainer.id.eq(trainerId);
}
return null;
}

private BooleanExpression memberTypeEq(MemberType memberType) {
return member.memberType.eq(memberType);
if(!ObjectUtils.isEmpty(memberType)){
return member.memberType.eq(memberType);
}
return null;
}

private BooleanExpression memberGymIdEq(Long gymId) {
return member.gym.id.eq(gymId);
if(!ObjectUtils.isEmpty(gymId)){
return member.gym.id.eq(gymId);
}
return null;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -43,16 +43,21 @@ public Page<Point> getPoint(Long memberId, String searchDate, Pageable pageable)
}

private BooleanExpression pointMemberIdEq(Long memberId) {
return point1.member.id.eq(memberId);
if(!ObjectUtils.isEmpty(memberId)){
return point1.member.id.eq(memberId);
}
return null;
}

private BooleanExpression convertDateFormat(String searchDate) {
if (ObjectUtils.isEmpty(searchDate)) return null;
StringTemplate stringTemplate = Expressions.stringTemplate(
"DATE_FORMAT({0}, {1})"
, point1.createdAt
, ConstantImpl.create("%Y-%m"));
return stringTemplate.eq(searchDate);
if (!ObjectUtils.isEmpty(searchDate)){
StringTemplate stringTemplate = Expressions.stringTemplate(
"DATE_FORMAT({0}, {1})"
, point1.createdAt
, ConstantImpl.create("%Y-%m"));
return stringTemplate.eq(searchDate);
}
return null;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ public String registerScheduleWaiting(Long scheduleId, Long memberId) {

CourseDto usingCourse = courseService.getNowUsingCourse(memberId);
if(usingCourse == null) throw new CustomException(COURSE_NOT_FOUND);
if(usingCourse.getRemainLessonCnt()==0) throw new CustomException(LESSON_CNT_NOT_VALID);

LocalDateTime lessonDateTime = LocalDateTime.of(findSchedule.getLessonDt(), findSchedule.getLessonStartTime());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,11 +137,17 @@ private BooleanExpression lessonDtEq(StudentScheduleCond searchCond) {
}

private BooleanExpression scheduleTrainerIdEq(Long trainerId) {
return schedule.trainer.id.eq(trainerId);
if(!ObjectUtils.isEmpty(trainerId)){
return schedule.trainer.id.eq(trainerId);
}
return null;
}

private BooleanExpression scheduleApplicantIdEq(Long memberId) {
return schedule.applicant.id.eq(memberId);
if(!ObjectUtils.isEmpty(memberId)){
return schedule.applicant.id.eq(memberId);
}
return null;
}

private Predicate courseIdEq(StudentScheduleCond searchCond) {
Expand All @@ -152,11 +158,13 @@ private Predicate courseIdEq(StudentScheduleCond searchCond) {
}

private BooleanExpression convertDateFormat(String searchDate) {
if (ObjectUtils.isEmpty(searchDate)) return null;
StringTemplate stringTemplate = Expressions.stringTemplate(
"DATE_FORMAT({0}, {1})"
, schedule.lessonDt
, ConstantImpl.create("%Y-%m"));
return stringTemplate.eq(searchDate);
if (!ObjectUtils.isEmpty(searchDate)){
StringTemplate stringTemplate = Expressions.stringTemplate(
"DATE_FORMAT({0}, {1})"
, schedule.lessonDt
, ConstantImpl.create("%Y-%m"));
return stringTemplate.eq(searchDate);
}
return null;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Repository;
import org.springframework.util.ObjectUtils;

import java.time.LocalDate;
import java.time.LocalTime;
Expand Down Expand Up @@ -40,7 +41,10 @@ public List<MyScheduleWaiting> findAllMyScheduleWaiting(Long memberId) {
}

private BooleanExpression scheduleWaitingMemberIdEq(Long memberId) {
return scheduleWaiting.member.id.eq(memberId);
if(!ObjectUtils.isEmpty(memberId)){
return scheduleWaiting.member.id.eq(memberId);
}
return null;
}

private Predicate lessonDateTimeAfterYesterday() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -159,14 +159,13 @@ public void deleteStudentOfTrainer(Member trainer, Long memberId) {
CourseDto courseDto = courseService.getNowUsingCourse(memberId);

//수강권 횟수가 남아있는 경우 삭제 불가
if(courseDto != null){
if(isRemainLessonCnt(courseDto)) throw new CustomException(COURSE_ALREADY_EXISTS);
courseService.deleteCourse(trainer.getId(), courseDto.getCourseId());
if(courseDto != null && isRemainLessonCnt(courseDto)){
throw new CustomException(COURSE_ALREADY_EXISTS);
}
mappingRepository.deleteByTrainerIdAndMemberId(trainer.getId(), member.getId());
}

private boolean isRemainLessonCnt(CourseDto courseDto){
return courseDto.getCompletedLessonCnt()<courseDto.getTotalLessonCnt();
return courseDto.getCompletedLessonCnt() != courseDto.getTotalLessonCnt();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -174,12 +174,14 @@ private BooleanExpression historyFileDeYnEq(boolean bool) {
}

private BooleanExpression convertDateFormat(String searchDate) {
if (ObjectUtils.isEmpty(searchDate)) return null;
StringTemplate stringTemplate = Expressions.stringTemplate(
"DATE_FORMAT({0}, {1})"
, workoutHistory.createdAt
, ConstantImpl.create("%Y-%m"));
return stringTemplate.eq(searchDate);
if (!ObjectUtils.isEmpty(searchDate)) {
StringTemplate stringTemplate = Expressions.stringTemplate(
"DATE_FORMAT({0}, {1})"
, workoutHistory.createdAt
, ConstantImpl.create("%Y-%m"));
return stringTemplate.eq(searchDate);
}
return null;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@ class LessonHistoryCommentRepositoryImpl(
.from(lessonHistoryComment)
.where(
lessonHistoryIdEq(lessonHistoryId),
parentCommentIdIsNull(),
lessonHistoryComment.delYn.eq(false)
parentCommentIdIsNull()
)
.fetchOne() ?: 1
return result
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ class LessonHistoryRepositoryImpl(
.orderBy(lessonHistory.id.desc())
.offset(pageable.offset)
.limit(pageable.pageSize.toLong())
.orderBy(lessonHistory.id.desc())
.fetch()

val totalCount = queryFactory
Expand Down Expand Up @@ -169,6 +170,7 @@ class LessonHistoryRepositoryImpl(
)
.offset(pageable.offset)
.limit(pageable.pageSize.toLong())
.orderBy(lessonHistory.id.desc())
.fetch()

val totalCount = queryFactory
Expand Down

0 comments on commit 9297806

Please sign in to comment.