From 728c7eed23d5fb02bba7c0acf588bca58096009f Mon Sep 17 00:00:00 2001 From: tungd0 Date: Tue, 16 May 2023 03:19:32 +0000 Subject: [PATCH] fix list user error --- src/api/controllers/v1/user.controller.js | 44 +++++++++++++++-------- 1 file changed, 30 insertions(+), 14 deletions(-) diff --git a/src/api/controllers/v1/user.controller.js b/src/api/controllers/v1/user.controller.js index 7eedf36..99af8e9 100644 --- a/src/api/controllers/v1/user.controller.js +++ b/src/api/controllers/v1/user.controller.js @@ -43,21 +43,37 @@ exports.create = async (req, res, next) => { exports.list = async (req, res, next) => { req.query.services = User.Services.USER; // console.log(req.query.services); - User.list( { - service : "user", - is_active: true - } - ).then(result => { - res.json({ - code: 0, - count: req.totalRecords, - data: result.map( - x => User.transform(x) - ) + // User.list( { + // service : "user", + // is_active: true + // } + // ).then(result => { + // res.json({ + // code: 0, + // count: req.totalRecords, + // data: result.map( + // x => User.transform(x) + // ) + // }); + // }).catch(ex => { + // ErrorHandler(ex, req, res, next); + // }); + + + return User.findAll({ + where : { + service : "user", + is_active: true + } + }).then(result => { + res.json({ + code: 0, + count: req.totalRecords, + data: result + }); + }).catch(ex => { + ErrorHandler(ex, req, res, next); }); - }).catch(ex => { - ErrorHandler(ex, req, res, next); - }); }; /**