tango-app-api-audit 1.0.47 → 1.0.49

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.
@@ -1,5 +1,4 @@
1
1
  import { chunkArray, download, getUTC, insertOpenSearchData, logger, sendMessageToQueue } from 'tango-app-api-middleware';
2
- import { aggregateAuditClientData } from '../service/auditClientData.service.js';
3
2
  import { aggregateUserAudit, updateOneUserAudit } from '../service/userAudit.service.js';
4
3
  import mongoose from 'mongoose';
5
4
  import { aggregateStoreAudit, updateOneStoreAudit } from '../service/storeAudit.service.js';
@@ -10,7 +9,6 @@ import { countDocumentsStore } from '../service/store.service.js';
10
9
  import { findOneClient } from '../service/client.service.js';
11
10
  import { getAuditFilterData, getAuditImageData, zipDownloadImage } from '../validation/audit.validation.js';
12
11
  import { getReauditImg } from './audit.controllers.js';
13
- import { aggregateStoreZoneAudit } from '../service/storeZoneAudit.service.js';
14
12
  // import { listQueue } from 'tango-app-api-middleware/src/utils/aws/sqs.js';
15
13
 
16
14
  export async function userAuditHistory( req, res ) {
@@ -663,8 +661,8 @@ export async function clientMetrics( req, res ) {
663
661
  },
664
662
  );
665
663
  }
666
-
667
- const count = await aggregateAuditClientData( query );
664
+ logger.info( { query: query } );
665
+ const count = [];// await aggregateAuditClientData( query );
668
666
  if ( count.length == 0 ) {
669
667
  return res.sendError( 'No Data Found', 204 );
670
668
  }
@@ -694,8 +692,8 @@ export async function clientMetrics( req, res ) {
694
692
  );
695
693
  }
696
694
 
697
-
698
- const result = await aggregateAuditClientData( query );
695
+ logger.info( { query: query } );
696
+ const result = [];// await aggregateAuditClientData( query );
699
697
  if ( inputData.isExport ) {
700
698
  await download( result, res );
701
699
  return;
@@ -1339,21 +1337,21 @@ export async function overAllAuditSummary( req, res ) {
1339
1337
  }
1340
1338
  const storeQuery = inputData.clientId.length? { 'edge.firstFile': true, 'clientId': { $in: inputData. clientId } } : { 'edge.firstFile': true };
1341
1339
  temp.installedStores = await countDocumentsStore( storeQuery );
1342
- const auditClientDataQuery =[
1343
- {
1344
- $match: {
1345
- $and: filters,
1346
- },
1347
-
1348
- },
1349
- {
1350
- $group: {
1351
- _id: null,
1352
- totalFilesCount: { $sum: '$totalFilesCount' },
1353
- },
1354
- },
1355
- ];
1356
- const auditClientData = await aggregateAuditClientData( auditClientDataQuery );
1340
+ // const auditClientDataQuery =[
1341
+ // {
1342
+ // $match: {
1343
+ // $and: filters,
1344
+ // },
1345
+
1346
+ // },
1347
+ // {
1348
+ // $group: {
1349
+ // _id: null,
1350
+ // totalFilesCount: { $sum: '$totalFilesCount' },
1351
+ // },
1352
+ // },
1353
+ // ];
1354
+ const auditClientData = [];// await aggregateAuditClientData( auditClientDataQuery );
1357
1355
  if ( auditClientData.length >0 ) {
1358
1356
  temp.auditStores = auditClientData[0].totalFilesCount;
1359
1357
  }
@@ -1405,7 +1403,7 @@ export async function overAllAuditSummary( req, res ) {
1405
1403
  },
1406
1404
  },
1407
1405
  ];
