@@ -4,29 +4,44 @@ const calculateTime = require('../utils/calculateTime');
44
55const prisma = new PrismaClient ( ) ;
66
7- const uncompletedMission = async ( memberId ) => {
8- try {
9- const missions = await prisma . memberMission . findMany ( {
10- where : {
11- memberId : Number ( memberId ) ,
12- completed : false
13- } ,
14- include : {
15- mission : {
16- include : { flower : true }
17- }
18- } ,
19- orderBy : {
20- mission : { id : 'asc' }
21- } ,
22- } ) ;
23- return missions ;
24- } catch ( error ) {
25- throw new CustomError ( ErrorCodes . InternalServerError , '사용자의 미션 목록 조회 중 오류가 발생하였습니다.' ) ;
7+ const uncompletedMission = async ( memberId ) => {
8+ try {
9+ const missions = await prisma . memberMission . findMany ( {
10+ where : {
11+ memberId : Number ( memberId ) ,
12+ } ,
13+ include : {
14+ mission : {
15+ include : { flower : true } ,
16+ } ,
17+ } ,
18+ orderBy : {
19+ mission : { id : "asc" } ,
20+ } ,
21+ } ) ;
22+
23+ const missionList = [ ] ;
24+
25+ missions . forEach ( ( mission ) => {
26+ const formatMission = {
27+ title : mission . mission . title ,
28+ description : mission . mission . description ,
29+ type : mission . mission . type ,
30+ targetValue : mission . mission . targetValue ,
31+ currentValue : 0 ,
32+ completed : mission . completed ,
33+ flowerName : mission . mission . flower . name ,
34+ } ;
35+
36+ missionList . push ( formatMission ) ;
37+ } ) ;
38+
39+ return missionList ;
40+
41+ } catch ( error ) {
42+ throw new CustomError ( ErrorCodes . InternalServerError , "사용자의 미션 목록 조회 중 오류가 발생하였습니다." ) ;
2643 }
2744} ;
28-
29-
3045//연속 심기 미션 업데이트(로그인시..?)
3146const updateConsecutivePlantingMission = async ( memberId ) => {
3247 const today = new Date ( new Date ( ) . setHours ( 0 , 0 , 0 , 0 ) ) ; //시간 자정으로 맞춤
@@ -208,7 +223,7 @@ const setupMission= async(memberId) => {
208223 lastUpdated : new Date ( )
209224 } ) )
210225 } ) ;
211-
226+
212227 console . log ( '미션 초기할당이 완료되었습니다' ) ; //확인용
213228 } catch ( error ) {
214229 console . error ( '미션 초기 생성 중 오류:' , error ) ;
0 commit comments