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
송용우
2020-08-21 16:45:32 +0900
1
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
bd5f5ee664c24938067fb4b71ac62aa123f4ed63
bd5f5ee6
1 parent
9288698a
Integrate User and Profile Model to Model
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
41 additions
and
4 deletions
jaksimsamil-server/.gitignore
jaksimsamil-server/src/api/profile/profile.ctrl.js
jaksimsamil-server/src/models/user.js
jaksimsamil-server/.gitignore
View file @
bd5f5ee
...
...
@@ -8,3 +8,4 @@ access.log
# dependencies
/node_modules
...
...
jaksimsamil-server/src/api/profile/profile.ctrl.js
View file @
bd5f5ee
...
...
@@ -134,7 +134,7 @@ exports.recommend = async (ctx) => {
problem_set
.
problem_set
);
ctx
.
body
=
compareBJ
.
randomItem
(
unsolved_data
);
//데이터가 비었을 떄 예외처리 필요
//
TODO:
데이터가 비었을 떄 예외처리 필요
}
catch
(
e
)
{
ctx
.
throw
(
500
,
e
);
}
...
...
jaksimsamil-server/src/models/user.js
View file @
bd5f5ee
...
...
@@ -7,8 +7,18 @@ const Schema = mongoose.Schema;
const
UserSchema
=
new
Schema
({
username
:
String
,
hashedPassword
:
String
,
userBJID
:
String
,
sovledBJ
:
Object
,
solvedBJ_date
:
Object
,
friendList
:
[
String
],
slackWebHookURL
:
String
,
goalNum
:
Number
,
});
UserSchema
.
statics
.
findByUsername
=
function
(
username
)
{
return
this
.
findOne
({
username
});
};
UserSchema
.
methods
.
setPassword
=
async
function
(
password
)
{
const
hash
=
await
bcrypt
.
hash
(
password
,
10
);
this
.
hashedPassword
=
hash
;
...
...
@@ -17,14 +27,13 @@ UserSchema.methods.checkPassword = async function (password) {
const
result
=
await
bcrypt
.
compare
(
password
,
this
.
hashedPassword
);
return
result
;
};
UserSchema
.
statics
.
findByUsername
=
function
(
username
)
{
return
this
.
findOne
({
username
});
};
UserSchema
.
methods
.
serialize
=
function
()
{
const
data
=
this
.
toJSON
();
delete
data
.
hashedPassword
;
return
data
;
};
UserSchema
.
methods
.
generateToken
=
function
()
{
const
token
=
jwt
.
sign
(
{
...
...
@@ -38,5 +47,32 @@ UserSchema.methods.generateToken = function () {
);
return
token
;
};
UserSchema
.
statics
.
findByUsername
=
function
(
username
)
{
return
this
.
findOne
({
username
});
};
UserSchema
.
methods
.
getBJID
=
function
()
{
return
this
.
userBJID
;
};
UserSchema
.
methods
.
getBJdata
=
function
()
{
return
this
.
solvedBJ
;
};
UserSchema
.
methods
.
getslackURL
=
function
()
{
return
this
.
slackWebHookURL
;
};
UserSchema
.
methods
.
getgoalNum
=
function
()
{
return
this
.
goalNum
;
};
UserSchema
.
methods
.
getTodaySovled
=
function
()
{
if
(
this
.
solvedBJ_date
)
{
return
this
.
solvedBJ_date
.
presentNum
;
}
};
const
User
=
mongoose
.
model
(
"User"
,
UserSchema
);
module
.
exports
=
User
;
...
...
송용우
@2019102188
2020-09-26 12:41:26 UTC
Mentioned in commit
b885b7d5
Please
register
or
login
to post a comment