Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
5
59110440259
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
senior-prj-62
59110440259
Commits
7fff7e5b
Commit
7fff7e5b
authored
Feb 10, 2020
by
Piyaphorn Arphornsri
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add db
parent
64ac1a89
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
149 additions
and
30 deletions
+149
-30
index.js
Backend/controllers/booking/index.js
+27
-0
index.js
Backend/controllers/review/index.js
+65
-0
index.js
Backend/models/booking/index.js
+1
-1
index.js
Backend/models/reviews/index.js
+1
-1
index.js
Backend/routers/booking/index.js
+12
-0
index.js
Backend/routers/index.js
+13
-10
index.js
Backend/routers/promotion/index.js
+2
-2
index.js
Backend/routers/review/index.js
+14
-0
index.js
Backend/routers/shop/index.js
+2
-2
server.js
Backend/server.js
+12
-14
No files found.
Backend/controllers/booking/index.js
0 → 100644
View file @
7fff7e5b
const
Booking
=
require
(
"../../models/booking"
);
exports
.
addbooking
=
async
(
req
,
res
)
=>
{
try
{
const
addbookingData
=
req
.
body
;
console
.
log
(
addbookingData
);
await
Booking
.
create
(
addbookingData
);
res
.
send
(
"create"
);
}
catch
(
err
)
{
console
.
log
(
err
);
res
.
sendStatus
(
401
);
}
};
exports
.
getBooking
=
async
(
req
,
res
)
=>
{
try
{
let
booking
=
await
Booking
.
findAll
();
res
.
status
(
200
).
send
(
"success"
);
}
catch
(
err
)
{
console
.
log
(
err
);
res
.
sendStatus
(
401
);
}
};
Backend/controllers/review/index.js
0 → 100644
View file @
7fff7e5b
const
Review
=
require
(
"../../models/reviews"
);
exports
.
addreview
=
async
(
req
,
res
)
=>
{
try
{
const
addreviewData
=
req
.
body
;
console
.
log
(
addreviewData
);
await
Review
.
create
(
addreviewData
);
res
.
send
(
"create"
);
}
catch
(
err
)
{
console
.
log
(
err
);
res
.
sendStatus
(
401
);
}
};
exports
.
getReview
=
async
(
req
,
res
)
=>
{
try
{
let
review
=
await
Review
.
findAll
();
res
.
status
(
200
).
send
(
"success"
);
}
catch
(
err
)
{
console
.
log
(
err
);
res
.
sendStatus
(
401
);
}
};
exports
.
deleteReview
=
async
(
req
,
res
)
=>
{
try
{
const
reviewId
=
req
.
params
.
reviewId
;
await
Review
.
destroy
({
where
:
{
id
:
reviewId
}
});
res
.
status
(
200
).
send
(
"success"
);
}
catch
(
err
)
{
console
.
log
(
err
);
res
.
sendStatus
(
401
);
}
};
exports
.
getReviewId
=
async
(
req
,
res
)
=>
{
try
{
const
reviewId
=
req
.
params
.
id
;
let
review
=
await
Review
.
findOne
({
where
:
{
id
:
reviewId
}
});
res
.
status
(
200
).
send
(
"success"
);
}
catch
(
err
)
{
console
.
log
(
err
);
res
.
sendStatus
(
401
);
}
};
exports
.
updateReview
=
async
(
req
,
res
)
=>
{
try
{
const
reviewData
=
req
.
body
;
const
id
=
req
.
params
.
id
;
await
review
.
update
(
reviewData
,
{
where
:
{
id
:
id
}
});
res
.
status
(
200
).
send
({
status
:
"done"
});
}
catch
(
err
)
{
console
.
log
(
err
);
res
.
sendStatus
(
401
);
}
};
Backend/models/booking/index.js
View file @
7fff7e5b
...
...
@@ -7,7 +7,7 @@ module.exports = db.sequelize.define("bookings", {
primaryKey
:
true
,
autoIncrement
:
true
},
user
:
{
name
:
{
type
:
Sequelize
.
INTEGER
,
references
:
'users'
,
referencesKey
:
'id'
...
...
Backend/models/reviews/index.js
View file @
7fff7e5b
const
Sequelize
=
require
(
"sequelize"
);
const
db
=
require
(
"../../db"
);
module
.
exports
=
db
.
sequelize
.
define
(
"revi
we
s"
,
{
module
.
exports
=
db
.
sequelize
.
define
(
"revi
ew
s"
,
{
id
:
{
type
:
Sequelize
.
INTEGER
,
primaryKey
:
true
,
...
...
Backend/routers/booking/index.js
0 → 100644
View file @
7fff7e5b
const
express
=
require
(
"express"
);
const
router
=
express
.
Router
();
const
bookingController
=
require
(
"
\
../../controllers/booking"
);
router
.
post
(
"/add"
,
bookingController
.
addbooking
);
router
.
get
(
'/all'
,
bookingController
.
getBooking
);
module
.
exports
=
router
;
Backend/routers/index.js
View file @
7fff7e5b
const
auth
=
require
(
'./auth'
);
const
list
=
require
(
'./list'
);
const
shop
=
require
(
'./shop'
)
const
promotion
=
require
(
'./promotion'
);
const
auth
=
require
(
"./auth"
);
const
list
=
require
(
"./list"
);
const
shop
=
require
(
"./shop"
);
const
promotion
=
require
(
"./promotion"
);
const
review
=
require
(
"./review"
);
const
booking
=
require
(
"./booking"
);
module
.
exports
=
{
auth
,
list
,
shop
,
promotion
,
}
\ No newline at end of file
auth
,
list
,
shop
,
promotion
,
review
,
booking
};
Backend/routers/promotion/index.js
View file @
7fff7e5b
...
...
@@ -7,8 +7,8 @@ const promotiomController = require("../../controllers/promotion");
router
.
post
(
"/add"
,
promotiomController
.
addpromotion
);
router
.
get
(
'/all'
,
promotiomController
.
getPromotion
);
router
.
delete
(
'/delete/:promotionId'
,
promotiomController
.
deletePromotion
);
router
.
get
(
'/get
List
Id/:id'
,
promotiomController
.
getPromotionId
);
router
.
put
(
'/update
List
/id'
,
promotiomController
.
updatePromotion
);
router
.
get
(
'/get
Promotion
Id/:id'
,
promotiomController
.
getPromotionId
);
router
.
put
(
'/update
Promotion
/id'
,
promotiomController
.
updatePromotion
);
module
.
exports
=
router
;
Backend/routers/review/index.js
0 → 100644
View file @
7fff7e5b
const
express
=
require
(
"express"
);
const
router
=
express
.
Router
();
const
reviewController
=
require
(
"../../controllers/review"
);
router
.
post
(
"/add"
,
reviewController
.
addreview
);
router
.
get
(
'/all'
,
reviewController
.
getReview
);
router
.
delete
(
'/delete/:reviewId'
,
reviewController
.
deleteReview
);
router
.
get
(
'/getReviewId/:id'
,
reviewController
.
getReviewId
);
router
.
put
(
'/updateReview/id'
,
reviewController
.
updateReview
);
module
.
exports
=
router
;
Backend/routers/shop/index.js
View file @
7fff7e5b
...
...
@@ -6,8 +6,8 @@ const shopController = require("../../controllers/shop");
router
.
post
(
"/add"
,
shopController
.
addShop
);
router
.
get
(
'/all'
,
shopController
.
getShop
);
router
.
delete
(
'/delete/:shopId'
,
shopController
.
updateShop
);
router
.
get
(
'/get
List
Id/:id'
,
shopController
.
getShopId
);
router
.
put
(
'/update
List
/id'
,
shopController
.
updateShop
);
router
.
get
(
'/get
Shop
Id/:id'
,
shopController
.
getShopId
);
router
.
put
(
'/update
shop
/id'
,
shopController
.
updateShop
);
module
.
exports
=
router
;
Backend/server.js
View file @
7fff7e5b
const
express
=
require
(
'express'
);
const
router
=
require
(
'./routers'
);
const
cors
=
require
(
'cors'
);
const
bodyParser
=
require
(
'body-parser'
);
const
express
=
require
(
"express"
);
const
router
=
require
(
"./routers"
);
const
cors
=
require
(
"cors"
);
const
bodyParser
=
require
(
"body-parser"
);
const
port
=
process
.
env
.
PORT
||
9000
;
const
app
=
express
();
app
.
use
(
cors
());
app
.
use
(
bodyParser
.
json
());
app
.
use
(
bodyParser
.
urlencoded
({
extended
:
false
}))
app
.
use
(
'/api/auth'
,
router
.
auth
);
app
.
use
(
'/api/list'
,
router
.
list
);
app
.
use
(
'/api/shop'
,
router
.
shop
);
app
.
use
(
'/api/promotion'
,
router
.
promotion
);
app
.
use
(
bodyParser
.
urlencoded
({
extended
:
false
}));
app
.
use
(
"/api/auth"
,
router
.
auth
);
app
.
use
(
"/api/list"
,
router
.
list
);
app
.
use
(
"/api/shop"
,
router
.
shop
);
app
.
use
(
"/api/promotion"
,
router
.
promotion
);
app
.
use
(
"/api/review"
,
router
.
review
);
app
.
use
(
"/api/booking"
,
router
.
booking
);
app
.
listen
(
port
,
()
=>
{
console
.
log
(
'Express server listening on port '
+
port
)
console
.
log
(
"Express server listening on port "
+
port
);
});
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment