tango-app-api-client 3.6.5-vms.0 → 3.6.5-vms.10
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 +4 -3
- package/src/controllers/client.controllers.js +291 -3
- package/src/controllers/vmsAudit.controller.js +345 -0
- package/src/dtos/client.dtos.js +76 -1
- package/src/dtos/vmsAudit.dtos.js +24 -0
- package/src/routes/client.routes.js +7 -2
- package/src/routes/vmsAudit.routes.js +10 -0
- package/src/service/client.service.js +4 -0
- package/src/service/vmsStoreRequest.service.js +13 -0
- package/src/service/vmsauditLog.service.js +10 -0
- package/src/service/vmsuserAudit.service.js +22 -0
package/package.json
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tango-app-api-client",
|
|
3
|
-
"version": "3.6.5-vms.
|
|
3
|
+
"version": "3.6.5-vms.10",
|
|
4
4
|
"description": "client",
|
|
5
5
|
"main": "index.js",
|
|
6
|
-
"type": "module",
|
|
6
|
+
"type": "module",
|
|
7
7
|
"scripts": {
|
|
8
8
|
"start": "nodemon --exec \"eslint --fix . && node app.js\"",
|
|
9
9
|
"build:patch": "node build.js patch && npm publish",
|
|
@@ -18,6 +18,7 @@
|
|
|
18
18
|
"dependencies": {
|
|
19
19
|
"aws-sdk": "^2.1560.0",
|
|
20
20
|
"cors": "^2.8.5",
|
|
21
|
+
"dayjs": "^1.11.19",
|
|
21
22
|
"dotenv": "^16.4.4",
|
|
22
23
|
"express": "^4.18.2",
|
|
23
24
|
"express-fileupload": "^1.4.3",
|
|
@@ -30,7 +31,7 @@
|
|
|
30
31
|
"npm": "^10.9.1",
|
|
31
32
|
"sharp": "^0.34.3",
|
|
32
33
|
"swagger-ui-express": "^5.0.0",
|
|
33
|
-
"tango-api-schema": "^2.4.
|
|
34
|
+
"tango-api-schema": "^2.4.27",
|
|
34
35
|
"tango-app-api-middleware": "^3.6.0",
|
|
35
36
|
"winston": "^3.11.0",
|
|
36
37
|
"winston-daily-rotate-file": "^5.0.0"
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { billingDetailsUpdate, brandInfoUpdate, domainDetailsConfigurationUpdate, featureConfigurationUpdate, getClientData, signatoryDetailsUpdate, ticketConfigurationUpdate, documentsUpdate, getUserData, CsmUsersGet, OpsUsersGet, userConfigurationUpdate, findClient, aggregateClient, createAuditQueue, findOne, insert, update, findOneClient, updateOneClient } from '../service/client.service.js';
|
|
2
2
|
import { checkFileExist, signedUrl, chunkArray, download, logger, getOpenSearchData, insertOpenSearchData, sendEmailWithSES, createCustomer, createVirtualAccount, getUuid, fileRestrictedUpload, getXsscheck, customSignedUrl } from 'tango-app-api-middleware';
|
|
3
3
|
import { countDocumentsUser, findOneAndUpdateUser, findOneUser, getUserNameEmailById, updateManyUser } from '../service/user.service.js';
|
|
4
|
-
import { aggregateStore, countDocumentsStore, findStore, updateManyStore } from '../service/store.service.js';
|
|
4
|
+
import { aggregateStore, countDocumentsStore, findOneStore, findStore, updateManyStore } from '../service/store.service.js';
|
|
5
5
|
import { aggregateCamera, countDocumentsCamera } from '../service/camera.service.js';
|
|
6
6
|
import _ from 'lodash';
|
|
7
7
|
import { findOneStandaredRole } from '../service/standaredRole.service.js';
|
|
@@ -18,6 +18,8 @@ import { countDocumentsClusters, createclusterModel } from '../service/cluster.s
|
|
|
18
18
|
import { countDocumentsTeams } from '../service/teams.service.js';
|
|
19
19
|
import { createauditConfig, updateauditConfig, aggregateAuditconfig } from '../service/auditConfig.service.js';
|
|
20
20
|
import { findOnerevopConfig, createrevopConfig, updaterevopConfig } from '../service/revopConfig.service.js';
|
|
21
|
+
import clientModel from 'tango-api-schema/schema/client.model.js';
|
|
22
|
+
import { aggregateVmsStoreRequest, updateOneUpsertVmsStoreRequest, updateOneVmsStoreRequest } from '../service/vmsStoreRequest.service.js';
|
|
21
23
|
|
|
22
24
|
export async function create( req, res ) {
|
|
23
25
|
try {
|
|
@@ -2965,10 +2967,89 @@ export async function updateFDConfig( req, res ) {
|
|
|
2965
2967
|
export async function getFDConfig( req, res ) {
|
|
2966
2968
|
try {
|
|
2967
2969
|
const inputData = req.query;
|
|
2968
|
-
let result = await findOneClient( { clientId: inputData.clientId }, { footfallDirectoryConfigs: 1 } );
|
|
2969
|
-
|
|
2970
|
+
// let result = await findOneClient( { clientId: inputData.clientId }, { footfallDirectoryConfigs: 1 } );
|
|
2971
|
+
const configQuery = [
|
|
2972
|
+
{
|
|
2973
|
+
$match: {
|
|
2974
|
+
clientId: inputData?.clientId,
|
|
2975
|
+
},
|
|
2976
|
+
},
|
|
2977
|
+
|
|
2978
|
+
// Convert all effectiveFrom to proper Date
|
|
2979
|
+
{
|
|
2980
|
+
$addFields: {
|
|
2981
|
+
taggingLimitationWithDate: {
|
|
2982
|
+
$map: {
|
|
2983
|
+
input: '$footfallDirectoryConfigs.taggingLimitation',
|
|
2984
|
+
as: 'item',
|
|
2985
|
+
in: {
|
|
2986
|
+
effectiveFrom: { $toDate: '$$item.effectiveFrom' },
|
|
2987
|
+
values: '$$item.values',
|
|
2988
|
+
},
|
|
2989
|
+
},
|
|
2990
|
+
},
|
|
2991
|
+
},
|
|
2992
|
+
},
|
|
2993
|
+
|
|
2994
|
+
// Filter items <= input date
|
|
2995
|
+
{
|
|
2996
|
+
$addFields: {
|
|
2997
|
+
matchedLimitation: {
|
|
2998
|
+
$filter: {
|
|
2999
|
+
input: '$taggingLimitationWithDate',
|
|
3000
|
+
as: 'item',
|
|
3001
|
+
cond: {
|
|
3002
|
+
$lte: [
|
|
3003
|
+
'$$item.effectiveFrom',
|
|
3004
|
+
{ $toDate: inputData.dateString },
|
|
3005
|
+
],
|
|
3006
|
+
},
|
|
3007
|
+
},
|
|
3008
|
+
},
|
|
3009
|
+
},
|
|
3010
|
+
},
|
|
3011
|
+
|
|
3012
|
+
// Sort DESC and pick ONLY top 1 -> latest effective record
|
|
3013
|
+
{
|
|
3014
|
+
$addFields: {
|
|
3015
|
+
effectiveLimitation: {
|
|
3016
|
+
$arrayElemAt: [
|
|
3017
|
+
{
|
|
3018
|
+
$slice: [
|
|
3019
|
+
{
|
|
3020
|
+
$sortArray: {
|
|
3021
|
+
input: '$matchedLimitation',
|
|
3022
|
+
sortBy: { effectiveFrom: -1 },
|
|
3023
|
+
},
|
|
3024
|
+
},
|
|
3025
|
+
1,
|
|
3026
|
+
],
|
|
3027
|
+
},
|
|
3028
|
+
0,
|
|
3029
|
+
],
|
|
3030
|
+
},
|
|
3031
|
+
},
|
|
3032
|
+
},
|
|
3033
|
+
|
|
3034
|
+
{
|
|
3035
|
+
$project: {
|
|
3036
|
+
'config': 1,
|
|
3037
|
+
'effectiveLimitation': 1,
|
|
3038
|
+
'footfallDirectoryConfigs': 1,
|
|
3039
|
+
|
|
3040
|
+
},
|
|
3041
|
+
},
|
|
3042
|
+
];
|
|
3043
|
+
|
|
3044
|
+
|
|
3045
|
+
const getData = await aggregateClient( configQuery );
|
|
3046
|
+
let result = getData[0];
|
|
3047
|
+
if ( !result || result===null ) {
|
|
2970
3048
|
return res.sendError( 'no data found', 204 );
|
|
2971
3049
|
}
|
|
3050
|
+
result.footfallDirectoryConfigs.taggingLimitation = result?.effectiveLimitation?.values;
|
|
3051
|
+
delete result.effectiveLimitation;
|
|
3052
|
+
|
|
2972
3053
|
return res.sendSuccess( result );
|
|
2973
3054
|
} catch ( error ) {
|
|
2974
3055
|
const err = error.message || 'Internal Server Error';
|
|
@@ -2977,3 +3058,210 @@ export async function getFDConfig( req, res ) {
|
|
|
2977
3058
|
}
|
|
2978
3059
|
}
|
|
2979
3060
|
|
|
3061
|
+
|
|
3062
|
+
export async function updateTaggingType( req, res ) {
|
|
3063
|
+
try {
|
|
3064
|
+
const inputData = req.body;
|
|
3065
|
+
|
|
3066
|
+
const inputQuery = req.query; // up
|
|
3067
|
+
const types = inputData?.taggingLimitation?.map( ( x ) => x.type );
|
|
3068
|
+
// Step 1: remove existing items with same "type"
|
|
3069
|
+
await clientModel.updateOne(
|
|
3070
|
+
{ clientId: inputQuery.clientId },
|
|
3071
|
+
{
|
|
3072
|
+
$pull: {
|
|
3073
|
+
'footfallDirectoryConfigs.taggingLimitation': {
|
|
3074
|
+
type: { $in: types },
|
|
3075
|
+
},
|
|
3076
|
+
},
|
|
3077
|
+
},
|
|
3078
|
+
);
|
|
3079
|
+
|
|
3080
|
+
// Remove duplicate entries by type
|
|
3081
|
+
const uniqueData = uniqueByType( inputData.taggingLimitation );
|
|
3082
|
+
|
|
3083
|
+
// Step 2: insert fresh new items
|
|
3084
|
+
let result =await clientModel.updateOne(
|
|
3085
|
+
{ clientId: inputQuery.clientId },
|
|
3086
|
+
{
|
|
3087
|
+
$addToSet: {
|
|
3088
|
+
'footfallDirectoryConfigs.taggingLimitation': {
|
|
3089
|
+
$addToSet: {
|
|
3090
|
+
effectiveFrom: new Date().toISOString().split( 'T' )[0],
|
|
3091
|
+
values: uniqueData,
|
|
3092
|
+
},
|
|
3093
|
+
},
|
|
3094
|
+
},
|
|
3095
|
+
},
|
|
3096
|
+
);
|
|
3097
|
+
|
|
3098
|
+
if ( result?.acknowledged === true ) {
|
|
3099
|
+
return res.sendSuccess( result );
|
|
3100
|
+
} else {
|
|
3101
|
+
return res.sendError( 'no data', 204 );
|
|
3102
|
+
}
|
|
3103
|
+
} catch ( error ) {
|
|
3104
|
+
const err = error.message || 'Internal Server Error';
|
|
3105
|
+
logger.error( { error: error, message: req.query, function: 'updateTaggingType' } );
|
|
3106
|
+
return res.sendError( err, 500 );
|
|
3107
|
+
}
|
|
3108
|
+
}
|
|
3109
|
+
|
|
3110
|
+
function uniqueByType( arr ) {
|
|
3111
|
+
const seen = new Set();
|
|
3112
|
+
return arr.filter( ( item ) => {
|
|
3113
|
+
if ( seen.has( item.type ) ) return false;
|
|
3114
|
+
seen.add( item.type );
|
|
3115
|
+
return true;
|
|
3116
|
+
} );
|
|
3117
|
+
}
|
|
3118
|
+
|
|
3119
|
+
export async function createStoreRequest( req, res ) {
|
|
3120
|
+
try {
|
|
3121
|
+
const inputData = req.body;
|
|
3122
|
+
const getClientId = await findOneStore( { storeId: inputData?.storeId }, { clientId: 1, storeName: 1 } );
|
|
3123
|
+
const record = {
|
|
3124
|
+
clientId: getClientId?.clientId,
|
|
3125
|
+
storeId: inputData?.storeId,
|
|
3126
|
+
storeName: getClientId?.storeName,
|
|
3127
|
+
dateString: inputData?.dateString,
|
|
3128
|
+
raisedBy: req?.user?._id,
|
|
3129
|
+
status: 'request',
|
|
3130
|
+
|
|
3131
|
+
};
|
|
3132
|
+
const upsertRecord = await updateOneUpsertVmsStoreRequest( { storeId: inputData?.storeId, dateString: inputData?.dateString }, record );
|
|
3133
|
+
logger.info( { upsertRecord } );
|
|
3134
|
+
if ( upsertRecord?.upsertedCount === 1 ) {
|
|
3135
|
+
return res.sendSuccess( 'The Request has been sent Successfully' );
|
|
3136
|
+
} else if ( upsertRecord?.matchedCount === 1 && upsertRecord?.modifiedCount === 1 ) {
|
|
3137
|
+
return res.sendSuccess( 'The Request has been updated Successfully' );
|
|
3138
|
+
} else if ( upsertRecord?.matchedCount === 1 && upsertRecord?.modifiedCount === 0 ) {
|
|
3139
|
+
return res.sendSuccess( 'The Request already exists and nothing to update' );
|
|
3140
|
+
} else {
|
|
3141
|
+
return res.sendError( 'Internal Server Error', 500 );
|
|
3142
|
+
}
|
|
3143
|
+
} catch ( error ) {
|
|
3144
|
+
const err = error.message || 'Internal Server Error';
|
|
3145
|
+
logger.error( { error: error, message: req.query, function: 'createStoreRequest' } );
|
|
3146
|
+
return res.sendError( err, 500 );
|
|
3147
|
+
}
|
|
3148
|
+
}
|
|
3149
|
+
|
|
3150
|
+
export async function listStoreRequest( req, res ) {
|
|
3151
|
+
try {
|
|
3152
|
+
const inputData = req.query;
|
|
3153
|
+
|
|
3154
|
+
const today = new Date();
|
|
3155
|
+
const threeDaysAgo = new Date();
|
|
3156
|
+
threeDaysAgo.setDate( today.getDate() - 3 );
|
|
3157
|
+
|
|
3158
|
+
const todayStr = today.toISOString().slice( 0, 10 );
|
|
3159
|
+
const threeDaysAgoStr = threeDaysAgo.toISOString().slice( 0, 10 );
|
|
3160
|
+
|
|
3161
|
+
|
|
3162
|
+
const query = [
|
|
3163
|
+
{
|
|
3164
|
+
$match: {
|
|
3165
|
+
$and: [
|
|
3166
|
+
{
|
|
3167
|
+
clientId: { $eq: inputData?.clientId },
|
|
3168
|
+
},
|
|
3169
|
+
{
|
|
3170
|
+
status: { $eq: 'request' },
|
|
3171
|
+
},
|
|
3172
|
+
{
|
|
3173
|
+
dateString: { $gte: threeDaysAgoStr, $lte: todayStr },
|
|
3174
|
+
},
|
|
3175
|
+
],
|
|
3176
|
+
},
|
|
3177
|
+
},
|
|
3178
|
+
{
|
|
3179
|
+
$project: {
|
|
3180
|
+
_id: 0,
|
|
3181
|
+
id: { $concat: [ '$storeId', '_', '$dateString' ] },
|
|
3182
|
+
storeName: 1,
|
|
3183
|
+
storeId: 1,
|
|
3184
|
+
dateString: 1,
|
|
3185
|
+
raisedOn: { $ifNull: [ { $dateToString: { format: '%d %b, %Y', date: '$createdAt' } }, '' ] },
|
|
3186
|
+
totalRaised: null,
|
|
3187
|
+
},
|
|
3188
|
+
},
|
|
3189
|
+
];
|
|
3190
|
+
const result = await aggregateVmsStoreRequest( query );
|
|
3191
|
+
if ( !result || result.length === 0 ) {
|
|
3192
|
+
return res.sendError( 'no data found', 204 );
|
|
3193
|
+
}
|
|
3194
|
+
const getStores = result.map( ( item ) => item.storeId );
|
|
3195
|
+
if ( !getStores || getStores.length === 0 ) {
|
|
3196
|
+
return res.sendError( 'no data found', 204 );
|
|
3197
|
+
}
|
|
3198
|
+
const getCountQuery = [
|
|
3199
|
+
{
|
|
3200
|
+
$match: {
|
|
3201
|
+
$and: [
|
|
3202
|
+
{
|
|
3203
|
+
storeId: { $in: getStores },
|
|
3204
|
+
},
|
|
3205
|
+
{
|
|
3206
|
+
status: 'reset',
|
|
3207
|
+
},
|
|
3208
|
+
],
|
|
3209
|
+
},
|
|
3210
|
+
},
|
|
3211
|
+
{
|
|
3212
|
+
$sort: {
|
|
3213
|
+
createdAt: -1,
|
|
3214
|
+
},
|
|
3215
|
+
},
|
|
3216
|
+
{
|
|
3217
|
+
$group: {
|
|
3218
|
+
_id: '$storeId',
|
|
3219
|
+
storeId: { $first: '$storeId' },
|
|
3220
|
+
lastRaised: { $first: '$createdAt' },
|
|
3221
|
+
total: { $sum: 1 },
|
|
3222
|
+
|
|
3223
|
+
},
|
|
3224
|
+
},
|
|
3225
|
+
{
|
|
3226
|
+
$project: {
|
|
3227
|
+
_id: 0,
|
|
3228
|
+
storeId: 1,
|
|
3229
|
+
lastRaised: { $dateToString: { format: '%d %b, %Y', date: '$lastRaised' } },
|
|
3230
|
+
totalRaised: '$total',
|
|
3231
|
+
},
|
|
3232
|
+
},
|
|
3233
|
+
];
|
|
3234
|
+
|
|
3235
|
+
const getCounts = await aggregateVmsStoreRequest( getCountQuery );
|
|
3236
|
+
if ( !getCounts || getCounts?.length === 0 ) {
|
|
3237
|
+
return res.sendSuccess( { result: result } );
|
|
3238
|
+
} else {
|
|
3239
|
+
const merged = result.map( ( item ) => {
|
|
3240
|
+
const match = getCounts.find( ( g ) => g.storeId === item.storeId );
|
|
3241
|
+
|
|
3242
|
+
return {
|
|
3243
|
+
...item,
|
|
3244
|
+
...( match || {} ),
|
|
3245
|
+
};
|
|
3246
|
+
} );
|
|
3247
|
+
return res.sendSuccess( { result: merged } );
|
|
3248
|
+
}
|
|
3249
|
+
} catch ( error ) {
|
|
3250
|
+
const err = error.message || 'Internal Server Error';
|
|
3251
|
+
logger.error( { error: error, message: req.query, function: 'listStoreRequest' } );
|
|
3252
|
+
return res.sendError( err, 500 );
|
|
3253
|
+
}
|
|
3254
|
+
}
|
|
3255
|
+
export async function resetStoreRequest( req, res ) {
|
|
3256
|
+
try {
|
|
3257
|
+
const inputData = req.body;
|
|
3258
|
+
for ( const item of inputData?.arrayOfStores ) {
|
|
3259
|
+
await updateOneVmsStoreRequest( { clientId: inputData.clientId, storeId: item.storeId, dateString: item.dateString }, { status: 'reset', appovedBy: req?.user?._id } );
|
|
3260
|
+
}
|
|
3261
|
+
return res.sendSuccess( 'The Request has been reset Successfully' );
|
|
3262
|
+
} catch ( error ) {
|
|
3263
|
+
const err = error.message || 'Internal Server Error';
|
|
3264
|
+
logger.error( { error: error, message: req.body, function: 'resetStoreRequest' } );
|
|
3265
|
+
return res.sendError( err, 500 );
|
|
3266
|
+
}
|
|
3267
|
+
}
|
|
@@ -0,0 +1,345 @@
|
|
|
1
|
+
import { logger, searchOpenSearchData } from 'tango-app-api-middleware';
|
|
2
|
+
import { findOneStore } from '../service/store.service.js';
|
|
3
|
+
import { aggregatevmsUserAudit, createvmsUserAudit, findOnevmsUserAudit, updateOnevmsUserAudit } from '../service/vmsuserAudit.service.js';
|
|
4
|
+
import { createvmsAuditLog, findOnevmsAuditLog } from '../service/vmsauditLog.service.js';
|
|
5
|
+
import { insertOpenSearchData, clearScroll, scrollResponse } from 'tango-app-api-middleware';
|
|
6
|
+
import { findOneUser } from '../service/user.service.js';
|
|
7
|
+
import dayjs from 'dayjs';
|
|
8
|
+
import utc from 'dayjs/plugin/utc.js';
|
|
9
|
+
import timezone from 'dayjs/plugin/timezone.js';
|
|
10
|
+
|
|
11
|
+
dayjs.extend( utc );
|
|
12
|
+
dayjs.extend( timezone );
|
|
13
|
+
export async function getAuditFile( req, res ) {
|
|
14
|
+
try {
|
|
15
|
+
// const bucket = JSON.parse( process.env.BUCKET );
|
|
16
|
+
const url = JSON.parse( process.env.URL );
|
|
17
|
+
const openSearch = JSON.parse( process.env.OPENSEARCH );
|
|
18
|
+
const inputData = req.query;
|
|
19
|
+
const files = [];
|
|
20
|
+
const storeQuery = {
|
|
21
|
+
storeId: inputData.storeId,
|
|
22
|
+
};
|
|
23
|
+
const storeFields = {
|
|
24
|
+
storeName: 1,
|
|
25
|
+
clientId: 1,
|
|
26
|
+
address: '$storeProfile.address',
|
|
27
|
+
};
|
|
28
|
+
const storeInfo = await findOneStore( storeQuery, storeFields );
|
|
29
|
+
|
|
30
|
+
const userQuery = [
|
|
31
|
+
{
|
|
32
|
+
$match: {
|
|
33
|
+
$and: [
|
|
34
|
+
{ userId: req.user._id },
|
|
35
|
+
{ auditStatus: { $nin: [ 'completed', 'skipped' ] } },
|
|
36
|
+
{ storeId: inputData.storeId },
|
|
37
|
+
{ fileDate: inputData.Date },
|
|
38
|
+
],
|
|
39
|
+
},
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
$sort: { createdAt: -1 },
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
$limit: 1,
|
|
46
|
+
},
|
|
47
|
+
];
|
|
48
|
+
|
|
49
|
+
const userDetails = await aggregatevmsUserAudit( userQuery );
|
|
50
|
+
console.log( '🚀 ~ getAuditFile ~ userDetails:', userDetails );
|
|
51
|
+
const auditStatus = userDetails && userDetails.length > 0 ? userDetails[0].auditStatus : null;
|
|
52
|
+
if ( auditStatus === 'drafted' ) {
|
|
53
|
+
const log = await findOnevmsAuditLog(
|
|
54
|
+
{
|
|
55
|
+
userId: userDetails[0].userId,
|
|
56
|
+
fileDate: userDetails[0].fileDate,
|
|
57
|
+
storeId: userDetails[0].storeId,
|
|
58
|
+
totalCount: userDetails[0].beforeCount,
|
|
59
|
+
},
|
|
60
|
+
{},
|
|
61
|
+
{ createdAt: -1 },
|
|
62
|
+
);
|
|
63
|
+
console.log( '🚀 ~ getAuditFile ~ log:', log );
|
|
64
|
+
if ( !log ) {
|
|
65
|
+
await updateOnevmsUserAudit(
|
|
66
|
+
{ _id: userDetails[0]._id },
|
|
67
|
+
{ $set: { isDraft: false, auditStatus: 'skipped' } },
|
|
68
|
+
);
|
|
69
|
+
logger.info( 'audit update in drafted', {
|
|
70
|
+
_id: userDetails[0]._id,
|
|
71
|
+
isDraft: false,
|
|
72
|
+
auditStatus: 'skipped',
|
|
73
|
+
} );
|
|
74
|
+
return res.sendError( 'User saved data has been deleted', 204 );
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
const file = {
|
|
78
|
+
auditId: userDetails[0]._id,
|
|
79
|
+
storeId: userDetails[0].storeId,
|
|
80
|
+
Date: userDetails[0].fileDate,
|
|
81
|
+
userId: log.userId,
|
|
82
|
+
timeSpent: log.timeSpent,
|
|
83
|
+
clientId: userDetails[0].clientId,
|
|
84
|
+
};
|
|
85
|
+
const userdata = await findOneUser( { _id: log.userId } );
|
|
86
|
+
if (
|
|
87
|
+
!inputData.nextId ||
|
|
88
|
+
inputData.nextId === '' ||
|
|
89
|
+
inputData.nextId == null
|
|
90
|
+
) {
|
|
91
|
+
const logData = {
|
|
92
|
+
userId: log.userId,
|
|
93
|
+
userName: userdata.userName,
|
|
94
|
+
logType: 'vmsaudit',
|
|
95
|
+
logSubType: 'auditStart',
|
|
96
|
+
logData: {
|
|
97
|
+
fileDate: userDetails[0].fileDate,
|
|
98
|
+
storeId: userDetails[0].storeId,
|
|
99
|
+
auditId: userDetails[0]._id,
|
|
100
|
+
beforeCount: userDetails[0].beforeCount,
|
|
101
|
+
},
|
|
102
|
+
createdAt: new Date(),
|
|
103
|
+
};
|
|
104
|
+
await insertOpenSearchData( openSearch.vmsauditLog, logData );
|
|
105
|
+
}
|
|
106
|
+
const storeQuery = {
|
|
107
|
+
storeId: userDetails[0].storeId,
|
|
108
|
+
};
|
|
109
|
+
const storeFields = {
|
|
110
|
+
storeId: 1,
|
|
111
|
+
storeName: 1,
|
|
112
|
+
address: '$storeProfile.address',
|
|
113
|
+
};
|
|
114
|
+
const storeDetails = await findOneStore( storeQuery, storeFields );
|
|
115
|
+
return res.sendSuccess( {
|
|
116
|
+
result: log.draftedData,
|
|
117
|
+
storeId: storeDetails?.storeId,
|
|
118
|
+
storeName: storeDetails?.storeName,
|
|
119
|
+
address: storeDetails?.address || '',
|
|
120
|
+
count: log.totalCount,
|
|
121
|
+
timeSpent: log.timeSpent,
|
|
122
|
+
file: file,
|
|
123
|
+
isDraft: userDetails[0].isDraft,
|
|
124
|
+
} );
|
|
125
|
+
}
|
|
126
|
+
console.log( inputData );
|
|
127
|
+
|
|
128
|
+
const query = {
|
|
129
|
+
size: inputData?.limit || 2,
|
|
130
|
+
_source: [ 'module', 'status', 'date', 'store_id', 'outputCluster', 'personPath', 'REIDCluster', 'isEmployee', 'isJunk', 'EmployeeStatusFinal' ], // Only fetch necessary fields
|
|
131
|
+
|
|
132
|
+
query: {
|
|
133
|
+
bool: {
|
|
134
|
+
'must': [
|
|
135
|
+
{
|
|
136
|
+
term: { 'store_id.keyword': inputData.storeId },
|
|
137
|
+
},
|
|
138
|
+
{
|
|
139
|
+
term: { 'date.keyword': dayjs( inputData.Date ).format( 'DD-MM-YYYY' ) },
|
|
140
|
+
},
|
|
141
|
+
{
|
|
142
|
+
term: { 'module.keyword': 'CUSTOMER' },
|
|
143
|
+
},
|
|
144
|
+
{
|
|
145
|
+
term: { 'status.keyword': 'PP_CLUSTER_FORMED' },
|
|
146
|
+
},
|
|
147
|
+
{
|
|
148
|
+
terms: { EmployeeStatusFinal: [ 1, 2 ] },
|
|
149
|
+
},
|
|
150
|
+
],
|
|
151
|
+
'should': [
|
|
152
|
+
{ 'term': { 'isJunk': false } },
|
|
153
|
+
{ 'bool': { 'must_not': { 'exists': { 'field': 'isJunk' } } } },
|
|
154
|
+
],
|
|
155
|
+
'minimum_should_match': 1,
|
|
156
|
+
},
|
|
157
|
+
},
|
|
158
|
+
|
|
159
|
+
};
|
|
160
|
+
console.log( openSearch.vmsAudit );
|
|
161
|
+
let list =inputData.nextId? await scrollResponse( inputData.nextId ): await searchOpenSearchData( openSearch.vmsAudit, query );
|
|
162
|
+
const folderPath = list?.body?.hits?.hits;
|
|
163
|
+
if ( list?.body?.hits?.hits?.length ==0 ) {
|
|
164
|
+
await clearScroll( list?.body?._scroll_id );
|
|
165
|
+
}
|
|
166
|
+
if ( folderPath?.length > 0 ) {
|
|
167
|
+
for ( let i = 0; i < folderPath.length; i++ ) {
|
|
168
|
+
const img = folderPath[i]?._source?.personPath?.split( '/' );
|
|
169
|
+
const image = img[3]?.split( '.' );
|
|
170
|
+
const indexes = folderPath[i]?._source?.outputCluster === 50000 ? folderPath[i]?._source?.REIDCluster : folderPath[i]?._source?.outputCluster;
|
|
171
|
+
// fetchData.file_path = folderPath[i]?._source?.personPath;
|
|
172
|
+
const data = `${url.trackInput}${folderPath[i]?._source?.personPath}`;
|
|
173
|
+
const mapimg = {
|
|
174
|
+
img_path: data,
|
|
175
|
+
img_name: indexes,
|
|
176
|
+
img_id: image[0],
|
|
177
|
+
};
|
|
178
|
+
addUniqueFile( files, {
|
|
179
|
+
img_path: data,
|
|
180
|
+
img_name: indexes,
|
|
181
|
+
img_id: image[0],
|
|
182
|
+
selected: false,
|
|
183
|
+
dropped: false,
|
|
184
|
+
demographic: '',
|
|
185
|
+
count: 1,
|
|
186
|
+
mappedid: [ mapimg ],
|
|
187
|
+
} );
|
|
188
|
+
}
|
|
189
|
+
} else if ( inputData.nextId !== '' && inputData.nextId !== null && inputData.nextId !== undefined ) {
|
|
190
|
+
if ( !list ) {
|
|
191
|
+
return res.sendError( 'token expired', 404 );
|
|
192
|
+
}
|
|
193
|
+
list.body._scroll_id = '';
|
|
194
|
+
// insertData = userDetails[0];
|
|
195
|
+
} else {
|
|
196
|
+
logger.error( {
|
|
197
|
+
error: { folderPath: folderPath, nextQuery: inputData.nextId },
|
|
198
|
+
function: 'getAuditFile',
|
|
199
|
+
message: 'Bucket image data not availale',
|
|
200
|
+
} );
|
|
201
|
+
return res.sendError( 'Bucket is Empty', 204 );
|
|
202
|
+
}
|
|
203
|
+
const [ year, month, day ] = inputData.Date.split( '-' );
|
|
204
|
+
const temp = `${year}-${month}-${day}`;
|
|
205
|
+
console.log( temp );
|
|
206
|
+
let start = new Date( temp );
|
|
207
|
+
const userTimezoneOffset = start.getTimezoneOffset() * 60000;
|
|
208
|
+
start = new Date( start.getTime() - userTimezoneOffset );
|
|
209
|
+
start.setUTCHours( 0, 0, 0, 0 );
|
|
210
|
+
console.log( start );
|
|
211
|
+
const record = {
|
|
212
|
+
userId: req.user._id,
|
|
213
|
+
storeId: inputData.storeId,
|
|
214
|
+
clientId: storeInfo?.clientId,
|
|
215
|
+
fileDate: inputData.Date,
|
|
216
|
+
beforeCount: inputData.count,
|
|
217
|
+
auditStatus: 'inprogress',
|
|
218
|
+
fileDateISO: start,
|
|
219
|
+
timeSpent: 0,
|
|
220
|
+
startTime: new Date(),
|
|
221
|
+
};
|
|
222
|
+
const insertData = await createvmsUserAudit( record );
|
|
223
|
+
if ( inputData.nextId !== '' && inputData.nextId !== null && inputData.nextId !== undefined && inputData.moduleType === 'track' ) {
|
|
224
|
+
if ( !list ) {
|
|
225
|
+
return res.sendError( 'token expired', 404 );
|
|
226
|
+
}
|
|
227
|
+
list.body._scroll_id = '';
|
|
228
|
+
}
|
|
229
|
+
return res.sendSuccess( {
|
|
230
|
+
result: files,
|
|
231
|
+
count: inputData.count,
|
|
232
|
+
storeId: inputData.storeId,
|
|
233
|
+
storeName: storeInfo?.storeName,
|
|
234
|
+
address: storeInfo?.address,
|
|
235
|
+
file: {
|
|
236
|
+
clientId: storeInfo?.clientId,
|
|
237
|
+
storeId: inputData.storeId,
|
|
238
|
+
Date: inputData.Date,
|
|
239
|
+
auditId: insertData._id,
|
|
240
|
+
userId: insertData.userId,
|
|
241
|
+
nextToken: list?.body?._scroll_id ?list?.body?._scroll_id:null,
|
|
242
|
+
|
|
243
|
+
},
|
|
244
|
+
isDraft: insertData.isDraft,
|
|
245
|
+
} );
|
|
246
|
+
} catch ( error ) {
|
|
247
|
+
const err = error.message || 'Internal Server Error';
|
|
248
|
+
logger.error( {
|
|
249
|
+
error: error,
|
|
250
|
+
message: req.query,
|
|
251
|
+
function: 'getAuditFile',
|
|
252
|
+
} );
|
|
253
|
+
return res.sendError( err, 500 );
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
function addUniqueFile( files, newFile ) {
|
|
257
|
+
const exists = files.some( ( file ) => file.img_name === newFile.img_name );
|
|
258
|
+
if ( !exists ) {
|
|
259
|
+
files.push( newFile );
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
export async function saveDraft( req, res ) {
|
|
263
|
+
try {
|
|
264
|
+
const openSearch = JSON.parse( process.env.OPENSEARCH );
|
|
265
|
+
const inputData = req.body;
|
|
266
|
+
inputData.userId = req.user._id;
|
|
267
|
+
const getUserAuditData = await findOnevmsUserAudit( { _id: inputData.auditId } );
|
|
268
|
+
if ( !getUserAuditData ) {
|
|
269
|
+
return res.sendError( 'No Data Found', 204 );
|
|
270
|
+
}
|
|
271
|
+
if ( getUserAuditData.auditStatus == 'skipped' ) {
|
|
272
|
+
return res.sendError( 'File Assigned to Someone else', 203 );
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
const userQuery = {
|
|
276
|
+
_id: inputData.auditId,
|
|
277
|
+
};
|
|
278
|
+
let userRecord = {
|
|
279
|
+
isDraft: true,
|
|
280
|
+
auditStatus: 'drafted',
|
|
281
|
+
};
|
|
282
|
+
|
|
283
|
+
|
|
284
|
+
if ( getUserAuditData?.startTime ) {
|
|
285
|
+
userRecord.timeSpent = inputData.timeSpent;
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
if ( inputData.userCommands ) {
|
|
289
|
+
userRecord.userCommands = inputData.userCommands;
|
|
290
|
+
const logData = {
|
|
291
|
+
userId: req.user._id,
|
|
292
|
+
userName: req.user.userName,
|
|
293
|
+
logType: 'vmsaudit',
|
|
294
|
+
logSubType: 'auditDraft',
|
|
295
|
+
logData: {
|
|
296
|
+
fileDate: inputData.fileDate,
|
|
297
|
+
storeId: inputData.storeId,
|
|
298
|
+
beforeCount: inputData.totalCount,
|
|
299
|
+
afterCount: inputData.customerCount,
|
|
300
|
+
timeSpent: inputData.timeSpent,
|
|
301
|
+
auditId: inputData.auditId,
|
|
302
|
+
},
|
|
303
|
+
createdAt: new Date(),
|
|
304
|
+
};
|
|
305
|
+
await insertOpenSearchData( openSearch.vmsauditLog, logData );
|
|
306
|
+
}
|
|
307
|
+
await createvmsAuditLog( inputData );
|
|
308
|
+
await updateOnevmsUserAudit( userQuery, userRecord );
|
|
309
|
+
console.log( '🚀 ~ saveDraft ~ userRecord:', userRecord );
|
|
310
|
+
return res.sendSuccess( {
|
|
311
|
+
result: 'The file has been drafted successfully',
|
|
312
|
+
} );
|
|
313
|
+
} catch ( error ) {
|
|
314
|
+
const err = error.message || 'Internal Server Error';
|
|
315
|
+
logger.error( { error: error, message: req.body, function: 'saveDraft' } );
|
|
316
|
+
return res.sendError( err, 500 );
|
|
317
|
+
}
|
|
318
|
+
}
|
|
319
|
+
export async function getDraftedData( req, res ) {
|
|
320
|
+
try {
|
|
321
|
+
const inputData = req.query;
|
|
322
|
+
const userId = inputData.userId || req.user._id;
|
|
323
|
+
const query = {
|
|
324
|
+
fileDate: inputData.fileDate,
|
|
325
|
+
storeId: inputData.storeId,
|
|
326
|
+
userId: userId,
|
|
327
|
+
auditId: inputData.auditId,
|
|
328
|
+
};
|
|
329
|
+
console.log( query );
|
|
330
|
+
const result = await findOnevmsAuditLog( query, {}, { createdAt: -1 }, 1 );
|
|
331
|
+
|
|
332
|
+
if ( !result ) {
|
|
333
|
+
return res.sendError( 'No Data Found', 204 );
|
|
334
|
+
}
|
|
335
|
+
return res.sendSuccess( { result: result } );
|
|
336
|
+
} catch ( error ) {
|
|
337
|
+
const err = error.message || 'Internal Server Error';
|
|
338
|
+
logger.error( {
|
|
339
|
+
error: error,
|
|
340
|
+
message: req.query,
|
|
341
|
+
function: 'getDraftedData',
|
|
342
|
+
} );
|
|
343
|
+
return res.sendError( err, 500 );
|
|
344
|
+
}
|
|
345
|
+
}
|
package/src/dtos/client.dtos.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import joi from 'joi';
|
|
2
|
+
import dayjs from 'dayjs';
|
|
2
3
|
|
|
3
4
|
export const clientDetailsSchema = joi.object( {
|
|
4
5
|
id: joi.string().required(),
|
|
@@ -359,12 +360,15 @@ export const updateFDConfigBodySchema = joi.object( {
|
|
|
359
360
|
tangoReview: joi.string().optional(),
|
|
360
361
|
revision: joi.array().items( joi.object( {
|
|
361
362
|
actionType: joi.string().required(),
|
|
362
|
-
isChecked: joi.boolean().
|
|
363
|
+
isChecked: joi.boolean().optional().default( false ),
|
|
363
364
|
} ) ).optional(),
|
|
364
365
|
taggingLimitation: joi.array().items( joi.object( {
|
|
366
|
+
iconName: joi.string().optional(),
|
|
367
|
+
name: joi.string().optional(),
|
|
365
368
|
type: joi.string().required(),
|
|
366
369
|
value: joi.number().required(),
|
|
367
370
|
unit: joi.string().required(),
|
|
371
|
+
key: joi.string().required(),
|
|
368
372
|
} ) ).optional(),
|
|
369
373
|
|
|
370
374
|
} );
|
|
@@ -373,8 +377,12 @@ export const updateFDConfigQuerySchema = joi.object( {
|
|
|
373
377
|
clientId: joi.string().required(),
|
|
374
378
|
} );
|
|
375
379
|
|
|
380
|
+
|
|
381
|
+
const todayDate = () => new Date().toISOString().split( 'T' )[0];
|
|
382
|
+
|
|
376
383
|
export const getFDConfigSchema = joi.object( {
|
|
377
384
|
clientId: joi.string().required(),
|
|
385
|
+
dateString: joi.string().optional().default( () => todayDate() ),
|
|
378
386
|
} );
|
|
379
387
|
|
|
380
388
|
export const updateFDConfigValid = {
|
|
@@ -384,3 +392,70 @@ export const updateFDConfigValid = {
|
|
|
384
392
|
export const getFDConfigValid = {
|
|
385
393
|
query: getFDConfigSchema,
|
|
386
394
|
};
|
|
395
|
+
|
|
396
|
+
export const updateTaggingTypeSchema = joi.object( {
|
|
397
|
+
clientId: joi.string().required(),
|
|
398
|
+
taggingLimitation: joi.array().items( joi.object( {
|
|
399
|
+
type: joi.string().required(),
|
|
400
|
+
value: joi.number().required(),
|
|
401
|
+
unit: joi.string().required(),
|
|
402
|
+
} ) ).required(),
|
|
403
|
+
|
|
404
|
+
} );
|
|
405
|
+
|
|
406
|
+
export const updateTaggingTypeQuerySchema = joi.object( {
|
|
407
|
+
clientId: joi.string().required(),
|
|
408
|
+
} );
|
|
409
|
+
|
|
410
|
+
|
|
411
|
+
export const updateTaggingTypeValid = {
|
|
412
|
+
body: updateTaggingTypeSchema,
|
|
413
|
+
query: updateTaggingTypeQuerySchema,
|
|
414
|
+
};
|
|
415
|
+
|
|
416
|
+
export const createStoreRequestSchema = joi.object( {
|
|
417
|
+
storeId: joi.string().required(),
|
|
418
|
+
dateString: joi.string().required().custom( ( value, helpers ) => {
|
|
419
|
+
const inputDate = dayjs( value, 'YYYY-MM-DD', true );
|
|
420
|
+
const today = dayjs();
|
|
421
|
+
|
|
422
|
+
if ( !inputDate.isValid() ) {
|
|
423
|
+
return helpers.error( 'any.invalid' );
|
|
424
|
+
}
|
|
425
|
+
|
|
426
|
+
const diff = today.diff( inputDate, 'day' );
|
|
427
|
+
|
|
428
|
+
if ( diff > 3 ) {
|
|
429
|
+
return helpers.message( 'The request is not sent for a period exceeding 3 days' );
|
|
430
|
+
}
|
|
431
|
+
|
|
432
|
+
return value;
|
|
433
|
+
} ),
|
|
434
|
+
|
|
435
|
+
} );
|
|
436
|
+
|
|
437
|
+
export const createStoreRequestValid = {
|
|
438
|
+
body: createStoreRequestSchema,
|
|
439
|
+
};
|
|
440
|
+
|
|
441
|
+
export const listStoreRequestSchema = joi.object( {
|
|
442
|
+
clientId: joi.string().required(),
|
|
443
|
+
} );
|
|
444
|
+
|
|
445
|
+
export const listStoreRequestValid = {
|
|
446
|
+
query: listStoreRequestSchema,
|
|
447
|
+
};
|
|
448
|
+
|
|
449
|
+
export const resetStoreRequestSchema = joi.object( {
|
|
450
|
+
clientId: joi.string().required(),
|
|
451
|
+
arrayOfStores: joi.array().items(
|
|
452
|
+
joi.object( {
|
|
453
|
+
storeId: joi.string().required(),
|
|
454
|
+
dateString: joi.string().required(),
|
|
455
|
+
} ),
|
|
456
|
+
).required(),
|
|
457
|
+
} );
|
|
458
|
+
|
|
459
|
+
export const resetStoreRequestValid = {
|
|
460
|
+
body: resetStoreRequestSchema,
|
|
461
|
+
};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
|
|
2
|
+
import joi from 'joi';
|
|
3
|
+
export const getDraftedDataSchema = joi.object( {
|
|
4
|
+
storeId: joi.string().required(),
|
|
5
|
+
fileDate: joi.string().required(),
|
|
6
|
+
userId: joi.string().optional(),
|
|
7
|
+
auditId: joi.string().required(),
|
|
8
|
+
} );
|
|
9
|
+
export const getFileSchema = joi.object( {
|
|
10
|
+
nextId: joi.string().optional().allow( '' ),
|
|
11
|
+
limit: joi.number().optional(),
|
|
12
|
+
storeId: joi.string().required(),
|
|
13
|
+
Date: joi.string().required(),
|
|
14
|
+
count: joi.string().required(),
|
|
15
|
+
} );
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
export const getDraftedDataValid = {
|
|
19
|
+
query: getDraftedDataSchema,
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
export const getFileValid = {
|
|
23
|
+
query: getFileSchema,
|
|
24
|
+
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
|
|
2
2
|
import express from 'express';
|
|
3
|
-
import { activityLogValid, auditConfigValid, billingDetailsValid, brandInfoValid, clientCreationValid, clientDetailsValid, documentsValid, domainDetailsValid, featureConfigurationValid, getAssignedClientValid, getAuditConfigValid, getFDConfigValid, postClientCamApprovalValid, signatoryDetailsValid, ticketConfigurationValid, updateFDConfigValid, userConfigurationValid } from '../dtos/client.dtos.js';
|
|
4
|
-
import { auditConfiguration, changeStatus, clientCsmAssignAction, clientDetails, create, csmAssignConfirmation, domainDetailsConfiguration, getActivityLogs, getAuditConfiguration, getClients, getCsmUsers, getFDConfig, getOpsUsers, updateBillingDetails, updateBrandInfo, updateDocuments, updateFDConfig, updateFeatureConfiguration, updateSignatoryDetails, updateTicketConfiguration, userConfiguration } from '../controllers/client.controllers.js';
|
|
3
|
+
import { activityLogValid, auditConfigValid, billingDetailsValid, brandInfoValid, clientCreationValid, clientDetailsValid, createStoreRequestValid, documentsValid, domainDetailsValid, featureConfigurationValid, getAssignedClientValid, getAuditConfigValid, getFDConfigValid, listStoreRequestValid, postClientCamApprovalValid, resetStoreRequestValid, signatoryDetailsValid, ticketConfigurationValid, updateFDConfigValid, updateTaggingTypeValid, userConfigurationValid } from '../dtos/client.dtos.js';
|
|
4
|
+
import { auditConfiguration, changeStatus, clientCsmAssignAction, clientDetails, create, createStoreRequest, csmAssignConfirmation, domainDetailsConfiguration, getActivityLogs, getAuditConfiguration, getClients, getCsmUsers, getFDConfig, getOpsUsers, listStoreRequest, resetStoreRequest, updateBillingDetails, updateBrandInfo, updateDocuments, updateFDConfig, updateFeatureConfiguration, updateSignatoryDetails, updateTaggingType, updateTicketConfiguration, userConfiguration } from '../controllers/client.controllers.js';
|
|
5
5
|
import { accessVerification, isAllowedSessionHandler, validate } from 'tango-app-api-middleware';
|
|
6
6
|
import { clientListValid, detailedClientCountValid, createAuditConfigValid, AuditConfiglistValid, revopconfigValid, revopconfiggetValid } from '../dtos/client.dtos.js';
|
|
7
7
|
import { isclientIdExists, isclientNameExists, roleVerification } from '../validations/client.validations.js';
|
|
@@ -115,4 +115,9 @@ clientRouter.get( '/revopconfig', isAllowedSessionHandler,
|
|
|
115
115
|
// footfall directory configurations
|
|
116
116
|
clientRouter.put( '/update-footfall-directory-config', isAllowedSessionHandler, validate( updateFDConfigValid ), updateFDConfig );
|
|
117
117
|
clientRouter.get( '/get-footfall-directory-config', isAllowedSessionHandler, validate( getFDConfigValid ), getFDConfig );
|
|
118
|
+
clientRouter.put( '/update-tagging-type/', isAllowedSessionHandler, validate( updateTaggingTypeValid ), updateTaggingType );
|
|
118
119
|
|
|
120
|
+
// store request create/list/reset
|
|
121
|
+
clientRouter.post( '/create-store-request', isAllowedSessionHandler, validate( createStoreRequestValid ), createStoreRequest );
|
|
122
|
+
clientRouter.get( '/list-store-request', isAllowedSessionHandler, validate( listStoreRequestValid ), listStoreRequest );
|
|
123
|
+
clientRouter.post( '/reset-store-request', isAllowedSessionHandler, validate( resetStoreRequestValid ), resetStoreRequest );
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import express from 'express';
|
|
2
|
+
import { accessVerification, isAllowedSessionHandler, validate } from 'tango-app-api-middleware';
|
|
3
|
+
import { getDraftedDataValid, getFileValid } from '../dtos/vmsAudit.dtos.js';
|
|
4
|
+
import { getAuditFile, getDraftedData, saveDraft } from '../controllers/vmsAudit.controller.js';
|
|
5
|
+
export const vmsauditRouter = express.Router();
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
vmsauditRouter.get( '/get-file', isAllowedSessionHandler, accessVerification( { userType: [ 'tango' ] } ), validate( getFileValid ), getAuditFile );
|
|
9
|
+
vmsauditRouter.post( '/save-draft', isAllowedSessionHandler, accessVerification( { userType: [ 'tango' ] } ), saveDraft );
|
|
10
|
+
vmsauditRouter.get( '/get-drafted-data', isAllowedSessionHandler, accessVerification( { userType: [ 'tango' ] } ), validate( getDraftedDataValid ), getDraftedData );
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import vmsStoreRequestModel from 'tango-api-schema/schema/vmsStoreRequest.model.js';
|
|
2
|
+
|
|
3
|
+
export async function updateOneUpsertVmsStoreRequest( query, record ) {
|
|
4
|
+
return await vmsStoreRequestModel.updateOne( query, { $set: record }, { upsert: true } );
|
|
5
|
+
};
|
|
6
|
+
|
|
7
|
+
export async function updateOneVmsStoreRequest( query, record ) {
|
|
8
|
+
return await vmsStoreRequestModel.updateOne( query, { $set: record } );
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
export async function aggregateVmsStoreRequest( query ) {
|
|
12
|
+
return await vmsStoreRequestModel.aggregate( query );
|
|
13
|
+
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import vmsauditLogsModel from 'tango-api-schema/schema/vmsauditLogs.model.js';
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
export function createvmsAuditLog( record ) {
|
|
5
|
+
return vmsauditLogsModel.create( record );
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export function findOnevmsAuditLog( query, fields={}, sort={ createdAt: -1 }, limit=10 ) {
|
|
9
|
+
return vmsauditLogsModel.findOne( query, fields ).sort( sort ).limit( limit );
|
|
10
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import vmsuserAuditModel from 'tango-api-schema/schema/vmsuserAudit.model.js';
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
export function aggregatevmsUserAudit( query ) {
|
|
5
|
+
return vmsuserAuditModel.aggregate( query, { collation: { locale: 'en', strength: 2 } } );
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export function updateOnevmsUserAudit( query, record ) {
|
|
9
|
+
return vmsuserAuditModel.updateOne( query, { $set: record } );
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export function createvmsUserAudit( record ) {
|
|
13
|
+
return vmsuserAuditModel.create( record );
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export function findOnevmsUserAudit( query, fields ) {
|
|
17
|
+
return vmsuserAuditModel.findOne( query, fields );
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export function aggregatevmsUserAuditCount( query ) {
|
|
21
|
+
return vmsuserAuditModel.aggregate( query );
|
|
22
|
+
}
|