Skip to content

Commit

Permalink
Fix: 과릿 1.1.7 (#339)
Browse files Browse the repository at this point in the history
* Fix: Homework 정보 반환 시, 클래스 색상 사용자 지정 색으로 반환되도록 수정 (#336)

* Fix: 학생 초대 시, FCM 토큰 없이도 초대되도록 수정 (#337)
  • Loading branch information
dl-00-e8 authored Nov 20, 2023
1 parent 3431f1a commit 906c3a9
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public interface HomeworkRepositoryCustom {

Optional<List<HomeworkMainRes>> findAllHomeworkByMemberAndType(Member member, Boolean type);

HomeworkMainRes findHomeworkByHomeworkId(Long homeworkId);
HomeworkMainRes findHomeworkByHomeworkId(Member member, Long homeworkId);

Optional<List<HomeworkMainRes>> findAllHomeworkByMemberAndLectureId(Member member, Long lectureId);

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.selfrunner.gwalit.domain.homework.repository;

import com.querydsl.core.types.Projections;
import com.querydsl.core.types.dsl.CaseBuilder;
import com.querydsl.jpa.impl.JPAQueryFactory;
import com.selfrunner.gwalit.domain.homework.dto.response.HomeworkMainRes;
import com.selfrunner.gwalit.domain.homework.dto.response.HomeworkRes;
Expand Down Expand Up @@ -56,9 +57,12 @@ public Optional<List<HomeworkMainRes>> findRecentHomeworkByMemberAndLessonIdList
return Optional.ofNullable(
queryFactory.selectFrom(homework)
.leftJoin(lesson).on(lesson.lessonId.eq(homework.lessonId))
.leftJoin(lecture).on(lecture.lectureId.eq(lesson.lecture.lectureId))
.leftJoin(memberAndLecture).on(memberAndLecture.lecture.lectureId.eq(lesson.lecture.lectureId))
.where(homework.lessonId.in(lessonIdList), homework.memberId.eq(member.getMemberId()), homework.deletedAt.isNull())
.transform(groupBy(homework.homeworkId).list(Projections.constructor(HomeworkMainRes.class, homework.homeworkId, lecture.lectureId, lecture.color, lesson.lessonId, homework.memberId, homework.body, homework.deadline, homework.isFinish)))
.orderBy(homework.homeworkId.asc(), new CaseBuilder()
.when(memberAndLecture.member.memberId.eq(member.getMemberId())).then(0)
.otherwise(1).asc())
.transform(groupBy(homework.homeworkId).list(Projections.constructor(HomeworkMainRes.class, homework.homeworkId, memberAndLecture.lecture.lectureId, memberAndLecture.color, lesson.lessonId, homework.memberId, homework.body, homework.deadline, homework.isFinish)))
);
}

Expand All @@ -67,9 +71,12 @@ public Optional<List<HomeworkMainRes>> findAllHomeworkByMember(Member member) {
return Optional.ofNullable(
queryFactory.selectFrom(homework)
.leftJoin(lesson).on(lesson.lessonId.eq(homework.lessonId))
.leftJoin(lecture).on(lecture.lectureId.eq(lesson.lecture.lectureId))
.leftJoin(memberAndLecture).on(memberAndLecture.lecture.lectureId.eq(lesson.lecture.lectureId))
.where(homework.memberId.eq(member.getMemberId()), homework.deletedAt.isNull())
.transform(groupBy(homework.homeworkId).list(Projections.constructor(HomeworkMainRes.class, homework.homeworkId, lecture.lectureId, lecture.color, lesson.lessonId, homework.memberId, homework.body, homework.deadline, homework.isFinish)))
.orderBy(homework.homeworkId.asc(), new CaseBuilder()
.when(memberAndLecture.member.memberId.eq(member.getMemberId())).then(0)
.otherwise(1).asc())
.transform(groupBy(homework.homeworkId).list(Projections.constructor(HomeworkMainRes.class, homework.homeworkId, memberAndLecture.lecture.lectureId, memberAndLecture.color, lesson.lessonId, homework.memberId, homework.body, homework.deadline, homework.isFinish)))
);
}

Expand All @@ -78,19 +85,25 @@ public Optional<List<HomeworkMainRes>> findAllHomeworkByMemberAndType(Member mem
return Optional.ofNullable(
queryFactory.selectFrom(homework)
.leftJoin(lesson).on(lesson.lessonId.eq(homework.lessonId))
.leftJoin(lecture).on(lecture.lectureId.eq(lesson.lecture.lectureId))
.leftJoin(memberAndLecture).on(memberAndLecture.lecture.lectureId.eq(lesson.lecture.lectureId))
.where(homework.memberId.eq(member.getMemberId()), homework.isFinish.eq(type), homework.deletedAt.isNull())
.transform(groupBy(homework.homeworkId).list(Projections.constructor(HomeworkMainRes.class, homework.homeworkId, lecture.lectureId, lecture.color, lesson.lessonId, homework.memberId, homework.body, homework.deadline, homework.isFinish)))
.orderBy(homework.homeworkId.asc(), new CaseBuilder()
.when(memberAndLecture.member.memberId.eq(member.getMemberId())).then(0)
.otherwise(1).asc())
.transform(groupBy(homework.homeworkId).list(Projections.constructor(HomeworkMainRes.class, homework.homeworkId, memberAndLecture.lecture.lectureId, memberAndLecture.color, lesson.lessonId, homework.memberId, homework.body, homework.deadline, homework.isFinish)))
);
}

@Override
public HomeworkMainRes findHomeworkByHomeworkId(Long homeworkId) {
return queryFactory.select(Projections.constructor(HomeworkMainRes.class, homework.homeworkId, lecture.lectureId, lecture.color, lesson.lessonId, homework.memberId, homework.body, homework.deadline, homework.isFinish))
public HomeworkMainRes findHomeworkByHomeworkId(Member member, Long homeworkId) {
return queryFactory.select(Projections.constructor(HomeworkMainRes.class, homework.homeworkId, memberAndLecture.lecture.lectureId, memberAndLecture.color, lesson.lessonId, homework.memberId, homework.body, homework.deadline, homework.isFinish))
.from(homework)
.leftJoin(lesson).on(lesson.lessonId.eq(homework.lessonId))
.leftJoin(lecture).on(lecture.lectureId.eq(lesson.lecture.lectureId))
.leftJoin(memberAndLecture).on(memberAndLecture.lecture.lectureId.eq(lesson.lecture.lectureId))
.where(homework.homeworkId.eq(homeworkId), homework.deletedAt.isNull())
.orderBy(homework.homeworkId.asc(), new CaseBuilder()
.when(memberAndLecture.member.memberId.eq(member.getMemberId())).then(0)
.otherwise(1).asc())
.fetchOne();

}
Expand All @@ -100,9 +113,12 @@ public Optional<List<HomeworkMainRes>> findAllHomeworkByMemberAndLectureId(Membe
return Optional.ofNullable(
queryFactory.selectFrom(homework)
.leftJoin(lesson).on(lesson.lessonId.eq(homework.lessonId))
.leftJoin(lecture).on(lecture.lectureId.eq(lesson.lecture.lectureId))
.where(homework.memberId.eq(member.getMemberId()), homework.deletedAt.isNull(), lecture.lectureId.eq(lectureId))
.transform(groupBy(homework.homeworkId).list(Projections.constructor(HomeworkMainRes.class, homework.homeworkId, lecture.lectureId, lecture.color, lesson.lessonId, homework.memberId, homework.body, homework.deadline, homework.isFinish)))
.leftJoin(memberAndLecture).on(memberAndLecture.lecture.lectureId.eq(lesson.lecture.lectureId))
.where(homework.memberId.eq(member.getMemberId()), homework.deletedAt.isNull(), memberAndLecture.lecture.lectureId.eq(lectureId))
.orderBy(homework.homeworkId.asc(), new CaseBuilder()
.when(memberAndLecture.member.memberId.eq(member.getMemberId())).then(0)
.otherwise(1).asc())
.transform(groupBy(homework.homeworkId).list(Projections.constructor(HomeworkMainRes.class, homework.homeworkId, memberAndLecture.lecture.lectureId, memberAndLecture.color, lesson.lessonId, homework.memberId, homework.body, homework.deadline, homework.isFinish)))
);
}

Expand All @@ -111,9 +127,12 @@ public Optional<List<HomeworkMainRes>> findAllHomeworkByMemberAndLectureIdAndTyp
return Optional.ofNullable(
queryFactory.selectFrom(homework)
.leftJoin(lesson).on(lesson.lessonId.eq(homework.lessonId))
.leftJoin(lecture).on(lecture.lectureId.eq(lesson.lecture.lectureId))
.where(homework.memberId.eq(member.getMemberId()), homework.isFinish.eq(type), homework.deletedAt.isNull(), lecture.lectureId.eq(lectureId))
.transform(groupBy(homework.homeworkId).list(Projections.constructor(HomeworkMainRes.class, homework.homeworkId, lecture.lectureId, lecture.color, lesson.lessonId, homework.memberId, homework.body, homework.deadline, homework.isFinish)))
.leftJoin(memberAndLecture).on(memberAndLecture.lecture.lectureId.eq(lesson.lecture.lectureId))
.where(homework.memberId.eq(member.getMemberId()), homework.isFinish.eq(type), homework.deletedAt.isNull(), memberAndLecture.lecture.lectureId.eq(lectureId))
.orderBy(homework.homeworkId.asc(), new CaseBuilder()
.when(memberAndLecture.member.memberId.eq(member.getMemberId())).then(0)
.otherwise(1).asc())
.transform(groupBy(homework.homeworkId).list(Projections.constructor(HomeworkMainRes.class, homework.homeworkId, memberAndLecture.lecture.lectureId, memberAndLecture.color, lesson.lessonId, homework.memberId, homework.body, homework.deadline, homework.isFinish)))
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public HomeworkMainRes update(Member member, Long homeworkId, HomeworkReq homewo

// Business Logic
homework.update(homeworkReq);
HomeworkMainRes homeworkMainRes = homeworkRepository.findHomeworkByHomeworkId(homeworkId);
HomeworkMainRes homeworkMainRes = homeworkRepository.findHomeworkByHomeworkId(member, homeworkId);

// Response
return homeworkMainRes;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@ public void inviteStudent(Member member, Long lectureId, PostInviteReq postInvit
if(check.getState().equals(MemberState.INVITE)) {
smsClient.sendInvitation(member.getName(), lectureName, postInviteReq, Boolean.TRUE);
}
if(check.getState().equals(MemberState.ACTIVE)) {
if(check.getState().equals(MemberState.ACTIVE) && check.getToken() != null) {
// smsClient.sendInvitation(member.getName(), lectureName,postInviteReq, Boolean.FALSE);
String title = lectureName + "클래스 초대";
String body = "[과릿] " + member.getName() + " 선생님으로부터 " + lectureName + " 클래스 초대가 도착했습니다." + "\n" + "접속하여 초대된 클래스를 확인해보세요!";
Expand Down

0 comments on commit 906c3a9

Please sign in to comment.