1408
- const storeAudit = inputData.moduleType == 'zone'?await aggregateStoreZoneAudit( storeAuditQuery ) : await aggregateStoreAudit( storeAuditQuery );
1406
+ const storeAudit = await aggregateStoreAudit( storeAuditQuery );
1409
1407
  if ( storeAudit.length > 0 ) {
1410
1408
  temp.inprogreseStores= storeAudit[0].inprogreseStores;
1411
1409
  temp.completedStores = storeAudit[0].completedStores;
@@ -1,8 +1,6 @@
1
1
  import { download, fileUpload, getJsonFileData, getUTC, insertOpenSearchData, listFileByPath, listFileWithoutLimit, sendMessageToQueue, signedUrl, sqsReceive } from 'tango-app-api-middleware';
2
2
  import { aggregateZoneUserAudit, createZoneUserAudit, findOneZoneUserAudit, updateOneZoneUserAudit } from '../service/zoneUserAudit.service.js';
3
3
  import { logger } from 'tango-app-api-middleware';
4
- import { aggregateAssignZoneAudit } from '../service/assignZoneAudit.service.js';
5
- import { aggregateStoreZoneAudit, createStoreZoneAudit, findOneStoreZoneAudit, updateOneStoreZoneAudit } from '../service/storeZoneAudit.service.js';
6
4
  import { findOneUser } from '../service/user.service.js';
7
5
  import { findOneStore } from '../service/store.service.js';
8
6
  import dayjs from 'dayjs';
@@ -11,7 +9,6 @@ import { aggregateAssignAudit, createAssignAudit } from '../service/assignAudit.
11
9
  import { createAuditLog, findOneAuditLog } from '../service/auditLog.service.js';
12
10
  import { mapCustomer, mapEmployee, mapJunk, splitB20000, splitE0, splitG20000, zipDownloadImage } from '../validation/audit.validation.js';
13
11
  import { aggregateClient, findClient, findOneClient } from '../service/client.service.js';
14
- import { aggregateAuditClientData } from '../service/auditClientData.service.js';
15
12
  import _ from 'lodash';
16
13
  import mongoose from 'mongoose';
17
14
  import { listQueue } from 'tango-app-api-middleware/src/utils/aws/sqs.js';
@@ -73,7 +70,7 @@ export async function getZoneAuditFile( req, res ) {
73
70
  },
74
71
  ];
75
72
 
76
- const userAssign = await aggregateAssignZoneAudit( query );
73
+ const userAssign = await aggregateAssignAudit( query );
77
74
  if ( userAssign.length > 0 ) {
78
75
  logger.info( 'Hit in user assign', { inputData } );
79
76
  } else {
@@ -776,38 +773,38 @@ export async function workSpace( req, res ) {
776
773
 
777
774
  const clientDetails = await aggregateClient( clientQuery );
778
775
  const clientList = clientDetails.map( ( i ) => i.clientId );
779
- const query = [
780
- {
781
- $match: {
782
- $and: [
783
- {
784
- clientId: { $in: clientList },
785
- },
786
- {
787
- moduleType: 'zone',
788
- },
789
- ],
790
-
791
- },
792
- },
793
- {
794
- $group: {
795
- _id: '$clientId',
796
- clientId: { $last: '$clientId' },
797
- totalFilesCount: { $last: '$totalFilesCount' },
798
- clientName: { $last: '$clientName' },
799
- queueName: { $last: '$queueName' },
800
- },
801
- },
802
- {
803
- $project: {
804
- clientId: 1,
805
- totalFilesCount: 1,
806
- clientName: 1,
807
- queueName: 1,
808
- },
809
- },
810
- ];
776
+ // const query = [
777
+ // {
778
+ // $match: {
779
+ // $and: [
780
+ // {
781
+ // clientId: { $in: clientList },
782
+ // },
783
+ // {
784
+ // moduleType: 'zone',
785
+ // },
786
+ // ],
787
+
788
+ // },
789
+ // },
790
+ // {
791
+ // $group: {
792
+ // _id: '$clientId',
793
+ // clientId: { $last: '$clientId' },
794
+ // totalFilesCount: { $last: '$totalFilesCount' },
795
+ // clientName: { $last: '$clientName' },
796
+ // queueName: { $last: '$queueName' },
797
+ // },
798
+ // },
799
+ // {
800
+ // $project: {
801
+ // clientId: 1,
802
+ // totalFilesCount: 1,
803
+ // clientName: 1,
804
+ // queueName: 1,
805
+ // },
806
+ // },
807
+ // ];
811
808
 
812
809
  const fileDate = dayjs( dateRange.start ).subtract( 1, 'days' );
813
810
 
@@ -977,7 +974,7 @@ export async function workSpace( req, res ) {
977
974
  },
978
975
  ];
979
976
 
980
- const auditDetails = await aggregateAuditClientData( query );
977
+ const auditDetails = [];// await aggregateAuditClientData( query );
981
978
  const auditCount = await aggregateUserAudit( auditFiles );
982
979
  const draftedCount = await aggregateUserAudit( draftedFiles );
983
980
  const CompletedCount = await aggregateStoreZoneAudit( completedFiles );
@@ -1626,8 +1623,8 @@ export async function clientMetrics( req, res ) {
1626
1623
  },
1627
1624
  );
