tango-app-api-report 3.0.13-dev → 3.0.15-dev
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { findOneReport, findReport, reportCreate, reportGet, reportGetSingle, reportUpdate } from '../service/report.service.js';
|
|
1
|
+
import { deleteOneReport, findOneReport, findReport, reportCreate, reportGet, reportGetSingle, reportUpdate } from '../service/report.service.js';
|
|
2
2
|
import { appConfig, fileUpload, getObject, getOpenSearchData, insertOpenSearchData, listFileByPath, logger, sendMessageToQueue } from 'tango-app-api-middleware';
|
|
3
3
|
import { findOneUser, getUserNameEmailById } from '../service/user.service.js';
|
|
4
4
|
import { updateOneBasePriceModel } from '../service/basePrice.service.js';
|
|
@@ -107,6 +107,16 @@ export async function updateReport( req, res ) {
|
|
|
107
107
|
}
|
|
108
108
|
}
|
|
109
109
|
|
|
110
|
+
export async function deleteReport( req, res ) {
|
|
111
|
+
try {
|
|
112
|
+
const inputData = req.params;
|
|
113
|
+
await deleteOneReport( { _id: inputData.id } );
|
|
114
|
+
return res.sendSuccess( { result: 'Report has been deleted successfully' } );
|
|
115
|
+
} catch ( error ) {
|
|
116
|
+
return res.sendError( error, 500 );
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
|
|
110
120
|
export async function clientReportList( req, res ) {
|
|
111
121
|
try {
|
|
112
122
|
const inputData = req.body;
|
|
@@ -118,6 +128,7 @@ export async function clientReportList( req, res ) {
|
|
|
118
128
|
$match: {
|
|
119
129
|
$and: [
|
|
120
130
|
{ 'reportConfigs.report': { $eq: true } },
|
|
131
|
+
{ status: { $eq: 'active' } },
|
|
121
132
|
{ clientId: { $in: inputData.clientId } },
|
|
122
133
|
],
|
|
123
134
|
|
package/src/docs/report.docs.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import j2s from 'joi-to-swagger';
|
|
2
2
|
|
|
3
|
-
import { clientListTableSchema, downloadReportSchema, generateReportSchema, getReportListSchema, getReportLogSchema, sendReportSchema, uploadManualReportSchema, uploadManualReportSchema2 } from '../dtos/report.dtos.js';
|
|
3
|
+
import { clientListTableSchema, deleteReportSchemaParam, downloadReportSchema, generateReportSchema, getReportListSchema, getReportLogSchema, getReportSchemaParam, sendReportSchema, uploadManualReportSchema, uploadManualReportSchema2 } from '../dtos/report.dtos.js';
|
|
4
4
|
|
|
5
5
|
export const reportDocs = {
|
|
6
6
|
|
|
@@ -175,5 +175,53 @@ export const reportDocs = {
|
|
|
175
175
|
},
|
|
176
176
|
},
|
|
177
177
|
|
|
178
|
+
'/v3/report/delete-report/{id}': {
|
|
179
|
+
get: {
|
|
180
|
+
tags: [ 'Report' ],
|
|
181
|
+
description: 'delete report by _id',
|
|
182
|
+
operationId: 'delete-report/{id}',
|
|
183
|
+
parameters: [
|
|
184
|
+
{
|
|
185
|
+
in: 'path',
|
|
186
|
+
name: 'id',
|
|
187
|
+
required: true,
|
|
188
|
+
description: 'The _id of the report.',
|
|
189
|
+
scema: j2s( deleteReportSchemaParam ).swagger,
|
|
190
|
+
},
|
|
191
|
+
],
|
|
192
|
+
responses: {
|
|
193
|
+
200: { description: 'Success' },
|
|
194
|
+
401: { description: 'Unauthorized User' },
|
|
195
|
+
422: { description: 'Field Error' },
|
|
196
|
+
500: { description: 'Server Error' },
|
|
197
|
+
204: { description: 'Not Found' },
|
|
198
|
+
},
|
|
199
|
+
},
|
|
200
|
+
},
|
|
201
|
+
|
|
202
|
+
'/v3/report/get-client-reports/{id}': {
|
|
203
|
+
get: {
|
|
204
|
+
tags: [ 'Report' ],
|
|
205
|
+
description: 'Get list of reports by client wise',
|
|
206
|
+
operationId: 'get-client-reports/{id}',
|
|
207
|
+
parameters: [
|
|
208
|
+
{
|
|
209
|
+
in: 'path',
|
|
210
|
+
name: 'id',
|
|
211
|
+
required: true,
|
|
212
|
+
description: 'client Id',
|
|
213
|
+
scema: j2s( getReportSchemaParam ).swagger,
|
|
214
|
+
},
|
|
215
|
+
],
|
|
216
|
+
responses: {
|
|
217
|
+
200: { description: 'Success' },
|
|
218
|
+
401: { description: 'Unauthorized User' },
|
|
219
|
+
422: { description: 'Field Error' },
|
|
220
|
+
500: { description: 'Server Error' },
|
|
221
|
+
204: { description: 'Not Found' },
|
|
222
|
+
},
|
|
223
|
+
},
|
|
224
|
+
},
|
|
225
|
+
|
|
178
226
|
};
|
|
179
227
|
|
package/src/dtos/report.dtos.js
CHANGED
|
@@ -56,6 +56,15 @@ export const updateReportValid = {
|
|
|
56
56
|
|
|
57
57
|
};
|
|
58
58
|
|
|
59
|
+
export const deleteReportSchemaParam = joi.object( {
|
|
60
|
+
id: joi.string().required(),
|
|
61
|
+
} );
|
|
62
|
+
|
|
63
|
+
export const deleteReportValid = {
|
|
64
|
+
params: deleteReportSchemaParam,
|
|
65
|
+
|
|
66
|
+
};
|
|
67
|
+
|
|
59
68
|
|
|
60
69
|
export const clientListTableSchema = joi.object( {
|
|
61
70
|
fromDate: joi.string().required(),
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
|
|
2
2
|
import express from 'express';
|
|
3
3
|
import { authorize, isAllowedSessionHandler, validate } from 'tango-app-api-middleware';
|
|
4
|
-
import { addReportValid, clientListTableValid, downloadReportValid, generateReportValid, getReportListValid, getReportLogValid, getReportValid, getSingleReportValid, sendReportValid, updateReportValid } from '../dtos/report.dtos.js';
|
|
5
|
-
import { clientReportList, createReport, dowloadReport, generateReport, getReport, getReportList, getReportLog, getSingleReport, sendReport, updateBasePrice, updateReport, uploadManualReport } from '../controllers/report.controllers.js';
|
|
4
|
+
import { addReportValid, clientListTableValid, deleteReportValid, downloadReportValid, generateReportValid, getReportListValid, getReportLogValid, getReportValid, getSingleReportValid, sendReportValid, updateReportValid } from '../dtos/report.dtos.js';
|
|
5
|
+
import { clientReportList, createReport, deleteReport, dowloadReport, generateReport, getReport, getReportList, getReportLog, getSingleReport, sendReport, updateBasePrice, updateReport, uploadManualReport } from '../controllers/report.controllers.js';
|
|
6
6
|
import { isFileExist, isFolderExist, isReportEnable } from '../validations/report.validations.js';
|
|
7
7
|
|
|
8
8
|
export const reportRouter = express.Router();
|
|
@@ -21,6 +21,10 @@ reportRouter.put( '/update-report/:id', isAllowedSessionHandler, authorize( { us
|
|
|
21
21
|
{ featureName: 'settings', name: 'configuration', permissions: [ 'isEdit' ] },
|
|
22
22
|
] } ), validate( updateReportValid ), updateReport );
|
|
23
23
|
|
|
24
|
+
reportRouter.get( '/delete-report/:id', isAllowedSessionHandler, authorize( { userType: [ 'tango' ], access: [
|
|
25
|
+
{ featureName: 'settings', name: 'configuration', permissions: [ 'isEdit' ] },
|
|
26
|
+
] } ), validate( deleteReportValid ), deleteReport );
|
|
27
|
+
|
|
24
28
|
|
|
25
29
|
// admin report's overview
|
|
26
30
|
reportRouter.post( '/client-list-table', isAllowedSessionHandler,
|
|
@@ -17,7 +17,9 @@ export function reportGet( { clientId } ) {
|
|
|
17
17
|
},
|
|
18
18
|
{
|
|
19
19
|
'fileName': 1,
|
|
20
|
-
'
|
|
20
|
+
'fileType': 1,
|
|
21
|
+
'email': 1,
|
|
22
|
+
'clientId': 1,
|
|
21
23
|
} );
|
|
22
24
|
}
|
|
23
25
|
|
|
@@ -45,3 +47,7 @@ export function findOneReport( query ) {
|
|
|
45
47
|
export function findReport( query, fields ) {
|
|
46
48
|
return reportModel.find( query, fields );
|
|
47
49
|
}
|
|
50
|
+
|
|
51
|
+
export function deleteOneReport( query ) {
|
|
52
|
+
return reportModel.deleteOne( query );
|
|
53
|
+
}
|
|
@@ -5,7 +5,7 @@ import { findOneClient } from '../service/client.service.js';
|
|
|
5
5
|
export async function isReportEnable( req, res, next ) {
|
|
6
6
|
try {
|
|
7
7
|
const inputData = req.method !== 'GET'? req.body: req.query;
|
|
8
|
-
const getReportName = await findOneClient( { 'clientId': inputData.clientId, 'reportConfigs.report': true }, { '_id': 0, 'reportConfigs.reportName': 1, 'clientName': 1 } );
|
|
8
|
+
const getReportName = await findOneClient( { 'clientId': inputData.clientId, 'status': 'active', 'reportConfigs.report': true }, { '_id': 0, 'reportConfigs.reportName': 1, 'clientName': 1 } );
|
|
9
9
|
if ( !getReportName ) {
|
|
10
10
|
return res.sendError( 'reportName is not there in the client', 204 );
|
|
11
11
|
}
|