Showing
7 changed files
with
62 additions
and
20 deletions
... | @@ -402,12 +402,12 @@ | ... | @@ -402,12 +402,12 @@ |
402 | } | 402 | } |
403 | }, | 403 | }, |
404 | "bcrypt": { | 404 | "bcrypt": { |
405 | - "version": "3.0.8", | 405 | + "version": "5.0.0", |
406 | - "resolved": "https://registry.npmjs.org/bcrypt/-/bcrypt-3.0.8.tgz", | 406 | + "resolved": "https://registry.npmjs.org/bcrypt/-/bcrypt-5.0.0.tgz", |
407 | - "integrity": "sha512-jKV6RvLhI36TQnPDvUFqBEnGX9c8dRRygKxCZu7E+MgLfKZbmmXL8a7/SFFOyHoPNX9nV81cKRC5tbQfvEQtpw==", | 407 | + "integrity": "sha512-jB0yCBl4W/kVHM2whjfyqnxTmOHkCX4kHEa5nYKSoGeYe8YrjTYTc87/6bwt1g8cmV0QrbhKriETg9jWtcREhg==", |
408 | "requires": { | 408 | "requires": { |
409 | - "nan": "2.14.0", | 409 | + "node-addon-api": "^3.0.0", |
410 | - "node-pre-gyp": "0.14.0" | 410 | + "node-pre-gyp": "0.15.0" |
411 | } | 411 | } |
412 | }, | 412 | }, |
413 | "bcrypt-pbkdf": { | 413 | "bcrypt-pbkdf": { |
... | @@ -2415,11 +2415,6 @@ | ... | @@ -2415,11 +2415,6 @@ |
2415 | "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", | 2415 | "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", |
2416 | "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==" | 2416 | "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==" |
2417 | }, | 2417 | }, |
2418 | - "nan": { | ||
2419 | - "version": "2.14.0", | ||
2420 | - "resolved": "https://registry.npmjs.org/nan/-/nan-2.14.0.tgz", | ||
2421 | - "integrity": "sha512-INOFj37C7k3AfaNTtX8RhsTw7qRy7eLET14cROi9+5HAVbbHuIWUHEauBv5qT4Av2tWasiTY1Jw6puUNqRJXQg==" | ||
2422 | - }, | ||
2423 | "natural-compare": { | 2418 | "natural-compare": { |
2424 | "version": "1.4.0", | 2419 | "version": "1.4.0", |
2425 | "resolved": "https://registry.npmjs.org/natural-compare/-/natural-compare-1.4.0.tgz", | 2420 | "resolved": "https://registry.npmjs.org/natural-compare/-/natural-compare-1.4.0.tgz", |
... | @@ -2451,14 +2446,19 @@ | ... | @@ -2451,14 +2446,19 @@ |
2451 | "resolved": "https://registry.npmjs.org/negotiator/-/negotiator-0.6.2.tgz", | 2446 | "resolved": "https://registry.npmjs.org/negotiator/-/negotiator-0.6.2.tgz", |
2452 | "integrity": "sha512-hZXc7K2e+PgeI1eDBe/10Ard4ekbfrrqG8Ep+8Jmf4JID2bNg7NvCPOZN+kfF574pFQI7mum2AUqDidoKqcTOw==" | 2447 | "integrity": "sha512-hZXc7K2e+PgeI1eDBe/10Ard4ekbfrrqG8Ep+8Jmf4JID2bNg7NvCPOZN+kfF574pFQI7mum2AUqDidoKqcTOw==" |
2453 | }, | 2448 | }, |
2449 | + "node-addon-api": { | ||
2450 | + "version": "3.0.0", | ||
2451 | + "resolved": "https://registry.npmjs.org/node-addon-api/-/node-addon-api-3.0.0.tgz", | ||
2452 | + "integrity": "sha512-sSHCgWfJ+Lui/u+0msF3oyCgvdkhxDbkCS6Q8uiJquzOimkJBvX6hl5aSSA7DR1XbMpdM8r7phjcF63sF4rkKg==" | ||
2453 | + }, | ||
2454 | "node-pre-gyp": { | 2454 | "node-pre-gyp": { |
2455 | - "version": "0.14.0", | 2455 | + "version": "0.15.0", |
2456 | - "resolved": "https://registry.npmjs.org/node-pre-gyp/-/node-pre-gyp-0.14.0.tgz", | 2456 | + "resolved": "https://registry.npmjs.org/node-pre-gyp/-/node-pre-gyp-0.15.0.tgz", |
2457 | - "integrity": "sha512-+CvDC7ZttU/sSt9rFjix/P05iS43qHCOOGzcr3Ry99bXG7VX953+vFyEuph/tfqoYu8dttBkE86JSKBO2OzcxA==", | 2457 | + "integrity": "sha512-7QcZa8/fpaU/BKenjcaeFF9hLz2+7S9AqyXFhlH/rilsQ/hPZKK32RtR5EQHJElgu+q5RfbJ34KriI79UWaorA==", |
2458 | "requires": { | 2458 | "requires": { |
2459 | "detect-libc": "^1.0.2", | 2459 | "detect-libc": "^1.0.2", |
2460 | - "mkdirp": "^0.5.1", | 2460 | + "mkdirp": "^0.5.3", |
2461 | - "needle": "^2.2.1", | 2461 | + "needle": "^2.5.0", |
2462 | "nopt": "^4.0.1", | 2462 | "nopt": "^4.0.1", |
2463 | "npm-packlist": "^1.1.6", | 2463 | "npm-packlist": "^1.1.6", |
2464 | "npmlog": "^4.0.2", | 2464 | "npmlog": "^4.0.2", | ... | ... |
... | @@ -5,7 +5,7 @@ | ... | @@ -5,7 +5,7 @@ |
5 | "license": "MIT", | 5 | "license": "MIT", |
6 | "dependencies": { | 6 | "dependencies": { |
7 | "axios": "^0.19.2", | 7 | "axios": "^0.19.2", |
8 | - "bcrypt": "^3.0.0", | 8 | + "bcrypt": "^5.0.0", |
9 | "body-parser": "^1.19.0", | 9 | "body-parser": "^1.19.0", |
10 | "cheerio": "^1.0.0-rc.3", | 10 | "cheerio": "^1.0.0-rc.3", |
11 | "cookie-parser": "^1.4.5", | 11 | "cookie-parser": "^1.4.5", | ... | ... |
... | @@ -134,7 +134,7 @@ exports.recommend = async (ctx) => { | ... | @@ -134,7 +134,7 @@ exports.recommend = async (ctx) => { |
134 | problem_set.problem_set | 134 | problem_set.problem_set |
135 | ); | 135 | ); |
136 | ctx.body = compareBJ.randomItem(unsolved_data); | 136 | ctx.body = compareBJ.randomItem(unsolved_data); |
137 | - //데이터가 비었을 떄 예외처리 필요 | 137 | + //TODO: 데이터가 비었을 떄 예외처리 필요 |
138 | } catch (e) { | 138 | } catch (e) { |
139 | ctx.throw(500, e); | 139 | ctx.throw(500, e); |
140 | } | 140 | } | ... | ... |
... | @@ -8,6 +8,7 @@ const ProblemSchema=new Schema({ | ... | @@ -8,6 +8,7 @@ const ProblemSchema=new Schema({ |
8 | solvedacLevel: {type: Number}, | 8 | solvedacLevel: {type: Number}, |
9 | sumbitNum: {type: Number, required: true}, | 9 | sumbitNum: {type: Number, required: true}, |
10 | correctNum: {type: Number, required: true}, | 10 | correctNum: {type: Number, required: true}, |
11 | + count: { type: Number }, | ||
11 | category: {type:[String]} | 12 | category: {type:[String]} |
12 | }); | 13 | }); |
13 | 14 | ||
... | @@ -46,6 +47,10 @@ ProblemSchema.methods.getCorrectNum=function(){ | ... | @@ -46,6 +47,10 @@ ProblemSchema.methods.getCorrectNum=function(){ |
46 | return this.correctNum; | 47 | return this.correctNum; |
47 | } | 48 | } |
48 | 49 | ||
50 | +ProblemSchema.methods.getCount=function(){ | ||
51 | + return this.count; | ||
52 | +} | ||
53 | + | ||
49 | ProblemSchema.methods.getCategory=function(){ | 54 | ProblemSchema.methods.getCategory=function(){ |
50 | return this.category; | 55 | return this.category; |
51 | } | 56 | } | ... | ... |
... | @@ -7,8 +7,18 @@ const Schema = mongoose.Schema; | ... | @@ -7,8 +7,18 @@ const Schema = mongoose.Schema; |
7 | const UserSchema = new Schema({ | 7 | const UserSchema = new Schema({ |
8 | username: String, | 8 | username: String, |
9 | hashedPassword: String, | 9 | hashedPassword: String, |
10 | + userBJID: String, | ||
11 | + sovledBJ: Object, | ||
12 | + solvedBJ_date: Object, | ||
13 | + friendList: [String], | ||
14 | + slackWebHookURL: String, | ||
15 | + goalNum: Number, | ||
10 | }); | 16 | }); |
11 | 17 | ||
18 | +UserSchema.statics.findByUsername = function (username) { | ||
19 | + return this.findOne({ username }); | ||
20 | +}; | ||
21 | + | ||
12 | UserSchema.methods.setPassword = async function (password) { | 22 | UserSchema.methods.setPassword = async function (password) { |
13 | const hash = await bcrypt.hash(password, 10); | 23 | const hash = await bcrypt.hash(password, 10); |
14 | this.hashedPassword = hash; | 24 | this.hashedPassword = hash; |
... | @@ -17,14 +27,13 @@ UserSchema.methods.checkPassword = async function (password) { | ... | @@ -17,14 +27,13 @@ UserSchema.methods.checkPassword = async function (password) { |
17 | const result = await bcrypt.compare(password, this.hashedPassword); | 27 | const result = await bcrypt.compare(password, this.hashedPassword); |
18 | return result; | 28 | return result; |
19 | }; | 29 | }; |
20 | -UserSchema.statics.findByUsername = function (username) { | 30 | + |
21 | - return this.findOne({ username }); | ||
22 | -}; | ||
23 | UserSchema.methods.serialize = function () { | 31 | UserSchema.methods.serialize = function () { |
24 | const data = this.toJSON(); | 32 | const data = this.toJSON(); |
25 | delete data.hashedPassword; | 33 | delete data.hashedPassword; |
26 | return data; | 34 | return data; |
27 | }; | 35 | }; |
36 | + | ||
28 | UserSchema.methods.generateToken = function () { | 37 | UserSchema.methods.generateToken = function () { |
29 | const token = jwt.sign( | 38 | const token = jwt.sign( |
30 | { | 39 | { |
... | @@ -38,5 +47,32 @@ UserSchema.methods.generateToken = function () { | ... | @@ -38,5 +47,32 @@ UserSchema.methods.generateToken = function () { |
38 | ); | 47 | ); |
39 | return token; | 48 | return token; |
40 | }; | 49 | }; |
50 | + | ||
51 | +UserSchema.statics.findByUsername = function (username) { | ||
52 | + return this.findOne({ username }); | ||
53 | +}; | ||
54 | + | ||
55 | +UserSchema.methods.getBJID = function () { | ||
56 | + return this.userBJID; | ||
57 | +}; | ||
58 | + | ||
59 | +UserSchema.methods.getBJdata = function () { | ||
60 | + return this.solvedBJ; | ||
61 | +}; | ||
62 | + | ||
63 | +UserSchema.methods.getslackURL = function () { | ||
64 | + return this.slackWebHookURL; | ||
65 | +}; | ||
66 | + | ||
67 | +UserSchema.methods.getgoalNum = function () { | ||
68 | + return this.goalNum; | ||
69 | +}; | ||
70 | + | ||
71 | +UserSchema.methods.getTodaySovled = function () { | ||
72 | + if (this.solvedBJ_date) { | ||
73 | + return this.solvedBJ_date.presentNum; | ||
74 | + } | ||
75 | +}; | ||
76 | + | ||
41 | const User = mongoose.model("User", UserSchema); | 77 | const User = mongoose.model("User", UserSchema); |
42 | module.exports = User; | 78 | module.exports = User; | ... | ... |
This diff is collapsed. Click to expand it.
-
Mentioned in commit 70f9fca2
-
Please register or login to post a comment