Fix Bug
This commit is contained in:
@@ -9,12 +9,13 @@ module.exports.createAward = [
|
||||
body('score').notEmpty().isInt().withMessage(_sr.fa.required.field),
|
||||
body('title').notEmpty().isString().withMessage(_sr.fa.required.field),
|
||||
body('desc').notEmpty().isString().withMessage(_sr.fa.required.field),
|
||||
body('expireDate').notEmpty().isDate().withMessage(_sr.fa.required.field),
|
||||
body('expireDate').notEmpty().withMessage(_sr.fa.required.field),
|
||||
],
|
||||
checkValidations(validationResult),
|
||||
async (req, res) => {
|
||||
const { score, title, desc, expireData } = req.body;
|
||||
const award = await Award.create({ score, title, desc, expireData })
|
||||
const { score, title, desc, expireDate } = req.body;
|
||||
const fixDate = new Date(expireDate)
|
||||
const award = await Award.create({ score, title, desc, expireDate:fixDate })
|
||||
res.status(201).json({
|
||||
msg: _sr.fa.response.success_save,
|
||||
data: award
|
||||
@@ -26,7 +27,7 @@ module.exports.createAward = [
|
||||
|
||||
module.exports.findAllUser = async (req, res) => {
|
||||
const toDay = new Date()
|
||||
const data = await Award.find({$lt: {expireDate: toDay}})
|
||||
const data = await Award.find({expireDate: {$gt: toDay}})
|
||||
res.status(200).json(data)
|
||||
}
|
||||
|
||||
@@ -57,11 +58,11 @@ module.exports.update =[
|
||||
body('score').notEmpty().isInt().withMessage(_sr.fa.required.field),
|
||||
body('title').notEmpty().isString().withMessage(_sr.fa.required.field),
|
||||
body('desc').notEmpty().isString().withMessage(_sr.fa.required.field),
|
||||
body('expireDate').notEmpty().isDate().withMessage(_sr.fa.required.field),
|
||||
body('expireDate').notEmpty().withMessage(_sr.fa.required.field),
|
||||
],
|
||||
checkValidations(validationResult),
|
||||
async (req, res) => {
|
||||
const { score, title, desc, expireData } = req.body;
|
||||
const { score, title, desc, expireDate } = req.body;
|
||||
const data = await Award.findById(req.params.id)
|
||||
if (!data) {
|
||||
res.status(404).json({ msg: _sr.fa.not_found.item_id })
|
||||
@@ -69,7 +70,7 @@ module.exports.update =[
|
||||
data.score = score;
|
||||
data.title = title;
|
||||
data.desc = desc;
|
||||
data.expireData = expireData;
|
||||
data.expireDate = new Date(expireDate)
|
||||
data.save()
|
||||
res.status(200).json({
|
||||
msg: _sr.fa.response.success_save,
|
||||
|
||||
Reference in New Issue
Block a user