Toggle navigation
Toggle navigation
This project
Loading...
Sign in
송용우
/
oss-Jaksimsamil
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Snippets
Network
Create a new issue
Builds
Commits
Issue Boards
Authored by
JJuOn
2020-08-31 16:50:47 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
0e52d2e804e8538fe203e814983f390a9de01123
0e52d2e8
1 parent
910ff91f
Fix response body to return serialized JSON
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
13 additions
and
11 deletions
jaksimsamil-server/src/api/challenge/challege.ctrl.js
jaksimsamil-server/src/api/profile/profile.ctrl.js
jaksimsamil-server/src/api/challenge/challege.ctrl.js
View file @
0e52d2e
...
...
@@ -13,12 +13,12 @@ const Joi = require("joi");
exports
.
getChallenge
=
async
(
ctx
)
=>
{
try
{
const
{
challengeName
}
=
ctx
.
request
.
body
;
const
challenge
=
await
Challenge
.
findByChallengeName
(
challengeName
)
.
select
(
'-_id'
)
;
const
challenge
=
await
Challenge
.
findByChallengeName
(
challengeName
);
if
(
!
challenge
)
{
ctx
.
status
=
401
;
return
;
}
ctx
.
body
=
challenge
;
ctx
.
body
=
challenge
.
serialize
()
;
}
catch
(
e
)
{
ctx
.
throw
(
500
,
e
);
}
...
...
@@ -58,7 +58,7 @@ exports.addChallenge = async (ctx) => {
}
=
ctx
.
request
.
body
;
try
{
const
isChallengeExist
=
await
Challenge
.
findByChallengeName
(
challengeName
)
.
select
(
'-_id'
)
;
const
isChallengeExist
=
await
Challenge
.
findByChallengeName
(
challengeName
);
if
(
isChallengeExist
)
{
ctx
.
status
=
409
;
...
...
@@ -122,7 +122,7 @@ exports.addChallenge = async (ctx) => {
s_date
=
new
Date
(
e_date
);
s_date
.
setMinutes
(
s_date
.
getMinutes
()
+
1
);
}
ctx
.
body
=
challenge
;
ctx
.
body
=
challenge
.
serialize
()
;
}
catch
(
e
)
{
ctx
.
throw
(
500
,
e
);
}
...
...
@@ -136,12 +136,12 @@ exports.list = async (ctx) => {
try
{
const
status
=
ctx
.
params
.
status
;
if
(
status
!==
'all'
){
const
challenges
=
await
Challenge
.
find
({
status
:
status
})
.
select
(
'-_id'
)
;
ctx
.
body
=
challenges
;
const
challenges
=
await
Challenge
.
find
({
status
:
status
});
ctx
.
body
=
challenges
.
serialize
()
;
}
else
{
const
challenges
=
await
Challenge
.
find
({})
.
select
(
'-_id'
)
;
ctx
.
body
=
challenges
;
const
challenges
=
await
Challenge
.
find
({});
ctx
.
body
=
challenges
.
serialize
()
;
}
}
catch
(
e
){
...
...
@@ -169,6 +169,7 @@ exports.participate=async (ctx)=>{
const
user
=
await
User
.
findByUsername
(
username
);
const
user_id
=
user
.
_id
;
const
newGroup
=
new
Group
({
groupName
:
`
${
user
.
username
}
의
${
challengeName
}
그룹`
,
members
:[
user_id
],
});
let
newGroup_id
=
""
...
...
@@ -185,6 +186,7 @@ exports.participate=async (ctx)=>{
problems
:[],
});
await
newParticipation
.
save
();
ctx
.
body
=
newParticipation
.
serialize
();
});
});
}
...
...
jaksimsamil-server/src/api/profile/profile.ctrl.js
View file @
0e52d2e
...
...
@@ -30,7 +30,7 @@ exports.getProfile = async (ctx) => {
ctx
.
status
=
401
;
return
;
}
ctx
.
body
=
profile
;
ctx
.
body
=
profile
.
serialize
()
;
}
catch
(
e
)
{
ctx
.
throw
(
500
,
e
);
}
...
...
@@ -71,7 +71,7 @@ exports.setProfile = async (ctx) => {
ctx
.
status
=
404
;
return
;
}
ctx
.
body
=
profile
;
ctx
.
body
=
profile
.
serialize
()
;
}
catch
(
e
)
{
ctx
.
throw
(
500
,
e
);
}
...
...
@@ -104,7 +104,7 @@ exports.syncBJ = async function (ctx) {
{
solvedBJ
:
BJdata
,
solvedBJ_date
:
BJdata_date
},
{
new
:
true
}
).
exec
();
ctx
.
body
=
updateprofile
;
ctx
.
body
=
updateprofile
.
serialize
()
;
}
catch
(
e
)
{
ctx
.
throw
(
500
,
e
);
}
...
...
Please
register
or
login
to post a comment