Toggle navigation
Toggle navigation
This project
Loading...
Sign in
khusat
/
khusat-server
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-11-14 04:11:34 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
11c951cdf2709f9e9c98c6d54aef641fe838597f
11c951cd
1 parent
50448331
server finished
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
33 additions
and
6 deletions
khusat_DB/job_db.xlsx
package.json
src/index.js
src/router/index.js
khusat_DB/job_db.xlsx
View file @
11c951c
No preview for this file type
package.json
View file @
11c951c
...
...
@@ -7,6 +7,7 @@
"license"
:
"MIT"
,
"dependencies"
:
{
"body-parser"
:
"^1.19.0"
,
"cors"
:
"^2.8.5"
,
"express"
:
"^4.17.1"
,
"mongoose"
:
"^5.10.14"
,
"nodemon"
:
"^2.0.6"
...
...
src/index.js
View file @
11c951c
const
express
=
require
(
'express'
);
const
app
=
express
();
// const cors = require('cors');
const
port
=
8000
;
const
mongoose
=
require
(
'mongoose'
);
...
...
@@ -7,6 +8,19 @@ const bodyParser = require('body-parser');
app
.
use
(
bodyParser
.
urlencoded
({
extended
:
true
}));
app
.
use
(
bodyParser
.
json
());
// app.use(cors());
// app.all('/*', function(req, res, next) {
// res.header("Access-Control-Allow-Origin", "*");
// res.header("Access-Control-Allow-Headers", "X-Requested-With");
// next();
// });
// app.all('/*', function(req, res, next) {
// res.header("Access-Control-Allow-Origin", "*");
// res.header("Access-Control-Allow-Headers", "X-Requested-With");
// next();
// });
const
db
=
mongoose
.
connection
;
db
.
on
(
'error'
,
console
.
error
);
...
...
@@ -15,6 +29,7 @@ db.once('open', function(){
console
.
log
(
"Connected to mongod server"
);
});
const
router
=
require
(
'./router'
)(
app
);
...
...
src/router/index.js
View file @
11c951c
...
...
@@ -160,25 +160,36 @@ module.exports = function(app)
}
}
console
.
log
(
fight
,
detail
,
traffic
,
control
,
support
,
activity
);
//
console.log(fight, detail, traffic, control, support, activity);
const
recommandedJob
=
await
jobRecommend
(
fight
,
detail
,
traffic
,
control
,
support
,
activity
);
// TODO : recommand job
//
const jobList = await Job.find({high: recommandedJob}).exec();
const
jobList
=
await
Job
.
find
({
high
:
recommandedJob
}).
exec
();
//
const rand = Math.floor(Math.random() * jobList.length);
//
const result = jobList[rand];
const
rand
=
Math
.
floor
(
Math
.
random
()
*
jobList
.
length
);
const
result
=
jobList
[
rand
];
res
.
send
(
recommandedJob
);
//
res.send(result);
//
res.send(recommandedJob);
res
.
send
(
result
);
});
app
.
post
(
'/addJobs'
,
async
(
req
,
res
,
next
)
=>
{
// 보직 추가하는 api
const
datas
=
req
.
body
;
for
(
let
i
=
0
;
i
<
datas
.
length
;
i
++
){
const
data
=
new
Job
();
data
.
num
=
datas
[
i
].
num
;
data
.
high
=
datas
[
i
].
high
;
data
.
low
=
datas
[
i
].
low
;
data
.
description
=
datas
[
i
].
description
;
data
.
image
=
datas
[
i
].
image
;
await
data
.
save
();
}
res
.
send
(
datas
[
0
]);
});
app
.
post
(
'/addQuestions'
,
async
(
req
,
res
,
next
)
=>
{
// 질문 추가하는 api
...
...
Please
register
or
login
to post a comment