1628
1625
  }
1629
-
1630
- const count = await aggregateAuditClientData( query );
1626
+ logger.info( { query: query } );
1627
+ const count = [];// await aggregateAuditClientData( query );
1631
1628
  if ( count.length == 0 ) {
1632
1629
  return res.sendError( 'No Data Found', 204 );
1633
1630
  }
@@ -1657,8 +1654,8 @@ export async function clientMetrics( req, res ) {
1657
1654
  );
1658
1655
  }
1659
1656
 
1660
-
1661
- const result = await aggregateAuditClientData( query );
1657
+ logger.info( { query: query } );
1658
+ const result = [];// await aggregateAuditClientData( query );
1662
1659
  if ( inputData.isExport ) {
1663
1660
  await download( result, res );
1664
1661
  return;
@@ -1,10 +1,99 @@
1
- import { getDraftedDataSchema, getFileSchema, saveDraftSchema, saveSchema, workSpaceSchema } from '../dtos/audit.dtos.js';
1
+ import { auditStoreSchema, clientSchema, getDraftedDataSchema, getFileSchema, saveDraftSchema, saveSchema, userSchema, workSpaceSchema } from '../dtos/audit.dtos.js';
2
2
  import j2s from 'joi-to-swagger';
3
3
 
4
4
  export const auditDocs = {
5
+
6
+
7
+ /* < -- *** Configuration *** --> */
8
+
9
+ // client
10
+ '/v3/audit/clients': {
11
+ get: {
12
+ tags: [ 'Client' ],
13
+ description: 'Get client list which is enable for audit',
14
+ operationId: 'clients',
15
+ parameters: [
16
+ {
17
+ in: 'query',
18
+ name: 'limit',
19
+ scema: j2s( clientSchema ).swagger,
20
+ require: false,
21
+ },
22
+ {
23
+ in: 'query',
24
+ name: 'offset',
25
+ scema: j2s( clientSchema ).swagger,
26
+ require: false,
27
+ },
28
+ ],
29
+ responses: {
30
+ 200: { description: 'Successful' },
31
+ 401: { description: 'Unauthorized User' },
32
+ 422: { description: 'Field Error' },
33
+ 500: { description: 'Server Error' },
34
+ 204: { description: 'Not Found' },
35
+ },
36
+ },
37
+ },
38
+
39
+ // store
40
+
41
+ '/v3/audit/audit-stores': {
42
+ post: {
43
+ tags: [ 'Stores' ],
44
+ description: `sGet list of stores`,
45
+ operationId: 'audit-stores',
46
+ parameters: {},
47
+ requestBody: {
48
+ content: {
49
+ 'application/json': {
50
+ schema: j2s( auditStoreSchema ).swagger,
51
+ },
52
+ },
53
+ },
54
+ responses: {
55
+ 200: { description: 'Successful' },
56
+ 401: { description: 'Unauthorized User' },
57
+ 422: { description: 'Field Error' },
58
+ 500: { description: 'Server Error' },
59
+ 204: { description: 'Not Found' },
60
+ },
61
+ },
62
+ },
63
+
64
+ // user
65
+ '/v3/audit/tango-users': {
66
+ get: {
67
+ tags: [ 'User' ],
68
+ description: 'Get user list',
69
+ operationId: 'tango-users',
70
+ parameters: [
71
+ {
72
+ in: 'query',
73
+ name: 'limit',
74
+ scema: j2s( userSchema ).swagger,
75
+ require: false,
76
+ },
77
+ {
78
+ in: 'query',
79
+ name: 'offset',
80
+ scema: j2s( userSchema ).swagger,
81
+ require: false,
82
+ },
83
+ ],
84
+ responses: {
85
+ 200: { description: 'Successful' },
86
+ 401: { description: 'Unauthorized User' },
87
+ 422: { description: 'Field Error' },
88
+ 500: { description: 'Server Error' },
89
+ 204: { description: 'Not Found' },
90
+ },
91
+ },
92
+ },
93
+
5
94
  '/v3/audit/get-file': {
6
95
  get: {
7
- tags: [ 'Audit' ],
96
+ tags: [ 'Audit Mapping' ],
8
97
  description: 'Get a file via queue message',
9
98
  operationId: 'get-file',
10
99
  parameters: [
@@ -26,6 +115,12 @@ export const auditDocs = {
26
115
  scema: j2s( getFileSchema ).swagger,
27
116
  require: false,
28
117
  },
118
+ {
119
+ in: 'query',
120
+ name: 'moduleType',
121
+ scema: j2s( getFileSchema ).swagger,
122
+ require: true,
123
+ },
29
124
  ],
30
125
  responses: {
31
126
  200: { description: 'Successful' },
@@ -38,7 +133,7 @@ export const auditDocs = {
38
133
  },
39
134
  '/v3/audit/save-draft': {
40
135
  post: {
41
- tags: [ 'Audit' ],
136
+ tags: [ 'Audit Mapping' ],
42
137
  description: `save audited file. which is save in the mongo db`,
43
138
  operationId: 'save-draft',
44
139
  parameters: {},
@@ -60,7 +155,7 @@ export const auditDocs = {
60
155
  },
61
156
  '/v3/audit/get-drafted-data': {
62
157
  get: {
63
- tags: [ 'Audit' ],
158
+ tags: [ 'Audit Mapping' ],
64
159
  description: 'Get a saved file via DB',
65
160
  operationId: 'get-drafted-data',
66
161
  parameters: [
@@ -88,7 +183,7 @@ export const auditDocs = {
88
183
  },
89
184
  '/v3/audit/save': {
90
185
  post: {
91
- tags: [ 'Audit' ],
186
+ tags: [ 'Audit Mapping' ],
92
187
  description: `submit the audit file. which is store in the bucket in the json format`,
93
188
  operationId: 'save',
94
189
  parameters: {},
@@ -110,10 +205,16 @@ export const auditDocs = {
110
205
  },
111
206
  '/v3/audit/work-space': {
112
207
  get: {
113
- tags: [ 'Audit' ],
208
+ tags: [ 'Audit Mapping' ],
114
209
  description: 'queue wise info of audit files ',
115
210
  operationId: 'work-space',
116
211
  parameters: [
212
+ {
213
+ in: 'query',
214
+ name: 'moduleType',
215
+ scema: j2s( workSpaceSchema ).swagger,
216
+ require: true,
217
+ },
117
218
  {
118
219
  in: 'query',
119
220
  name: 'searchValue',
@@ -1,11 +1,55 @@
1
1
  import joi from 'joi';
2
2
 
3
3
 
4
+ /* < -- *** Configurations *** --> */
5
+
6
+ // client
7
+ export const clientSchema = joi.object(
8
+ {
9
+ limit: joi.number().optional(),
10
+ offset: joi.number().optional(),
11
+ },
12
+ );
13
+
14
+ export const clientValid = {
15
+ query: clientSchema,
16
+ };
17
+
18
+ // store
19
+ export const auditStoreSchema = joi.object(
20
+ {
21
+ clientId: joi.array().required(),
22
+ limit: joi.number().optional(),
23
+ offset: joi.number().optional(),
24
+ },
25
+ );
26
+
27
+ export const auditStoreValid = {
28
+ body: auditStoreSchema,
29
+ };
30
+
31
+ // user
32
+ export const userSchema = joi.object(
33
+ {
34
+
35
+ limit: joi.number().optional(),
36
+ offset: joi.number().optional(),
37
+ },
38
+ );
39
+
40
+ export const userValid = {
41
+ query: userSchema,
42
+ };
43
+
44
+ /* < -- *** Audit Mapping *** --> */
45
+
46
+
4
47
  export const getFileSchema = joi.object(
5
48
  {
6
49
  queueName: joi.string().required(),
7
50
  nextId: joi.string().optional().allow( '' ),
8
51
  limit: joi.number().optional(),
52
+ moduleType: joi.string().required(),
9
53
  },
10
54
  );
11
55
 
@@ -18,6 +62,8 @@ export const saveDraftSchema = joi.object(
18
62
  userCommands: joi.string().optional().allow( '' ),
19
63
  storeId: joi.string().required(),
20
64
  auditId: joi.string().required(),
65
+ moduleType: joi.string().required(),
66
+ zoneName: joi.string().required(),
21
67
  auditType: joi.string().required(),
22
68
  fileDate: joi.string().required(),
23
69
  queueName: joi.string().required(),
@@ -42,6 +88,8 @@ export const getDraftedDataSchema = joi.object(
42
88
  storeId: joi.string().required(),
43
89
  fileDate: joi.string().required(),
44
90
  userId: joi.string().optional(),
91
+ moduleType: joi.string().required(),
92
+ zoneName: joi.string().required(),
45
93
  },
46
94
  );
47
95
 
@@ -55,6 +103,8 @@ export const saveSchema = joi.object(
55
103
  storeId: joi.string().required(),
56
104
  fileDate: joi.string().required(),
57
105
  auditType: joi.string().required(),
106
+ moduleType: joi.string().required(),
107
+ zoneName: joi.string().required(),
58
108
  beforeCount: joi.number().required(),
59
109
  junkCount: joi.number().required(),
60
110
  junk: joi.array().required(),
@@ -62,6 +112,8 @@ export const saveSchema = joi.object(
62
112
  employee: joi.array().required(),
63
113
  customerCount: joi.number().required(),
64
114
  customer: joi.array().required(),
115
+ moduleType: joi.string().required(),
116
+ zoneName: joi.string().required(),
65
117
  },
66
118
  );
67
119
 
@@ -72,6 +124,7 @@ export const saveValid = {
72
124
  export const workSpaceSchema = joi.object(
73
125
  {
74
126
  searchValue: joi.string().optional().allow( '' ),
127
+ moduleType: joi.string().required(),
75
128
  offset: joi.string().optional(),
76
129
  limit: joi.number().optional(),
77
130
  isExport: joi.boolean().optional(),
@@ -1,11 +1,18 @@
1
1
  import express from 'express';
2
2
  import { isExistsQueue, validateUserAudit } from '../validation/audit.validation.js';
3
3
  import { isAllowedSessionHandler, validate } from 'tango-app-api-middleware';
4
- import { getAuditFile, getDraftedData, save, saveDraft, workSpace } from '../controllers/audit.controllers.js';
5
- import { getDraftedDataValid, getFileValid, saveDraftValid, saveValid, workSpaceValid } from '../dtos/audit.dtos.js';
4
+ import { auditStoreList, auditUserList, clients, getAuditFile, getDraftedData, save, saveDraft, workSpace } from '../controllers/audit.controllers.js';
5
+ import { auditStoreValid, clientValid, getDraftedDataValid, getFileValid, saveDraftValid, saveValid, workSpaceValid } from '../dtos/audit.dtos.js';
6
6
 
7
7
  export const auditRouter = express.Router();
8
8
 
9
+ // Configuration
10
+
11
+ auditRouter.get( '/clients', isAllowedSessionHandler, validate( clientValid ), clients );
12
+ auditRouter.post( '/audit-stores', isAllowedSessionHandler, validate( auditStoreValid ), auditStoreList );
13
+ auditRouter.get( '/tango-users', isAllowedSessionHandler, auditUserList );
14
+
15
+ // Audit Mapping
9
16
  auditRouter.get( '/get-file', isAllowedSessionHandler, validate( getFileValid ), isExistsQueue, getAuditFile );
10
17
  auditRouter.post( '/save-draft', isAllowedSessionHandler, validate( saveDraftValid ), saveDraft );
11
18
  auditRouter.get( '/get-drafted-data', isAllowedSessionHandler, validate( getDraftedDataValid ), getDraftedData );
@@ -0,0 +1,10 @@
1
+ import auditStoreDataModel from 'tango-api-schema/schema/auditStoreData.model.js';
2
+
3
+
4
+ export function aggregateAuditStoreDataSchema( query ) {
5
+ return auditStoreDataModel.aggregate( query, { collation: { locale: 'en', strength: 2 } } );
6
+ }
7
+
8
+ export function findOneStoreData( query, fields, sort ) {
9
+ return auditStoreDataModel.findOne( query, fields ).sort( sort );
10
+ }
@@ -1,5 +1,5 @@
1
1
  import { checkFileExist, getJsonFileData, listFileWithoutLimit, signedUrl } from 'tango-app-api-middleware';
2
- import { findOneStoreZoneAudit } from '../service/storeZoneAudit.service.js';
2
+ import { findOneStoreAudit } from '../service/storeAudit.service.js';
3
3
 
4
4
  export async function isAuditDocumentExist( req, res, next ) {
5
5
  try {
@@ -9,7 +9,7 @@ export async function isAuditDocumentExist( req, res, next ) {
9
9
  fileDate: inputData.fileDate,
10
10
  zoneName: inputData.zoneName,
11
11
  };
12
- const auditInfo = await findOneStoreZoneAudit( query );
12
+ const auditInfo = await findOneStoreAudit( query );
13
13
  if ( auditInfo ) {
14
14
  req.audit = auditInfo;
15
15
  return next();
@@ -1,42 +0,0 @@
1
- import { logger } from 'tango-app-api-middleware';
2
- import { aggregateClient } from '../service/client.service.js';
3
-
4
- export async function clients( req, res ) {
5
- try {
6
- const inputData = req.query;
7
- const query =[
8
- {
9
- $match: {
10
- 'status': { $in: [ 'active', 'hold' ] },
11
- 'auditConfigs.audit': true,
12
- },
13
- },
14
- {
15
- $project: {
16
- _id: 0,
17
- clientName: 1,
18
- clientId: 1,
19
- },
20
- },
21
- ];
22
-
23
- const count = await aggregateClient( 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 getAuditClients = await aggregateClient( query );
35
-
36
- return res.sendSuccess( { result: getAuditClients, count: count.length } );
37
- } catch ( error ) {
38
- const err = error.message || 'Internal Server Error';
39
- logger.info( { error: error, messgae: req.query, function: 'clients' } );
40
- return res.sendError( err, 500 );
41
- }
42
- }
@@ -1,42 +0,0 @@
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 +0,0 @@
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,33 +0,0 @@
1
- import j2s from 'joi-to-swagger';
2
- import { clientSchema } from '../dtos/client.dtos.js';
3
-
4
- export const clientDocs = {
5
- '/v3/audit/client/clients': {
6
- get: {
7
- tags: [ 'Audit/Client' ],
8
- description: 'Get client list which is enable for audit',
9
- operationId: 'clients',
10
- parameters: [
11
- {
12
- in: 'query',
13
- name: 'limit',
14
- scema: j2s( clientSchema ).swagger,
15
- require: false,
16
- },
17
- {
18
- in: 'query',
19
- name: 'offset',
20
- scema: j2s( clientSchema ).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
- };