tango-app-api-audit 1.0.29 → 1.0.31
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 +2 -2
- package/src/controllers/auditMetrics.controllers.js +37 -4
- package/src/controllers/store.controllers.js +42 -42
- package/src/controllers/user.controllers.js +41 -41
- package/src/docs/auditMetrics.docs.js +2 -2
- package/src/docs/store.docs.js +27 -27
- package/src/docs/user.docs.js +33 -33
- package/src/dtos/auditMetrics.dtos.js +2 -2
- package/src/dtos/store.dtos.js +14 -14
- package/src/dtos/user.dtos.js +14 -14
- package/src/routes/store.routes.js +10 -10
- package/src/routes/user.routes.js +9 -9
- package/src/validation/audit.validation.js +40 -4
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tango-app-api-audit",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.31",
|
|
4
4
|
"description": "audit & audit metrics apis",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"type": "module",
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
"nodemon": "^3.1.3",
|
|
26
26
|
"swagger-ui-express": "^5.0.1",
|
|
27
27
|
"tango-api-schema": "^2.0.138",
|
|
28
|
-
"tango-app-api-middleware": "^3.1.
|
|
28
|
+
"tango-app-api-middleware": "^3.1.27",
|
|
29
29
|
"winston": "^3.13.0",
|
|
30
30
|
"winston-daily-rotate-file": "^5.0.0"
|
|
31
31
|
},
|
|
@@ -8,7 +8,8 @@ import dayjs from 'dayjs';
|
|
|
8
8
|
import { createAssignAudit } from '../service/assignAudit.service.js';
|
|
9
9
|
import { countDocumentsStore } from '../service/store.service.js';
|
|
10
10
|
import { findOneClient } from '../service/client.service.js';
|
|
11
|
-
import { getAuditImageData, zipDownloadImage } from '../validation/audit.validation.js';
|
|
11
|
+
import { getAuditFilterData, getAuditImageData, zipDownloadImage } from '../validation/audit.validation.js';
|
|
12
|
+
import { getReauditImg } from './audit.controllers.js';
|
|
12
13
|
// import { listQueue } from 'tango-app-api-middleware/src/utils/aws/sqs.js';
|
|
13
14
|
|
|
14
15
|
export async function userAuditHistory( req, res ) {
|
|
@@ -1302,24 +1303,56 @@ export async function auditImages( req, res ) {
|
|
|
1302
1303
|
try {
|
|
1303
1304
|
const inputData = req.query;
|
|
1304
1305
|
let auditImageDownload = '';
|
|
1305
|
-
switch ( inputData.
|
|
1306
|
+
switch ( inputData.imageType ) {
|
|
1306
1307
|
case 'BC':
|
|
1307
1308
|
const auditImageBC = await getAuditImageData( inputData );
|
|
1309
|
+
if ( auditImageBC?.errorCode ) {
|
|
1310
|
+
const error = auditImageBC?.errorMsg;
|
|
1311
|
+
const code = auditImageBC?.errorCode;
|
|
1312
|
+
return res.sendError( { error: error }, code );
|
|
1313
|
+
}
|
|
1308
1314
|
|
|
1309
1315
|
if ( inputData.export==true ) {
|
|
1310
1316
|
auditImageDownload= await zipDownloadImage( auditImageBC );
|
|
1311
1317
|
// Set response headers for the zip file
|
|
1312
1318
|
res.set( 'Content-Type', 'application/zip' );
|
|
1313
|
-
res.set( 'Content-Disposition', `attachment; filename=${inputData.storeId}_${inputData.fileDate}_${inputData.
|
|
1319
|
+
res.set( 'Content-Disposition', `attachment; filename=${inputData.storeId}_${inputData.fileDate}_${inputData.imageType}.zip` );
|
|
1314
1320
|
|
|
1315
1321
|
// Send the zip file as the API response
|
|
1316
1322
|
return res.send( auditImageDownload );
|
|
1317
1323
|
}
|
|
1318
|
-
|
|
1324
|
+
res.sendSuccess( { result: auditImageBC } );
|
|
1319
1325
|
|
|
1320
1326
|
break;
|
|
1321
1327
|
|
|
1328
|
+
case 'AC':
|
|
1329
|
+
|
|
1330
|
+
const [ filterData, auditImageAC ] = await Promise.all( [ getAuditFilterData( inputData ), getAuditImageData( inputData ) ] );
|
|
1331
|
+
|
|
1332
|
+
if ( filterData?.errorCode || auditImageAC?.errorCode ) {
|
|
1333
|
+
const error = filterData?.errorMsg || auditImageAC.errorMsg;
|
|
1334
|
+
const code = filterData?.errorCode || auditImageAC.errorCode;
|
|
1335
|
+
return res.sendError( { error: error }, code );
|
|
1336
|
+
}
|
|
1337
|
+
|
|
1338
|
+
const reauditImg = await getReauditImg( filterData, auditImageAC );
|
|
1339
|
+
|
|
1340
|
+
logger.info( { filterData: filterData } );
|
|
1341
|
+
logger.info( { auditImageAC: auditImageAC } );
|
|
1342
|
+
logger.info( { reauditImg: reauditImg } );
|
|
1343
|
+
if ( inputData.export==true ) {
|
|
1344
|
+
auditImageDownload= await zipDownloadImage( reauditImg );
|
|
1345
|
+
// Set response headers for the zip file
|
|
1346
|
+
res.set( 'Content-Type', 'application/zip' );
|
|
1347
|
+
res.set( 'Content-Disposition', `attachment; filename=${inputData.storeId}_${inputData.fileDate}_${inputData.imageType}.zip` );
|
|
1348
|
+
|
|
1349
|
+
// Send the zip file as the API response
|
|
1350
|
+
return res.send( auditImageDownload );
|
|
1351
|
+
}
|
|
1352
|
+
res.sendSuccess( { result: reauditImg } );
|
|
1353
|
+
break;
|
|
1322
1354
|
default:
|
|
1355
|
+
res.sendError( 'No Data Found', 204 );
|
|
1323
1356
|
break;
|
|
1324
1357
|
}
|
|
1325
1358
|
|
|
@@ -1,42 +1,42 @@
|
|
|
1
|
-
import { logger } from 'tango-app-api-middleware';
|
|
2
|
-
import { aggregateStore } from '../service/store.service.js';
|
|
3
|
-
|
|
4
|
-
export async function auditStoreList( req, res ) {
|
|
5
|
-
try {
|
|
6
|
-
const inputData = req.body;
|
|
7
|
-
const query =[
|
|
8
|
-
{
|
|
9
|
-
$match: {
|
|
10
|
-
clientId: { $in: inputData.clientId },
|
|
11
|
-
},
|
|
12
|
-
},
|
|
13
|
-
{
|
|
14
|
-
$project: {
|
|
15
|
-
_id: 0,
|
|
16
|
-
clientId: 1,
|
|
17
|
-
storeId: 1,
|
|
18
|
-
storeName: 1,
|
|
19
|
-
},
|
|
20
|
-
},
|
|
21
|
-
];
|
|
22
|
-
|
|
23
|
-
const count = await aggregateStore( query );
|
|
24
|
-
if ( count.length == 0 ) {
|
|
25
|
-
return res.sendSuccess( { result: [], count: 0 } );
|
|
26
|
-
}
|
|
27
|
-
if ( inputData.limit ) {
|
|
28
|
-
const offset = inputData.offset ? ( inputData.offset - 1 ) * inputData.limit : 0;
|
|
29
|
-
query.push(
|
|
30
|
-
{ $skip: offset },
|
|
31
|
-
{ $limit: limit },
|
|
32
|
-
);
|
|
33
|
-
}
|
|
34
|
-
const result = await aggregateStore( query );
|
|
35
|
-
|
|
36
|
-
return res.sendSuccess( { result: result, count: count.length } );
|
|
37
|
-
} catch ( error ) {
|
|
38
|
-
const err = error.message || 'Internal Server Error';
|
|
39
|
-
logger.info( { error: error, messgae: req.body, function: 'auditStoreList' } );
|
|
40
|
-
return res.sendError( err, 500 );
|
|
41
|
-
}
|
|
42
|
-
}
|
|
1
|
+
import { logger } from 'tango-app-api-middleware';
|
|
2
|
+
import { aggregateStore } from '../service/store.service.js';
|
|
3
|
+
|
|
4
|
+
export async function auditStoreList( req, res ) {
|
|
5
|
+
try {
|
|
6
|
+
const inputData = req.body;
|
|
7
|
+
const query =[
|
|
8
|
+
{
|
|
9
|
+
$match: {
|
|
10
|
+
clientId: { $in: inputData.clientId },
|
|
11
|
+
},
|
|
12
|
+
},
|
|
13
|
+
{
|
|
14
|
+
$project: {
|
|
15
|
+
_id: 0,
|
|
16
|
+
clientId: 1,
|
|
17
|
+
storeId: 1,
|
|
18
|
+
storeName: 1,
|
|
19
|
+
},
|
|
20
|
+
},
|
|
21
|
+
];
|
|
22
|
+
|
|
23
|
+
const count = await aggregateStore( query );
|
|
24
|
+
if ( count.length == 0 ) {
|
|
25
|
+
return res.sendSuccess( { result: [], count: 0 } );
|
|
26
|
+
}
|
|
27
|
+
if ( inputData.limit ) {
|
|
28
|
+
const offset = inputData.offset ? ( inputData.offset - 1 ) * inputData.limit : 0;
|
|
29
|
+
query.push(
|
|
30
|
+
{ $skip: offset },
|
|
31
|
+
{ $limit: limit },
|
|
32
|
+
);
|
|
33
|
+
}
|
|
34
|
+
const result = await aggregateStore( query );
|
|
35
|
+
|
|
36
|
+
return res.sendSuccess( { result: result, count: count.length } );
|
|
37
|
+
} catch ( error ) {
|
|
38
|
+
const err = error.message || 'Internal Server Error';
|
|
39
|
+
logger.info( { error: error, messgae: req.body, function: 'auditStoreList' } );
|
|
40
|
+
return res.sendError( err, 500 );
|
|
41
|
+
}
|
|
42
|
+
}
|
|
@@ -1,41 +1,41 @@
|
|
|
1
|
-
import { logger } from 'tango-app-api-middleware';
|
|
2
|
-
import { aggregateUser } from '../service/user.service.js';
|
|
3
|
-
|
|
4
|
-
export async function auditUserList( req, res ) {
|
|
5
|
-
try {
|
|
6
|
-
const inputData = req.query;
|
|
7
|
-
const query =[
|
|
8
|
-
{
|
|
9
|
-
$match: {
|
|
10
|
-
userType: { $eq: 'tango' },
|
|
11
|
-
},
|
|
12
|
-
},
|
|
13
|
-
{
|
|
14
|
-
$project: {
|
|
15
|
-
userName: 1,
|
|
16
|
-
userId: '$_id',
|
|
17
|
-
_id: 0,
|
|
18
|
-
},
|
|
19
|
-
},
|
|
20
|
-
];
|
|
21
|
-
|
|
22
|
-
const count = await aggregateUser( query );
|
|
23
|
-
if ( count.length == 0 ) {
|
|
24
|
-
return res.sendSuccess( { result: [], count: 0 } );
|
|
25
|
-
}
|
|
26
|
-
if ( inputData.limit ) {
|
|
27
|
-
const offset = inputData.offset ? ( inputData.offset - 1 ) * inputData.limit : 0;
|
|
28
|
-
query.push(
|
|
29
|
-
{ $skip: offset },
|
|
30
|
-
{ $limit: limit },
|
|
31
|
-
);
|
|
32
|
-
}
|
|
33
|
-
const result = await aggregateUser( query );
|
|
34
|
-
|
|
35
|
-
return res.sendSuccess( { result: result, count: count.length } );
|
|
36
|
-
} catch ( error ) {
|
|
37
|
-
const err = error.message || 'Internal Server Error';
|
|
38
|
-
logger.info( { error: error, messgae: req.query, function: 'auditUserList' } );
|
|
39
|
-
return res.sendError( err, 500 );
|
|
40
|
-
}
|
|
41
|
-
}
|
|
1
|
+
import { logger } from 'tango-app-api-middleware';
|
|
2
|
+
import { aggregateUser } from '../service/user.service.js';
|
|
3
|
+
|
|
4
|
+
export async function auditUserList( req, res ) {
|
|
5
|
+
try {
|
|
6
|
+
const inputData = req.query;
|
|
7
|
+
const query =[
|
|
8
|
+
{
|
|
9
|
+
$match: {
|
|
10
|
+
userType: { $eq: 'tango' },
|
|
11
|
+
},
|
|
12
|
+
},
|
|
13
|
+
{
|
|
14
|
+
$project: {
|
|
15
|
+
userName: 1,
|
|
16
|
+
userId: '$_id',
|
|
17
|
+
_id: 0,
|
|
18
|
+
},
|
|
19
|
+
},
|
|
20
|
+
];
|
|
21
|
+
|
|
22
|
+
const count = await aggregateUser( query );
|
|
23
|
+
if ( count.length == 0 ) {
|
|
24
|
+
return res.sendSuccess( { result: [], count: 0 } );
|
|
25
|
+
}
|
|
26
|
+
if ( inputData.limit ) {
|
|
27
|
+
const offset = inputData.offset ? ( inputData.offset - 1 ) * inputData.limit : 0;
|
|
28
|
+
query.push(
|
|
29
|
+
{ $skip: offset },
|
|
30
|
+
{ $limit: limit },
|
|
31
|
+
);
|
|
32
|
+
}
|
|
33
|
+
const result = await aggregateUser( query );
|
|
34
|
+
|
|
35
|
+
return res.sendSuccess( { result: result, count: count.length } );
|
|
36
|
+
} catch ( error ) {
|
|
37
|
+
const err = error.message || 'Internal Server Error';
|
|
38
|
+
logger.info( { error: error, messgae: req.query, function: 'auditUserList' } );
|
|
39
|
+
return res.sendError( err, 500 );
|
|
40
|
+
}
|
|
41
|
+
}
|
|
@@ -243,7 +243,7 @@ export const auditMetricsDocs = {
|
|
|
243
243
|
},
|
|
244
244
|
{
|
|
245
245
|
in: 'query',
|
|
246
|
-
name: '
|
|
246
|
+
name: 'imageType',
|
|
247
247
|
scema: j2s( auditImageValidSchema ).swagger,
|
|
248
248
|
require: true,
|
|
249
249
|
},
|
|
@@ -251,7 +251,7 @@ export const auditMetricsDocs = {
|
|
|
251
251
|
in: 'query',
|
|
252
252
|
name: 'export',
|
|
253
253
|
scema: j2s( auditImageValidSchema ).swagger,
|
|
254
|
-
require:
|
|
254
|
+
require: true,
|
|
255
255
|
},
|
|
256
256
|
],
|
|
257
257
|
responses: {
|
package/src/docs/store.docs.js
CHANGED
|
@@ -1,27 +1,27 @@
|
|
|
1
|
-
import j2s from 'joi-to-swagger';
|
|
2
|
-
import { auditStoreSchema } from '../dtos/store.dtos.js';
|
|
3
|
-
|
|
4
|
-
export const storeDocs = {
|
|
5
|
-
'/v3/audit/store/audit-stores': {
|
|
6
|
-
post: {
|
|
7
|
-
tags: [ 'Audit/Stores' ],
|
|
8
|
-
description: `sGet list of stores`,
|
|
9
|
-
operationId: 'audit-stores',
|
|
10
|
-
parameters: {},
|
|
11
|
-
requestBody: {
|
|
12
|
-
content: {
|
|
13
|
-
'application/json': {
|
|
14
|
-
schema: j2s( auditStoreSchema ).swagger,
|
|
15
|
-
},
|
|
16
|
-
},
|
|
17
|
-
},
|
|
18
|
-
responses: {
|
|
19
|
-
200: { description: 'Successful' },
|
|
20
|
-
401: { description: 'Unauthorized User' },
|
|
21
|
-
422: { description: 'Field Error' },
|
|
22
|
-
500: { description: 'Server Error' },
|
|
23
|
-
204: { description: 'Not Found' },
|
|
24
|
-
},
|
|
25
|
-
},
|
|
26
|
-
},
|
|
27
|
-
};
|
|
1
|
+
import j2s from 'joi-to-swagger';
|
|
2
|
+
import { auditStoreSchema } from '../dtos/store.dtos.js';
|
|
3
|
+
|
|
4
|
+
export const storeDocs = {
|
|
5
|
+
'/v3/audit/store/audit-stores': {
|
|
6
|
+
post: {
|
|
7
|
+
tags: [ 'Audit/Stores' ],
|
|
8
|
+
description: `sGet list of stores`,
|
|
9
|
+
operationId: 'audit-stores',
|
|
10
|
+
parameters: {},
|
|
11
|
+
requestBody: {
|
|
12
|
+
content: {
|
|
13
|
+
'application/json': {
|
|
14
|
+
schema: j2s( auditStoreSchema ).swagger,
|
|
15
|
+
},
|
|
16
|
+
},
|
|
17
|
+
},
|
|
18
|
+
responses: {
|
|
19
|
+
200: { description: 'Successful' },
|
|
20
|
+
401: { description: 'Unauthorized User' },
|
|
21
|
+
422: { description: 'Field Error' },
|
|
22
|
+
500: { description: 'Server Error' },
|
|
23
|
+
204: { description: 'Not Found' },
|
|
24
|
+
},
|
|
25
|
+
},
|
|
26
|
+
},
|
|
27
|
+
};
|
package/src/docs/user.docs.js
CHANGED
|
@@ -1,33 +1,33 @@
|
|
|
1
|
-
import j2s from 'joi-to-swagger';
|
|
2
|
-
import { userSchema } from '../dtos/user.dtos.js';
|
|
3
|
-
|
|
4
|
-
export const userDocs = {
|
|
5
|
-
'/v3/audit/user/tango-users': {
|
|
6
|
-
get: {
|
|
7
|
-
tags: [ 'Audit/User' ],
|
|
8
|
-
description: 'Get user list',
|
|
9
|
-
operationId: 'tango-users',
|
|
10
|
-
parameters: [
|
|
11
|
-
{
|
|
12
|
-
in: 'query',
|
|
13
|
-
name: 'limit',
|
|
14
|
-
scema: j2s( userSchema ).swagger,
|
|
15
|
-
require: false,
|
|
16
|
-
},
|
|
17
|
-
{
|
|
18
|
-
in: 'query',
|
|
19
|
-
name: 'offset',
|
|
20
|
-
scema: j2s( userSchema ).swagger,
|
|
21
|
-
require: false,
|
|
22
|
-
},
|
|
23
|
-
],
|
|
24
|
-
responses: {
|
|
25
|
-
200: { description: 'Successful' },
|
|
26
|
-
401: { description: 'Unauthorized User' },
|
|
27
|
-
422: { description: 'Field Error' },
|
|
28
|
-
500: { description: 'Server Error' },
|
|
29
|
-
204: { description: 'Not Found' },
|
|
30
|
-
},
|
|
31
|
-
},
|
|
32
|
-
},
|
|
33
|
-
};
|
|
1
|
+
import j2s from 'joi-to-swagger';
|
|
2
|
+
import { userSchema } from '../dtos/user.dtos.js';
|
|
3
|
+
|
|
4
|
+
export const userDocs = {
|
|
5
|
+
'/v3/audit/user/tango-users': {
|
|
6
|
+
get: {
|
|
7
|
+
tags: [ 'Audit/User' ],
|
|
8
|
+
description: 'Get user list',
|
|
9
|
+
operationId: 'tango-users',
|
|
10
|
+
parameters: [
|
|
11
|
+
{
|
|
12
|
+
in: 'query',
|
|
13
|
+
name: 'limit',
|
|
14
|
+
scema: j2s( userSchema ).swagger,
|
|
15
|
+
require: false,
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
in: 'query',
|
|
19
|
+
name: 'offset',
|
|
20
|
+
scema: j2s( userSchema ).swagger,
|
|
21
|
+
require: false,
|
|
22
|
+
},
|
|
23
|
+
],
|
|
24
|
+
responses: {
|
|
25
|
+
200: { description: 'Successful' },
|
|
26
|
+
401: { description: 'Unauthorized User' },
|
|
27
|
+
422: { description: 'Field Error' },
|
|
28
|
+
500: { description: 'Server Error' },
|
|
29
|
+
204: { description: 'Not Found' },
|
|
30
|
+
},
|
|
31
|
+
},
|
|
32
|
+
},
|
|
33
|
+
};
|
|
@@ -171,8 +171,8 @@ export const auditImageValidSchema = joi.object(
|
|
|
171
171
|
{
|
|
172
172
|
fileDate: joi.string().required(),
|
|
173
173
|
storeId: joi.string().required(),
|
|
174
|
-
|
|
175
|
-
export: joi.boolean().
|
|
174
|
+
imageType: joi.string().required(),
|
|
175
|
+
export: joi.boolean().required(),
|
|
176
176
|
},
|
|
177
177
|
);
|
|
178
178
|
|
package/src/dtos/store.dtos.js
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import joi from 'joi';
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
export const auditStoreSchema = joi.object(
|
|
5
|
-
{
|
|
6
|
-
clientId: joi.array().required(),
|
|
7
|
-
limit: joi.number().optional(),
|
|
8
|
-
offset: joi.number().optional(),
|
|
9
|
-
},
|
|
10
|
-
);
|
|
11
|
-
|
|
12
|
-
export const auditStoreValid = {
|
|
13
|
-
body: auditStoreSchema,
|
|
14
|
-
};
|
|
1
|
+
import joi from 'joi';
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
export const auditStoreSchema = joi.object(
|
|
5
|
+
{
|
|
6
|
+
clientId: joi.array().required(),
|
|
7
|
+
limit: joi.number().optional(),
|
|
8
|
+
offset: joi.number().optional(),
|
|
9
|
+
},
|
|
10
|
+
);
|
|
11
|
+
|
|
12
|
+
export const auditStoreValid = {
|
|
13
|
+
body: auditStoreSchema,
|
|
14
|
+
};
|
package/src/dtos/user.dtos.js
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import joi from 'joi';
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
export const userSchema = joi.object(
|
|
5
|
-
{
|
|
6
|
-
|
|
7
|
-
limit: joi.number().optional(),
|
|
8
|
-
offset: joi.number().optional(),
|
|
9
|
-
},
|
|
10
|
-
);
|
|
11
|
-
|
|
12
|
-
export const userValid = {
|
|
13
|
-
query: userSchema,
|
|
14
|
-
};
|
|
1
|
+
import joi from 'joi';
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
export const userSchema = joi.object(
|
|
5
|
+
{
|
|
6
|
+
|
|
7
|
+
limit: joi.number().optional(),
|
|
8
|
+
offset: joi.number().optional(),
|
|
9
|
+
},
|
|
10
|
+
);
|
|
11
|
+
|
|
12
|
+
export const userValid = {
|
|
13
|
+
query: userSchema,
|
|
14
|
+
};
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { Router } from 'express';
|
|
2
|
-
import { isAllowedSessionHandler, validate } from 'tango-app-api-middleware';
|
|
3
|
-
import { auditStoreList } from '../controllers/store.controllers.js';
|
|
4
|
-
import { auditStoreValid } from '../dtos/store.dtos.js';
|
|
5
|
-
|
|
6
|
-
export const storeRouter = Router();
|
|
7
|
-
|
|
8
|
-
storeRouter.post( '/audit-stores', isAllowedSessionHandler, validate( auditStoreValid ), auditStoreList );
|
|
9
|
-
|
|
10
|
-
export default storeRouter;
|
|
1
|
+
import { Router } from 'express';
|
|
2
|
+
import { isAllowedSessionHandler, validate } from 'tango-app-api-middleware';
|
|
3
|
+
import { auditStoreList } from '../controllers/store.controllers.js';
|
|
4
|
+
import { auditStoreValid } from '../dtos/store.dtos.js';
|
|
5
|
+
|
|
6
|
+
export const storeRouter = Router();
|
|
7
|
+
|
|
8
|
+
storeRouter.post( '/audit-stores', isAllowedSessionHandler, validate( auditStoreValid ), auditStoreList );
|
|
9
|
+
|
|
10
|
+
export default storeRouter;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { Router } from 'express';
|
|
2
|
-
import { isAllowedSessionHandler } from 'tango-app-api-middleware';
|
|
3
|
-
import { auditUserList } from '../controllers/user.controllers.js';
|
|
4
|
-
|
|
5
|
-
export const userRouter = Router();
|
|
6
|
-
|
|
7
|
-
userRouter.get( '/tango-users', isAllowedSessionHandler, auditUserList );
|
|
8
|
-
|
|
9
|
-
export default userRouter;
|
|
1
|
+
import { Router } from 'express';
|
|
2
|
+
import { isAllowedSessionHandler } from 'tango-app-api-middleware';
|
|
3
|
+
import { auditUserList } from '../controllers/user.controllers.js';
|
|
4
|
+
|
|
5
|
+
export const userRouter = Router();
|
|
6
|
+
|
|
7
|
+
userRouter.get( '/tango-users', isAllowedSessionHandler, auditUserList );
|
|
8
|
+
|
|
9
|
+
export default userRouter;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { checkFileExist, chunkArray, getObject, getQueueUrl, listFileWithoutLimit, logger, signedUrl } from 'tango-app-api-middleware';
|
|
1
|
+
import { checkFileExist, chunkArray, getJsonFileData, getObject, getQueueUrl, listFileWithoutLimit, logger, signedUrl } from 'tango-app-api-middleware';
|
|
2
2
|
import { findOneUserAudit } from '../service/userAudit.service.js';
|
|
3
3
|
import { findOneStoreAudit } from '../service/storeAudit.service.js';
|
|
4
4
|
import AdmZip from 'adm-zip';
|
|
@@ -165,7 +165,6 @@ export async function isAuditInputFolderExist( req, res, next ) {
|
|
|
165
165
|
try {
|
|
166
166
|
const bucket = JSON.parse( process.env.BUCKET );
|
|
167
167
|
const inputData = req.method === 'POST' ? req.body : req.query;
|
|
168
|
-
console.log( inputData );
|
|
169
168
|
const params={
|
|
170
169
|
Bucket: bucket.auditInput,
|
|
171
170
|
Key: `${inputData.fileDate}/${inputData.storeId}`,
|
|
@@ -235,6 +234,7 @@ export async function getAuditImageData( data ) {
|
|
|
235
234
|
imgPath: data,
|
|
236
235
|
imgName: indexes[1],
|
|
237
236
|
imgId: image[0],
|
|
237
|
+
img_name: indexes[1],
|
|
238
238
|
// imgFile: auditImages[i],
|
|
239
239
|
} );
|
|
240
240
|
}
|
|
@@ -256,6 +256,7 @@ export async function getAuditImageData( data ) {
|
|
|
256
256
|
imgName: indexes[1],
|
|
257
257
|
imgId: image[0],
|
|
258
258
|
imgFile: auditImages[i],
|
|
259
|
+
img_name: indexes[1],
|
|
259
260
|
} );
|
|
260
261
|
}
|
|
261
262
|
return files;
|
|
@@ -272,7 +273,6 @@ export async function zipDownloadImage( data ) {
|
|
|
272
273
|
const bucket = JSON.parse( process.env.BUCKET );
|
|
273
274
|
const zip = new AdmZip();
|
|
274
275
|
const split = await chunkArray( data, 10 );
|
|
275
|
-
|
|
276
276
|
const promises = await split.map( async ( chunk ) => {
|
|
277
277
|
for ( let i = 0; i< chunk.length; i++ ) {
|
|
278
278
|
const params ={
|
|
@@ -280,7 +280,7 @@ export async function zipDownloadImage( data ) {
|
|
|
280
280
|
Key: chunk[i].imgFile.Key,
|
|
281
281
|
};
|
|
282
282
|
const fileBuffer = await getObject( params );
|
|
283
|
-
zip.addFile( chunk[i].imgFile.Key, fileBuffer );
|
|
283
|
+
zip.addFile( chunk[i].imgFile.Key, fileBuffer.Body );
|
|
284
284
|
}
|
|
285
285
|
return zip;
|
|
286
286
|
} );
|
|
@@ -293,3 +293,39 @@ export async function zipDownloadImage( data ) {
|
|
|
293
293
|
return err;
|
|
294
294
|
}
|
|
295
295
|
}
|
|
296
|
+
|
|
297
|
+
export async function getAuditFilterData( data ) {
|
|
298
|
+
try {
|
|
299
|
+
const bucket = JSON.parse( process.env.BUCKET );
|
|
300
|
+
const storeId = data.storeId;
|
|
301
|
+
const fileDate = data.fileDate;
|
|
302
|
+
const params = {
|
|
303
|
+
Bucket: `${bucket.auditOutput}`,
|
|
304
|
+
Key: `${storeId}/${fileDate}/${bucket.masterJsonFile}`,
|
|
305
|
+
};
|
|
306
|
+
const mappingFile = await getJsonFileData( params );
|
|
307
|
+
if ( mappingFile.statusCode ) {
|
|
308
|
+
return mappingFile;
|
|
309
|
+
} else {
|
|
310
|
+
const mappingData = await JSON.parse( mappingFile.toString( 'utf-8' ) );
|
|
311
|
+
const filterData = await mappingData.person_data.filter(
|
|
312
|
+
( item ) =>
|
|
313
|
+
item.temp_ids < 20000 &&
|
|
314
|
+
item.temp_ids > 0 &&
|
|
315
|
+
item.person_status === '',
|
|
316
|
+
);
|
|
317
|
+
const finalResult = await filterData.map( ( i ) => {
|
|
318
|
+
return { ...i, img: i.index.concat( '_', i.temp_ids ) };
|
|
319
|
+
} );
|
|
320
|
+
return finalResult;
|
|
321
|
+
}
|
|
322
|
+
} catch ( error ) {
|
|
323
|
+
logger.error( {
|
|
324
|
+
error: error,
|
|
325
|
+
type: 'MAPPING JSON getFilterData',
|
|
326
|
+
function: 'getFilterData',
|
|
327
|
+
} );
|
|
328
|
+
return error;
|
|
329
|
+
}
|
|
330
|
+
}
|
|
331
|
+
|