a
This commit is contained in:
parent
8ad1465c7d
commit
d66d41c02e
@ -39,7 +39,9 @@ const generateControllers = (service, extraControllers = {}, options = {}) => {
|
|||||||
|
|
||||||
const params = extractParamsFromRequest(req, res, _options.params.find);
|
const params = extractParamsFromRequest(req, res, _options.params.find);
|
||||||
try {
|
try {
|
||||||
|
console.log('parammmmmmmasr', params);
|
||||||
const result = await service.fetchAll(params, buildContext(req, config));
|
const result = await service.fetchAll(params, buildContext(req, config));
|
||||||
|
console.log('controllllerrrrrrrrrrrrrrrr', result);
|
||||||
return handleResultResponse(result.rows, result.count, params, res);
|
return handleResultResponse(result.rows, result.count, params, res);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
return handleErrorResponse(_options.MODULE_NAME, 'find', error, res)
|
return handleErrorResponse(_options.MODULE_NAME, 'find', error, res)
|
||||||
|
|||||||
@ -54,7 +54,7 @@ function getTotalCount(result) {
|
|||||||
const toType = function (obj) {
|
const toType = function (obj) {
|
||||||
return ({}).toString.call(obj).match(/\s([a-zA-Z]+)/)[1].toLowerCase()
|
return ({}).toString.call(obj).match(/\s([a-zA-Z]+)/)[1].toLowerCase()
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (toType(result)) {
|
switch (toType(result)) {
|
||||||
case 'boolean':
|
case 'boolean':
|
||||||
return 1;
|
return 1;
|
||||||
@ -131,6 +131,7 @@ function handleErrorResponse(controllerName, methodName, error, res) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function handleResultResponse(result, totalCount = null, params, res, statusCode = httpStatus.OK) {
|
function handleResultResponse(result, totalCount = null, params, res, statusCode = httpStatus.OK) {
|
||||||
|
console.log('handleResultResponse(result>>>>>>>>>>>>>>', result, getTotalCount(result));
|
||||||
setPaginationInfo((totalCount) ? totalCount : getTotalCount(result), res);
|
setPaginationInfo((totalCount) ? totalCount : getTotalCount(result), res);
|
||||||
res.status(statusCode).send(typeof result == 'number' ? result.toString() : result);
|
res.status(statusCode).send(typeof result == 'number' ? result.toString() : result);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -31,7 +31,7 @@ routes.get('/events',
|
|||||||
(req, res, next) => {
|
(req, res, next) => {
|
||||||
if (!req.body.city)
|
if (!req.body.city)
|
||||||
return eventController.find({
|
return eventController.find({
|
||||||
scopes: ['defaultScope', 'includeVenue', 'includeMultimedias', 'includeDetails'],
|
// scopes: ['defaultScope', 'includeVenue', 'includeMultimedias', 'includeDetails'],
|
||||||
})(req, res, next)
|
})(req, res, next)
|
||||||
else
|
else
|
||||||
return eventController.find({
|
return eventController.find({
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user