Showing
2 changed files
with
13 additions
and
11 deletions
... | @@ -13,12 +13,12 @@ const Joi = require("joi"); | ... | @@ -13,12 +13,12 @@ const Joi = require("joi"); |
13 | exports.getChallenge = async (ctx) => { | 13 | exports.getChallenge = async (ctx) => { |
14 | try { | 14 | try { |
15 | const { challengeName } = ctx.request.body; | 15 | const { challengeName } = ctx.request.body; |
16 | - const challenge = await Challenge.findByChallengeName(challengeName).select('-_id'); | 16 | + const challenge = await Challenge.findByChallengeName(challengeName); |
17 | if (!challenge) { | 17 | if (!challenge) { |
18 | ctx.status = 401; | 18 | ctx.status = 401; |
19 | return; | 19 | return; |
20 | } | 20 | } |
21 | - ctx.body = challenge; | 21 | + ctx.body = challenge.serialize(); |
22 | } catch (e) { | 22 | } catch (e) { |
23 | ctx.throw(500, e); | 23 | ctx.throw(500, e); |
24 | } | 24 | } |
... | @@ -58,7 +58,7 @@ exports.addChallenge = async (ctx) => { | ... | @@ -58,7 +58,7 @@ exports.addChallenge = async (ctx) => { |
58 | } = ctx.request.body; | 58 | } = ctx.request.body; |
59 | 59 | ||
60 | try { | 60 | try { |
61 | - const isChallengeExist = await Challenge.findByChallengeName(challengeName).select('-_id'); | 61 | + const isChallengeExist = await Challenge.findByChallengeName(challengeName); |
62 | 62 | ||
63 | if (isChallengeExist) { | 63 | if (isChallengeExist) { |
64 | ctx.status = 409; | 64 | ctx.status = 409; |
... | @@ -122,7 +122,7 @@ exports.addChallenge = async (ctx) => { | ... | @@ -122,7 +122,7 @@ exports.addChallenge = async (ctx) => { |
122 | s_date=new Date(e_date); | 122 | s_date=new Date(e_date); |
123 | s_date.setMinutes(s_date.getMinutes()+1); | 123 | s_date.setMinutes(s_date.getMinutes()+1); |
124 | } | 124 | } |
125 | - ctx.body = challenge; | 125 | + ctx.body = challenge.serialize(); |
126 | } catch (e) { | 126 | } catch (e) { |
127 | ctx.throw(500, e); | 127 | ctx.throw(500, e); |
128 | } | 128 | } |
... | @@ -136,12 +136,12 @@ exports.list = async (ctx) => { | ... | @@ -136,12 +136,12 @@ exports.list = async (ctx) => { |
136 | try{ | 136 | try{ |
137 | const status = ctx.params.status; | 137 | const status = ctx.params.status; |
138 | if (status!=='all'){ | 138 | if (status!=='all'){ |
139 | - const challenges = await Challenge.find({status:status}).select('-_id'); | 139 | + const challenges = await Challenge.find({status:status}); |
140 | - ctx.body = challenges; | 140 | + ctx.body = challenges.serialize(); |
141 | } | 141 | } |
142 | else { | 142 | else { |
143 | - const challenges = await Challenge.find({}).select('-_id'); | 143 | + const challenges = await Challenge.find({}); |
144 | - ctx.body = challenges; | 144 | + ctx.body = challenges.serialize(); |
145 | } | 145 | } |
146 | } | 146 | } |
147 | catch(e){ | 147 | catch(e){ |
... | @@ -169,6 +169,7 @@ exports.participate=async (ctx)=>{ | ... | @@ -169,6 +169,7 @@ exports.participate=async (ctx)=>{ |
169 | const user=await User.findByUsername(username); | 169 | const user=await User.findByUsername(username); |
170 | const user_id=user._id; | 170 | const user_id=user._id; |
171 | const newGroup=new Group({ | 171 | const newGroup=new Group({ |
172 | + groupName:`${user.username}의 ${challengeName} 그룹`, | ||
172 | members:[user_id], | 173 | members:[user_id], |
173 | }); | 174 | }); |
174 | let newGroup_id="" | 175 | let newGroup_id="" |
... | @@ -185,6 +186,7 @@ exports.participate=async (ctx)=>{ | ... | @@ -185,6 +186,7 @@ exports.participate=async (ctx)=>{ |
185 | problems:[], | 186 | problems:[], |
186 | }); | 187 | }); |
187 | await newParticipation.save(); | 188 | await newParticipation.save(); |
189 | + ctx.body=newParticipation.serialize(); | ||
188 | }); | 190 | }); |
189 | }); | 191 | }); |
190 | } | 192 | } | ... | ... |
... | @@ -30,7 +30,7 @@ exports.getProfile = async (ctx) => { | ... | @@ -30,7 +30,7 @@ exports.getProfile = async (ctx) => { |
30 | ctx.status = 401; | 30 | ctx.status = 401; |
31 | return; | 31 | return; |
32 | } | 32 | } |
33 | - ctx.body = profile; | 33 | + ctx.body = profile.serialize(); |
34 | } catch (e) { | 34 | } catch (e) { |
35 | ctx.throw(500, e); | 35 | ctx.throw(500, e); |
36 | } | 36 | } |
... | @@ -71,7 +71,7 @@ exports.setProfile = async (ctx) => { | ... | @@ -71,7 +71,7 @@ exports.setProfile = async (ctx) => { |
71 | ctx.status = 404; | 71 | ctx.status = 404; |
72 | return; | 72 | return; |
73 | } | 73 | } |
74 | - ctx.body = profile; | 74 | + ctx.body = profile.serialize(); |
75 | } catch (e) { | 75 | } catch (e) { |
76 | ctx.throw(500, e); | 76 | ctx.throw(500, e); |
77 | } | 77 | } |
... | @@ -104,7 +104,7 @@ exports.syncBJ = async function (ctx) { | ... | @@ -104,7 +104,7 @@ exports.syncBJ = async function (ctx) { |
104 | { solvedBJ: BJdata, solvedBJ_date: BJdata_date }, | 104 | { solvedBJ: BJdata, solvedBJ_date: BJdata_date }, |
105 | { new: true } | 105 | { new: true } |
106 | ).exec(); | 106 | ).exec(); |
107 | - ctx.body = updateprofile; | 107 | + ctx.body = updateprofile.serialize(); |
108 | } catch (e) { | 108 | } catch (e) { |
109 | ctx.throw(500, e); | 109 | ctx.throw(500, e); |
110 | } | 110 | } | ... | ... |
-
Please register or login to post a comment