Skip to content

Commit

Permalink
Merge pull request #122 from Modagbul/feat/mission-alarm
Browse files Browse the repository at this point in the history
fix : 완료한 반복미션 미션 모아보기에 안뜨게 수정
  • Loading branch information
seungueonn authored Dec 9, 2023
2 parents b91e45a + 823944d commit c4aae86
Show file tree
Hide file tree
Showing 13 changed files with 129 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,40 +22,44 @@ public class MissionRemindAlarmUseCase {

public void sendRemindMissionAlarm(Mission mission) {



Random random = new Random(System.currentTimeMillis());

String title = getTitle("receiver",random.nextInt(4));
String message = getMessage(mission.getTitle(),random.nextInt(4));


String title = getTitle(random.nextInt(4));
String message = getMessage(random.nextInt(4));

MultiRequest multiRequest = new MultiRequest();
}

public String getTitle(String receiver, int num) {
public String getTitle(int num) {
switch (num) {
case 0:
return receiver + REMIND_MISSION_TITLE1.getMessage();
return REMIND_MISSION_TITLE1.getMessage();
case 1:
return receiver + REMIND_MISSION_TITLE2.getMessage();
return REMIND_MISSION_TITLE2.getMessage();
case 2:
return receiver + REMIND_MISSION_TITLE3.getMessage();
return REMIND_MISSION_TITLE3.getMessage();
case 3:
return receiver + REMIND_MISSION_TITLE4.getMessage();
return REMIND_MISSION_TITLE4.getMessage();
}
return receiver + REMIND_MISSION_TITLE4.getMessage();
return REMIND_MISSION_TITLE4.getMessage();

}
public String getMessage(String missionTitle, int num) {
public String getMessage(int num) {
switch (num) {
case 0:
return missionTitle + REMIND_MISSION_MESSAGE1.getMessage();
return REMIND_MISSION_MESSAGE1.getMessage();
case 1:
return missionTitle + REMIND_MISSION_MESSAGE2.getMessage();
return REMIND_MISSION_MESSAGE2.getMessage();
case 2:
return missionTitle + REMIND_MISSION_MESSAGE3.getMessage();
return REMIND_MISSION_MESSAGE3.getMessage();
case 3:
return missionTitle + REMIND_MISSION_MESSAGE4.getMessage();
return REMIND_MISSION_MESSAGE4.getMessage();
}
return missionTitle + REMIND_MISSION_MESSAGE4.getMessage();
return REMIND_MISSION_MESSAGE4.getMessage();

}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import com.moing.backend.domain.mission.domain.entity.constant.MissionType;
import com.moing.backend.domain.mission.domain.entity.constant.MissionWay;
import com.moing.backend.domain.missionArchive.domain.entity.MissionArchive;
import com.moing.backend.domain.missionState.domain.entity.MissionState;
import com.moing.backend.domain.team.domain.entity.Team;
import com.moing.backend.global.entity.BaseTimeEntity;
import lombok.AllArgsConstructor;
Expand Down Expand Up @@ -49,6 +50,9 @@ public class Mission extends BaseTimeEntity {

@OneToMany(mappedBy = "mission")
List<MissionArchive> missionArchiveList = new ArrayList<>();

@OneToMany(mappedBy = "mission")
List<MissionState> missionStateList = new ArrayList<>();

@Builder
public Mission(String title, LocalDateTime dueTo, String rule, String content, int number, Team team, MissionType type, MissionStatus status, MissionWay way) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,12 @@
import com.moing.backend.domain.mission.domain.entity.Mission;
import com.moing.backend.domain.mission.domain.entity.constant.MissionStatus;
import com.moing.backend.domain.mission.domain.entity.constant.MissionType;
import com.moing.backend.domain.missionArchive.domain.entity.QMissionArchive;
import com.moing.backend.domain.missionState.domain.entity.QMissionState;
import com.querydsl.core.types.Projections;
import com.querydsl.core.types.dsl.BooleanExpression;
import com.querydsl.jpa.JPAExpressions;
import com.querydsl.jpa.JPQLQuery;
import com.querydsl.jpa.impl.JPAQueryFactory;

import javax.persistence.EntityManager;
Expand Down Expand Up @@ -58,15 +60,17 @@ public Optional<List<GatherRepeatMissionRes>> findRepeatMissionByMemberId(Long m
.leftJoin(missionArchive)
.on(missionArchive.mission.eq(mission),
missionArchive.member.memberId.eq(memberId)
// ,missionArchive.count.max().loe(missionArchive.mission.number)
)
.where(
mission.team.teamId.in(teams),
mission.status.eq(MissionStatus.ONGOING),
mission.type.eq(MissionType.REPEAT)

)
.groupBy(mission.id)
.orderBy(missionArchive.count().desc())
.groupBy(mission.id,mission.number)
// .having(missionArchive.count().lt(mission.number)) // HAVING 절을 사용하여 조건 적용

.orderBy(missionArchive.count().desc())
.fetch());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ public class MissionArchiveRes {
private String heartStatus;
private Long hearts;

private boolean isAbleToEdit;



}
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ public class MissionArchive extends BaseTimeEntity { // 1회 미션을 저장
@Enumerated(value = EnumType.STRING)
private MissionArchiveStatus status;


@Column(nullable = false, columnDefinition="TEXT", length = 4000)
private String archive; //링크, 글, 사진 뭐든 가능

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.moing.backend.domain.missionArchive.domain.repository;

import com.moing.backend.domain.member.domain.entity.Member;
import com.moing.backend.domain.mission.application.dto.res.FinishMissionBoardRes;
import com.moing.backend.domain.mission.application.dto.res.RepeatMissionBoardRes;
import com.moing.backend.domain.mission.application.dto.res.SingleMissionBoardRes;
Expand Down Expand Up @@ -31,4 +32,7 @@ public interface MissionArchiveCustomRepository {

Boolean findMyArchivesToday(Long memberId,Long missionId);

Optional<List<String>> findPeopleRemainMission();


}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.moing.backend.domain.missionArchive.domain.repository;

import com.moing.backend.domain.member.domain.entity.Member;
import com.moing.backend.domain.mission.application.dto.res.FinishMissionBoardRes;
import com.moing.backend.domain.mission.application.dto.res.RepeatMissionBoardRes;
import com.moing.backend.domain.mission.application.dto.res.SingleMissionBoardRes;
Expand All @@ -22,6 +23,7 @@
import org.springframework.data.jpa.repository.Query;

import javax.persistence.EntityManager;
import javax.swing.text.html.Option;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.List;
Expand All @@ -30,7 +32,11 @@
import static com.moing.backend.domain.mission.domain.entity.QMission.mission;
import static com.moing.backend.domain.missionArchive.domain.entity.QMissionArchive.*;
import static com.moing.backend.domain.missionState.domain.entity.QMissionState.missionState;
import static com.moing.backend.domain.team.domain.entity.QTeam.team;
import static com.moing.backend.domain.teamMember.domain.entity.QTeamMember.teamMember;
import static javax.swing.Spring.constant;
import static org.springframework.data.jpa.domain.Specification.where;

@Slf4j
public class MissionArchiveCustomRepositoryImpl implements MissionArchiveCustomRepository {

Expand Down Expand Up @@ -294,5 +300,26 @@ public Boolean findMyArchivesToday(Long memberId, Long missionId) {
}


public Optional<List<String>> findPeopleRemainMission() {
return Optional.ofNullable(queryFactory
.select(teamMember.member.nickName).distinct()
.from(teamMember)
.join(teamMember.team, team)
.join(team.missions, mission)
.join(mission.missionStateList,missionState)
.where(missionState.isNull())
.fetch());
// .where(
// // active 한 미션 필터링
// (((mission.status.eq(MissionStatus.ONGOING).or(mission.status.eq(MissionStatus.WAIT))).and(mission.type.eq(MissionType.ONCE)))
// .or((mission.status.eq(MissionStatus.ONGOING)).and(mission.type.eq(MissionType.REPEAT)))),
// // 인증하지 않은값
// missionState.id.isNull()


// ).fetch());
}



}
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,12 @@
import org.hibernate.annotations.Parameter;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;

import java.util.List;
import java.util.Optional;

@Repository
public interface MissionArchiveRepository extends JpaRepository<MissionArchive, Long>,MissionArchiveCustomRepository {

@Query("select m from MissionArchive as m where m.member =:memberId" )
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package com.moing.backend.domain.missionArchive.domain.service;

import com.moing.backend.domain.member.domain.entity.Member;
import com.moing.backend.domain.missionArchive.application.dto.res.MissionArchiveRes;
import com.moing.backend.domain.missionArchive.domain.repository.MissionArchiveRepository;
import com.moing.backend.global.annotation.DomainService;
import lombok.RequiredArgsConstructor;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@DomainService
@Transactional
@RequiredArgsConstructor
public class MissionArchiveScheduleQueryService {


private final MissionArchiveRepository missionArchiveRepository;

public List<String> getRemainMissionPeople() {
return missionArchiveRepository.findPeopleRemainMission().orElseThrow();
}


}
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package com.moing.backend.domain.missionArchive.presentation;


import com.moing.backend.domain.member.domain.entity.Member;
import com.moing.backend.domain.mission.application.dto.res.GatherRepeatMissionRes;
import com.moing.backend.domain.missionArchive.application.dto.req.MissionArchiveReq;
Expand All @@ -10,7 +9,9 @@
import com.moing.backend.domain.missionArchive.application.dto.res.PersonalArchiveRes;
import com.moing.backend.domain.missionArchive.application.service.*;


import com.moing.backend.domain.missionArchive.domain.service.MissionArchiveDeleteService;

import com.moing.backend.domain.missionHeart.application.dto.MissionHeartRes;
import com.moing.backend.domain.missionHeart.application.service.MissionHeartUseCase;
import com.moing.backend.global.config.security.dto.User;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public class MissionState extends BaseTimeEntity {
@Column(name = "missionState_id")
private Long id;

@OneToOne(fetch = FetchType.LAZY)
@ManyToOne(fetch = FetchType.LAZY)
private Mission mission;
@OneToOne
private Member member;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,16 @@
@RequiredArgsConstructor
public enum RemindMissionTitle {

REMIND_MISSION_TITLE1("님, 오늘도 좋은하루!"),
REMIND_MISSION_TITLE2("님, 잊으신 건 아니죠?\uD83D\uDC40"),
REMIND_MISSION_TITLE3("님, 좋은 아침이에요! ☀\uFE0F"),
REMIND_MISSION_TITLE1("오늘도 좋은 하루 보내세요!"),
REMIND_MISSION_TITLE2("혹시 ... 잊으신 건 아니죠?\uD83D\uDC40"),
REMIND_MISSION_TITLE3("좋은 아침이에요! ☀\uFE0F"),
REMIND_MISSION_TITLE4("오늘의 열정이 타오르불\uD83D\uDD25"),


REMIND_MISSION_MESSAGE1(" 도전과 함께⚡\uFE0F "),
REMIND_MISSION_MESSAGE2(" 인증을 모임원들이 기다리고 있어요!"),
REMIND_MISSION_MESSAGE3(" 수행하고 이번주도 도전해요👊 "),
REMIND_MISSION_MESSAGE4(" 도전하고 성취감 뿜뿜💪 ");
REMIND_MISSION_MESSAGE1(" 자기계발 미션 도전과 함께⚡\uFE0F "),
REMIND_MISSION_MESSAGE2(" 미션 인증을 모임원들이 기다리고 있어요!"),
REMIND_MISSION_MESSAGE3(" 미션 인증하고 이번주도 도전해요👊 "),
REMIND_MISSION_MESSAGE4(" 미션 도전하고 성취감 뿜뿜💪 ");

private final String message;

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
//package com.moing.backend.domain.missionArchive.domain.repository;
//
//import com.querydsl.jpa.impl.JPAQueryFactory;
//import org.junit.jupiter.api.Test;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.boot.test.context.SpringBootTest;
//
//import javax.persistence.EntityManager;
//import java.util.List;
//import java.util.Optional;
//
//import static com.moing.backend.domain.mission.domain.entity.QMission.mission;
//import static com.moing.backend.domain.missionState.domain.entity.QMissionState.missionState;
//@SpringBootTest
//class MissionArchiveCustomRepositoryImplTest {
//
// @Autowired
// EntityManager em;
//
// @Autowired
// private MissionArchiveRepository missionArchiveRepository;
//
// @Test
// void findPeopleRemainMission() {
//
// System.out.println("!!!"+ missionArchiveRepository.findPeopleRemainMission());
//
// }
//}

0 comments on commit c4aae86

Please sign in to comment.