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
64ac1a89
Commit
64ac1a89
authored
Feb 07, 2020
by
Piyaphorn Arphornsri
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add
parent
b5bfc970
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
82 additions
and
0 deletions
+82
-0
index.js
Backend/controllers/promotion/index.js
+65
-0
index.js
Backend/routers/index.js
+3
-0
index.js
Backend/routers/promotion/index.js
+14
-0
No files found.
Backend/controllers/promotion/index.js
0 → 100644
View file @
64ac1a89
const
Promotion
=
require
(
"../../models/promotion"
);
exports
.
addpromotion
=
async
(
req
,
res
)
=>
{
try
{
const
addpromotionData
=
req
.
body
;
console
.
log
(
addpromotionData
);
await
Promotion
.
create
(
addpromotionData
);
res
.
send
(
"create"
);
}
catch
(
err
)
{
console
.
log
(
err
);
res
.
sendStatus
(
401
);
}
};
exports
.
getPromotion
=
async
(
req
,
res
)
=>
{
try
{
let
promotion
=
await
Promotion
.
findAll
();
res
.
status
(
200
).
send
(
"success"
);
}
catch
(
err
)
{
console
.
log
(
err
);
res
.
sendStatus
(
401
);
}
};
exports
.
deletePromotion
=
async
(
req
,
res
)
=>
{
try
{
const
promotionId
=
req
.
params
.
shopId
;
await
Promotion
.
destroy
({
where
:
{
id
:
promotionId
}
});
res
.
status
(
200
).
send
(
"success"
);
}
catch
(
err
)
{
console
.
log
(
err
);
res
.
sendStatus
(
401
);
}
};
exports
.
getPromotionId
=
async
(
req
,
res
)
=>
{
try
{
const
promotionId
=
req
.
params
.
id
;
let
promotion
=
await
Promotion
.
findOne
({
where
:
{
id
:
promotionId
}
});
res
.
status
(
200
).
send
(
"success"
);
}
catch
(
err
)
{
console
.
log
(
err
);
res
.
sendStatus
(
401
);
}
};
exports
.
updatePromotion
=
async
(
req
,
res
)
=>
{
try
{
const
promotionData
=
req
.
body
;
const
id
=
req
.
params
.
id
;
await
promotion
.
update
(
promotionData
,
{
where
:
{
id
:
id
}
});
res
.
status
(
200
).
send
({
status
:
"done"
});
}
catch
(
err
)
{
console
.
log
(
err
);
res
.
sendStatus
(
401
);
}
};
Backend/routers/index.js
View file @
64ac1a89
const
auth
=
require
(
'./auth'
);
const
auth
=
require
(
'./auth'
);
const
list
=
require
(
'./list'
);
const
list
=
require
(
'./list'
);
const
shop
=
require
(
'./shop'
)
const
shop
=
require
(
'./shop'
)
const
promotion
=
require
(
'./promotion'
);
module
.
exports
=
{
module
.
exports
=
{
auth
,
auth
,
list
,
list
,
shop
,
shop
,
promotion
,
}
}
\ No newline at end of file
Backend/routers/promotion/index.js
0 → 100644
View file @
64ac1a89
const
express
=
require
(
"express"
);
const
router
=
express
.
Router
();
const
promotiomController
=
require
(
"../../controllers/promotion"
);
router
.
post
(
"/add"
,
promotiomController
.
addpromotion
);
router
.
get
(
'/all'
,
promotiomController
.
getPromotion
);
router
.
delete
(
'/delete/:promotionId'
,
promotiomController
.
deletePromotion
);
router
.
get
(
'/getListId/:id'
,
promotiomController
.
getPromotionId
);
router
.
put
(
'/updateList/id'
,
promotiomController
.
updatePromotion
);
module
.
exports
=
router
;
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