@simitgroup/simpleapp-generator 2.0.1-w-alpha → 2.0.1-x-alpha
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/ReleaseNote.md +6 -0
- package/package.json +1 -1
- package/templates/nest/src/simple-app/_core/features/cron/cron-system/cron-system.service.ts.eta +8 -8
- package/templates/nest/src/simple-app/_core/framework/base/simple-app.service.ts.eta +15 -18
- package/templates/nest/src/simple-app/_core/framework/schemas/simple-app.schema.ts.eta +1 -0
package/ReleaseNote.md
CHANGED
package/package.json
CHANGED
package/templates/nest/src/simple-app/_core/features/cron/cron-system/cron-system.service.ts.eta
CHANGED
|
@@ -15,25 +15,25 @@ export class CronSystemService extends SimpleAppCronBaseClass {
|
|
|
15
15
|
super(robotUserService);
|
|
16
16
|
}
|
|
17
17
|
|
|
18
|
-
|
|
18
|
+
//@Cron('0 1 * * *')
|
|
19
19
|
async deleteApiLog() {
|
|
20
|
-
if (process.env.ON_CRONTAB == 'true') {
|
|
21
|
-
this.logger.debug('run CronSystemService.deleteApiLog
|
|
20
|
+
//if (process.env.ON_CRONTAB == 'true') {
|
|
21
|
+
this.logger.debug('run CronSystemService.deleteApiLog')
|
|
22
22
|
const today = new Date();
|
|
23
23
|
const newDate = new Date(today.getTime());
|
|
24
24
|
const cutoffdate = new Date(newDate.setDate(newDate.getDate() - 90)).toISOString();
|
|
25
25
|
await this.apiEventModel.deleteMany({ created: { $lte: cutoffdate } });
|
|
26
|
-
}
|
|
26
|
+
//}
|
|
27
27
|
}
|
|
28
28
|
|
|
29
|
-
|
|
29
|
+
//@Cron('30 0 * * *')
|
|
30
30
|
async deleteQueueJob() {
|
|
31
|
-
if (process.env.ON_CRONTAB == 'true') {
|
|
32
|
-
this.logger.debug('run deleteQueueJob.deleteApiLog
|
|
31
|
+
//if (process.env.ON_CRONTAB == 'true') {
|
|
32
|
+
this.logger.debug('run deleteQueueJob.deleteApiLog')
|
|
33
33
|
const today = new Date();
|
|
34
34
|
const newDate = new Date(today.getTime());
|
|
35
35
|
const cutoffdate = new Date(newDate.setDate(newDate.getDate() - 90)).toISOString();
|
|
36
36
|
await this.queueJobModel.deleteMany({ created: { $lte: cutoffdate } });
|
|
37
|
-
}
|
|
37
|
+
//}
|
|
38
38
|
}
|
|
39
39
|
}
|
|
@@ -286,27 +286,24 @@ export class SimpleAppService<T extends SchemaFields> {
|
|
|
286
286
|
|
|
287
287
|
async fullTextSearch(appuser: UserContext, body: TextSearchBody) {
|
|
288
288
|
try {
|
|
289
|
+
//{filters:string[],fields:string[]}
|
|
289
290
|
const isolationFilter = { ...this.getIsolationFilter(appuser) };
|
|
290
291
|
this.polishIsolationFilter(isolationFilter);
|
|
291
292
|
const keyword = body.keyword;
|
|
292
|
-
|
|
293
|
+
// console.log("bodybody",body)
|
|
293
294
|
// Prepare regex filter
|
|
294
295
|
const orConditions: any[] = [];
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
296
|
+
const regex = new RegExp(keyword, 'i')
|
|
297
|
+
|
|
298
|
+
if (body.filters && body.filters.length > 0) {
|
|
299
|
+
body.filters.forEach((field: string) => {
|
|
298
300
|
orConditions.push({
|
|
299
|
-
[field]: { $regex:
|
|
300
|
-
});
|
|
301
|
-
} else {
|
|
302
|
-
if (!isNaN(Number(keyword)) && (field == 'defaultPrice' || field == 'amount')) {
|
|
303
|
-
orConditions.push({
|
|
304
|
-
[field]: { $gte: keyword },
|
|
305
|
-
});
|
|
306
|
-
}
|
|
307
|
-
}
|
|
301
|
+
[field]: { $regex: regex },
|
|
302
|
+
});
|
|
308
303
|
});
|
|
309
304
|
}
|
|
305
|
+
|
|
306
|
+
|
|
310
307
|
const filter = {
|
|
311
308
|
$or: orConditions,
|
|
312
309
|
};
|
|
@@ -318,7 +315,7 @@ export class SimpleAppService<T extends SchemaFields> {
|
|
|
318
315
|
|
|
319
316
|
const fields = body.fields || {};
|
|
320
317
|
const sorts = body.sorts || {};
|
|
321
|
-
|
|
318
|
+
// console.log("newfilters",JSON.stringify(newfilters),fields)
|
|
322
319
|
// Ensure `this.doc` is a Mongoose model or similar
|
|
323
320
|
const results = await this.doc.find(newfilters, fields).sort(sorts).exec();
|
|
324
321
|
|
|
@@ -499,7 +496,7 @@ export class SimpleAppService<T extends SchemaFields> {
|
|
|
499
496
|
errormsg.push(this.errorlist[i].message);
|
|
500
497
|
}
|
|
501
498
|
|
|
502
|
-
throw new BadRequestException(errormsg as HttpExceptionOptions,'Before validation hook failed');
|
|
499
|
+
throw new BadRequestException(errormsg as HttpExceptionOptions, 'Before validation hook failed');
|
|
503
500
|
}
|
|
504
501
|
|
|
505
502
|
let validate;
|
|
@@ -513,7 +510,7 @@ export class SimpleAppService<T extends SchemaFields> {
|
|
|
513
510
|
if (!valid) {
|
|
514
511
|
this.logger.error(JSON.stringify(data));
|
|
515
512
|
this.logger.error(JSON.stringify(validate.errors), 'validate errors:');
|
|
516
|
-
throw new BadRequestException(validate.errors as HttpExceptionOptions,'Data validation failed');
|
|
513
|
+
throw new BadRequestException(validate.errors as HttpExceptionOptions, 'Data validation failed');
|
|
517
514
|
}
|
|
518
515
|
}
|
|
519
516
|
|
|
@@ -1089,7 +1086,7 @@ export class SimpleAppService<T extends SchemaFields> {
|
|
|
1089
1086
|
|
|
1090
1087
|
if (!unionresult) {
|
|
1091
1088
|
this.logger.error('foreign key control failed ', 'identifyForeignKeys');
|
|
1092
|
-
throw new InternalServerErrorException(pipelines as HttpExceptionOptions,'Foreignkey check execution error');
|
|
1089
|
+
throw new InternalServerErrorException(pipelines as HttpExceptionOptions, 'Foreignkey check execution error');
|
|
1093
1090
|
} else {
|
|
1094
1091
|
const searchresult: any = {};
|
|
1095
1092
|
unionresult.forEach((item) => {
|
|
@@ -1099,7 +1096,7 @@ export class SimpleAppService<T extends SchemaFields> {
|
|
|
1099
1096
|
searchresult[item.collection] = [item._id];
|
|
1100
1097
|
}
|
|
1101
1098
|
});
|
|
1102
|
-
this.logger.debug(
|
|
1099
|
+
this.logger.debug(this.documentType + ' search Result', unionresult);
|
|
1103
1100
|
|
|
1104
1101
|
//search is it all foreign key exists in db
|
|
1105
1102
|
for (let i = 0; i < collections.length; i++) {
|