Toggle navigation
Toggle navigation
This project
Loading...
Sign in
김건희
/
OSSW_Weather_Briefing
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
Seokjin
2022-06-04 14:21:21 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
2f8ec26f3e4c527ed01a12479c0e6700e76683cc
2f8ec26f
1 parent
6b345837
[UPDATE]ClothesRecommendation
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
24 additions
and
24 deletions
weather_briefing/package-lock.json
weather_briefing/server/clothes.js
weather_briefing/package-lock.json
View file @
2f8ec26
This diff could not be displayed because it is too large.
weather_briefing/server/clothes.js
View file @
2f8ec26
...
...
@@ -21,8 +21,8 @@ let db = mongoose.connect(uri, (err) => {
var
clothesSchema
=
new
mongoose
.
Schema
({
gender
:
Number
,
weather
:
Number
,
top
:
String
,
bottom
:
String
top
:
Array
,
bottom
:
Array
});
var
Clothes
=
mongoose
.
model
(
'clothes'
,
clothesSchema
);
...
...
@@ -30,35 +30,35 @@ var Clothes = mongoose.model('clothes', clothesSchema);
app
.
use
(
bodyParser
.
json
());
app
.
use
(
bodyParser
.
urlencoded
({
limit
:
'1gb'
,
extended
:
false
}));
app
.
post
(
'/api/addstyple'
,
(
req
,
res
)
=>
{
//
app.post('/api/addstyple', (req, res) => {
Clothes
.
findOne
({
gender
:
req
.
body
.
gender
,
weather
:
req
.
body
.
weather
,
top
:
req
.
top
,
bottom
:
req
.
bottom
},
(
err
,
clothes
)
=>
{
if
(
err
)
return
res
.
status
(
500
).
json
({
registerSuccess
:
'-1'
});
else
if
(
clothes
){
res
.
json
({
registerSuccess
:
'0'
});
}
else
{
const
new_user
=
new
Clothes
(
req
.
body
);
new_user
.
save
((
err
)
=>
{
if
(
err
)
return
res
.
status
(
500
).
json
({
registerSuccess
:
'-1'
});
else
return
res
.
status
(
200
).
json
({
registerSuccess
:
'1'
});
});
}
});
});
//
Clothes.findOne({ gender: req.body.gender, weather: req.body.weather, top:req.top,bottom:req.bottom }, (err, clothes) => {
//
if (err) return res.status(500).json({ registerSuccess: '-1'});
//
else if (clothes){
//
res.json({ registerSuccess: '0'});
//
}
//
else{
//
const new_user = new Clothes(req.body);
//
new_user.save((err) => {
//
if (err) return res.status(500).json({ registerSuccess: '-1'});
//
else return res.status(200).json({ registerSuccess: '1'});
//
});
//
}
//
});
//
});
app
.
post
(
'/api/clothes'
,
(
req
,
res
)
=>
{
Clothes
.
findOne
({
gender
:
req
.
body
.
gender
,
weather
:
req
.
body
.
weather
},
(
err
,
clothes
)
=>
{
if
(
err
)
return
res
.
status
(
500
).
json
({
loginSuccess
:
false
});
let
randt
=
Math
.
floor
(
Math
.
random
()
*
clothes
.
top
.
length
);
let
randb
=
Math
.
floor
(
Math
.
random
()
*
clothes
.
bottom
.
length
);
if
(
err
)
return
res
.
status
(
500
).
json
({
MatchingSuccess
:
false
});
else
if
(
clothes
)
{
console
.
log
(
clothes
);
// logid={id:clothes.id,password:clothes.password,name:clothes.name,gender:clothes.gender};
return
res
.
status
(
200
).
json
({
loginSuccess
:
true
});
return
res
.
status
(
200
).
json
({
top
:
clothes
.
top
[
randt
],
bottom
:
clothes
.
bottom
[
randb
]});
}
else
return
res
.
status
(
404
).
json
({
login
Success
:
false
});
else
return
res
.
status
(
404
).
json
({
Matching
Success
:
false
});
});
});
...
...
Please
register
or
login
to post a comment