test-entity-library-asm 2.7.6 → 2.7.8
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/dist/CustomRepository.d.ts +5 -1
- package/dist/CustomRepository.js +167 -1
- package/package.json +1 -1
- package/src/CustomRepository.ts +208 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { DataSource, EntityTarget, Repository, ObjectLiteral } from 'typeorm';
|
|
2
|
-
import { IPropsDiscountUserOrCompany, IPropsQueryVerifyLocal } from './interfaces';
|
|
2
|
+
import { IBasicLazyEvent, IPropsDiscountUserOrCompany, IPropsQueryVerifyLocal } from './interfaces';
|
|
3
3
|
export declare class CustomRepository<T extends ObjectLiteral> extends Repository<T> {
|
|
4
4
|
constructor(target: EntityTarget<T>, dataSource: DataSource);
|
|
5
5
|
getVerifyLocals({ status, lazyEvent }: IPropsQueryVerifyLocal): Promise<{
|
|
@@ -10,5 +10,9 @@ export declare class CustomRepository<T extends ObjectLiteral> extends Repositor
|
|
|
10
10
|
data: T[];
|
|
11
11
|
totalRecords: number;
|
|
12
12
|
}>;
|
|
13
|
+
getDiscountsCodeCompany({ lazyEvent, }: IBasicLazyEvent): Promise<false | {
|
|
14
|
+
data: T[];
|
|
15
|
+
totalRecords: number;
|
|
16
|
+
}>;
|
|
13
17
|
anyOtherRepository(args: any): Promise<void>;
|
|
14
18
|
}
|
package/dist/CustomRepository.js
CHANGED
|
@@ -184,7 +184,7 @@ var CustomRepository = /** @class */ (function (_super) {
|
|
|
184
184
|
// DOC: Filtro global
|
|
185
185
|
if (lazyEvent.filters['global'] && lazyEvent.filters['global'].value) {
|
|
186
186
|
globalValue = "%".concat(lazyEvent.filters['global'].value.toLowerCase(), "%");
|
|
187
|
-
queryBuilder.andWhere('LOWER(
|
|
187
|
+
queryBuilder.andWhere('LOWER(discount_code_user.local_name) LIKE :globalValue OR LOWER(partner_surname) LIKE :globalValue OR LOWER(discount_code_user.code) LIKE :globalValue OR LOWER(discount_code_user.discount) LIKE :globalValue OR LOWER(partner_name) LIKE :globalValue', {
|
|
188
188
|
globalValue: globalValue ||
|
|
189
189
|
(0, utils_1.getStatusBasic)(lazyEvent.filters['global'].value.toLowerCase()) ||
|
|
190
190
|
(0, utils_1.getSeverityNameDiscountType)(lazyEvent.filters['global'].value.toLowerCase()),
|
|
@@ -354,6 +354,172 @@ var CustomRepository = /** @class */ (function (_super) {
|
|
|
354
354
|
});
|
|
355
355
|
});
|
|
356
356
|
};
|
|
357
|
+
CustomRepository.prototype.getDiscountsCodeCompany = function (_a) {
|
|
358
|
+
return __awaiter(this, arguments, void 0, function (_b) {
|
|
359
|
+
var timezone_1, queryBuilder_1, globalValue, filters_1, order, _c, discountsCodeCompany, totalRecords, error_1;
|
|
360
|
+
var lazyEvent = _b.lazyEvent;
|
|
361
|
+
return __generator(this, function (_d) {
|
|
362
|
+
switch (_d.label) {
|
|
363
|
+
case 0:
|
|
364
|
+
_d.trys.push([0, 2, , 3]);
|
|
365
|
+
timezone_1 = (0, _1.getTimezoneOffset)((0, _1.getTimeZone)());
|
|
366
|
+
queryBuilder_1 = this.createQueryBuilder('discount')
|
|
367
|
+
.leftJoinAndSelect('discount.updated_by', 'master')
|
|
368
|
+
.skip(lazyEvent.first)
|
|
369
|
+
.take(lazyEvent.rows);
|
|
370
|
+
if (lazyEvent.filters['global'] && lazyEvent.filters['global'].value) {
|
|
371
|
+
globalValue = "%".concat(lazyEvent.filters['global'].value.toLowerCase(), "%");
|
|
372
|
+
queryBuilder_1.andWhere('LOWER(discount.code) LIKE :globalValue OR LOWER(discount.discount) LIKE :globalValue OR LOWER(discount.use_limit) LIKE :globalValue OR LOWER(discount.repeat_days) LIKE :globalValue OR LOWER(discount.updated) LIKE :globalValue OR LOWER(discount.start) LIKE :globalValue OR LOWER(discount.created) LIKE :globalValue OR LOWER(discount.expiration) LIKE :globalValue OR LOWER(master.name) LIKE :globalValue OR LOWER(master.surname) LIKE :globalValue', {
|
|
373
|
+
globalValue: globalValue ||
|
|
374
|
+
(0, utils_1.getStatusBasic)(lazyEvent.filters['global'].value.toLowerCase()) ||
|
|
375
|
+
(0, utils_1.getSeverityNameDiscountType)(lazyEvent.filters['global'].value.toLowerCase()),
|
|
376
|
+
});
|
|
377
|
+
}
|
|
378
|
+
filters_1 = lazyEvent.filters;
|
|
379
|
+
Object.keys(filters_1).forEach(function (key) {
|
|
380
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
381
|
+
var _l, _m;
|
|
382
|
+
var value = filters_1[key].value;
|
|
383
|
+
if ((Array.isArray(value) && value.length > 0) ||
|
|
384
|
+
(!Array.isArray(value) && value && key !== 'global')) {
|
|
385
|
+
var matchMode = filters_1[key].matchMode;
|
|
386
|
+
if (!Array.isArray(value) && value) {
|
|
387
|
+
value = filters_1[key].value.toLowerCase();
|
|
388
|
+
}
|
|
389
|
+
var accessKey = key.split('.').length > 1 ? "".concat(key) : "discount.".concat(key);
|
|
390
|
+
switch (matchMode) {
|
|
391
|
+
case 'custom':
|
|
392
|
+
if ((key === 'number_of_times_used' || key === 'use_limit') &&
|
|
393
|
+
matchMode === 'custom') {
|
|
394
|
+
var _o = value || [null, null], from = _o[0], to = _o[1];
|
|
395
|
+
if (from !== null && to === null) {
|
|
396
|
+
queryBuilder_1.andWhere("discount.".concat(key, " >= :from"), {
|
|
397
|
+
from: from,
|
|
398
|
+
});
|
|
399
|
+
}
|
|
400
|
+
else if (from === null && to !== null) {
|
|
401
|
+
queryBuilder_1.andWhere("discount.".concat(key, " <= :to"), {
|
|
402
|
+
to: to,
|
|
403
|
+
});
|
|
404
|
+
}
|
|
405
|
+
else if (from !== null && to !== null) {
|
|
406
|
+
queryBuilder_1.andWhere("discount.".concat(key, " BETWEEN :from AND :to"), {
|
|
407
|
+
from: from,
|
|
408
|
+
to: to,
|
|
409
|
+
});
|
|
410
|
+
}
|
|
411
|
+
}
|
|
412
|
+
break;
|
|
413
|
+
case 'contains':
|
|
414
|
+
queryBuilder_1.andWhere("".concat(accessKey, " LIKE :").concat(key), (_a = {},
|
|
415
|
+
_a[key] = "%".concat(value, "%"),
|
|
416
|
+
_a));
|
|
417
|
+
break;
|
|
418
|
+
case 'startsWith':
|
|
419
|
+
queryBuilder_1.andWhere("".concat(accessKey, " LIKE :").concat(key), (_b = {},
|
|
420
|
+
_b[key] = "".concat(value, "%"),
|
|
421
|
+
_b));
|
|
422
|
+
break;
|
|
423
|
+
case 'endsWith':
|
|
424
|
+
queryBuilder_1.andWhere("".concat(accessKey, " LIKE :").concat(key), (_c = {},
|
|
425
|
+
_c[key] = "%".concat(value),
|
|
426
|
+
_c));
|
|
427
|
+
break;
|
|
428
|
+
case 'equals':
|
|
429
|
+
if (key === 'status') {
|
|
430
|
+
queryBuilder_1.andWhere('discount.status = :status', {
|
|
431
|
+
status: (0, utils_1.getStatusBasic)((_l = filters_1[key].value) !== null && _l !== void 0 ? _l : ''),
|
|
432
|
+
});
|
|
433
|
+
}
|
|
434
|
+
else if (key === 'typeText') {
|
|
435
|
+
queryBuilder_1.andWhere('discount.type = :type', {
|
|
436
|
+
type: (0, utils_1.getSeverityNameDiscountType)((_m = filters_1[key].value) !== null && _m !== void 0 ? _m : ''),
|
|
437
|
+
});
|
|
438
|
+
}
|
|
439
|
+
else if (key === 'updated_by') {
|
|
440
|
+
var updatedByIds = filters_1[key].value.map(function (element) { return element.id; });
|
|
441
|
+
if (updatedByIds.length > 0) {
|
|
442
|
+
queryBuilder_1.andWhere('discount.updated_by IN (:...updatedByIds)', {
|
|
443
|
+
updatedByIds: updatedByIds,
|
|
444
|
+
});
|
|
445
|
+
}
|
|
446
|
+
}
|
|
447
|
+
else {
|
|
448
|
+
queryBuilder_1.andWhere("".concat(accessKey, " = :").concat(key), (_d = {},
|
|
449
|
+
_d[key] = value,
|
|
450
|
+
_d));
|
|
451
|
+
}
|
|
452
|
+
break;
|
|
453
|
+
case 'notContains':
|
|
454
|
+
queryBuilder_1.andWhere("".concat(accessKey, " NOT LIKE :").concat(key), (_e = {},
|
|
455
|
+
_e[key] = "%".concat(value, "%"),
|
|
456
|
+
_e));
|
|
457
|
+
break;
|
|
458
|
+
case 'notEquals':
|
|
459
|
+
queryBuilder_1.andWhere("".concat(accessKey, " != :").concat(key), (_f = {},
|
|
460
|
+
_f[key] = value,
|
|
461
|
+
_f));
|
|
462
|
+
break;
|
|
463
|
+
case 'dateIs':
|
|
464
|
+
queryBuilder_1.andWhere("".concat(key !== 'expiration' && key !== 'start'
|
|
465
|
+
? 'DATE(CONVERT_TZ('
|
|
466
|
+
: '', " ").concat(accessKey, " ").concat(key !== 'expiration' && key !== 'start'
|
|
467
|
+
? ", '+00:00', '".concat(timezone_1, "'))")
|
|
468
|
+
: '', " = :").concat(key), (_g = {},
|
|
469
|
+
_g[key] = value.split('T')[0],
|
|
470
|
+
_g));
|
|
471
|
+
break;
|
|
472
|
+
case 'dateIsNot':
|
|
473
|
+
queryBuilder_1.andWhere("".concat(key !== 'expiration' && key !== 'start'
|
|
474
|
+
? 'DATE(CONVERT_TZ('
|
|
475
|
+
: '', " ").concat(accessKey, " ").concat(key !== 'expiration' && key !== 'start'
|
|
476
|
+
? ", '+00:00', '".concat(timezone_1, "'))")
|
|
477
|
+
: '', " != :").concat(key), (_h = {},
|
|
478
|
+
_h[key] = value.split('T')[0],
|
|
479
|
+
_h));
|
|
480
|
+
break;
|
|
481
|
+
case 'dateBefore':
|
|
482
|
+
queryBuilder_1.andWhere("".concat(key !== 'expiration' && key !== 'start'
|
|
483
|
+
? 'DATE(CONVERT_TZ('
|
|
484
|
+
: '', " ").concat(accessKey, " ").concat(key !== 'expiration' && key !== 'start'
|
|
485
|
+
? ", '+00:00', '".concat(timezone_1, "'))")
|
|
486
|
+
: '', " < :").concat(key), (_j = {},
|
|
487
|
+
_j[key] = value.split('T')[0],
|
|
488
|
+
_j));
|
|
489
|
+
break;
|
|
490
|
+
case 'dateAfter':
|
|
491
|
+
queryBuilder_1.andWhere("".concat(key !== 'expiration' && key !== 'start'
|
|
492
|
+
? 'DATE(CONVERT_TZ('
|
|
493
|
+
: '', " ").concat(accessKey, " ").concat(key !== 'expiration' && key !== 'start'
|
|
494
|
+
? ", '+00:00', '".concat(timezone_1, "'))")
|
|
495
|
+
: '', " > :").concat(key), (_k = {},
|
|
496
|
+
_k[key] = value.split('T')[0],
|
|
497
|
+
_k));
|
|
498
|
+
break;
|
|
499
|
+
default:
|
|
500
|
+
break;
|
|
501
|
+
}
|
|
502
|
+
}
|
|
503
|
+
});
|
|
504
|
+
if (lazyEvent.sortField) {
|
|
505
|
+
order = lazyEvent.sortOrder === 1 ? 'ASC' : 'DESC';
|
|
506
|
+
queryBuilder_1.orderBy("discount.".concat(lazyEvent.sortField), order);
|
|
507
|
+
}
|
|
508
|
+
return [4 /*yield*/, queryBuilder_1.getManyAndCount()];
|
|
509
|
+
case 1:
|
|
510
|
+
_c = _d.sent(), discountsCodeCompany = _c[0], totalRecords = _c[1];
|
|
511
|
+
return [2 /*return*/, {
|
|
512
|
+
data: discountsCodeCompany,
|
|
513
|
+
totalRecords: totalRecords,
|
|
514
|
+
}];
|
|
515
|
+
case 2:
|
|
516
|
+
error_1 = _d.sent();
|
|
517
|
+
return [2 /*return*/, false];
|
|
518
|
+
case 3: return [2 /*return*/];
|
|
519
|
+
}
|
|
520
|
+
});
|
|
521
|
+
});
|
|
522
|
+
};
|
|
357
523
|
CustomRepository.prototype.anyOtherRepository = function (args) {
|
|
358
524
|
return __awaiter(this, void 0, void 0, function () {
|
|
359
525
|
return __generator(this, function (_a) {
|
package/package.json
CHANGED
package/src/CustomRepository.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { DataSource, EntityTarget, Repository, ObjectLiteral } from 'typeorm'
|
|
2
2
|
import {
|
|
3
|
+
IBasicLazyEvent,
|
|
3
4
|
IPropsDiscountUserOrCompany,
|
|
4
5
|
IPropsQueryVerifyLocal,
|
|
5
6
|
} from './interfaces'
|
|
@@ -171,7 +172,7 @@ export class CustomRepository<T extends ObjectLiteral> extends Repository<T> {
|
|
|
171
172
|
if (lazyEvent.filters['global'] && lazyEvent.filters['global'].value) {
|
|
172
173
|
const globalValue = `%${lazyEvent.filters['global'].value.toLowerCase()}%`
|
|
173
174
|
queryBuilder.andWhere(
|
|
174
|
-
'LOWER(
|
|
175
|
+
'LOWER(discount_code_user.local_name) LIKE :globalValue OR LOWER(partner_surname) LIKE :globalValue OR LOWER(discount_code_user.code) LIKE :globalValue OR LOWER(discount_code_user.discount) LIKE :globalValue OR LOWER(partner_name) LIKE :globalValue',
|
|
175
176
|
{
|
|
176
177
|
globalValue:
|
|
177
178
|
globalValue ||
|
|
@@ -389,6 +390,212 @@ export class CustomRepository<T extends ObjectLiteral> extends Repository<T> {
|
|
|
389
390
|
}
|
|
390
391
|
}
|
|
391
392
|
|
|
393
|
+
async getDiscountsCodeCompany({
|
|
394
|
+
lazyEvent,
|
|
395
|
+
}: IBasicLazyEvent) {
|
|
396
|
+
try {
|
|
397
|
+
const timezone = getTimezoneOffset(getTimeZone())
|
|
398
|
+
|
|
399
|
+
const queryBuilder = this.createQueryBuilder(
|
|
400
|
+
'discount'
|
|
401
|
+
)
|
|
402
|
+
.leftJoinAndSelect('discount.updated_by', 'master')
|
|
403
|
+
.skip(lazyEvent.first)
|
|
404
|
+
.take(lazyEvent.rows)
|
|
405
|
+
|
|
406
|
+
if (lazyEvent.filters['global'] && lazyEvent.filters['global'].value) {
|
|
407
|
+
const globalValue = `%${lazyEvent.filters['global'].value.toLowerCase()}%`
|
|
408
|
+
queryBuilder.andWhere(
|
|
409
|
+
'LOWER(discount.code) LIKE :globalValue OR LOWER(discount.discount) LIKE :globalValue OR LOWER(discount.use_limit) LIKE :globalValue OR LOWER(discount.repeat_days) LIKE :globalValue OR LOWER(discount.updated) LIKE :globalValue OR LOWER(discount.start) LIKE :globalValue OR LOWER(discount.created) LIKE :globalValue OR LOWER(discount.expiration) LIKE :globalValue OR LOWER(master.name) LIKE :globalValue OR LOWER(master.surname) LIKE :globalValue',
|
|
410
|
+
{
|
|
411
|
+
globalValue:
|
|
412
|
+
globalValue ||
|
|
413
|
+
getStatusBasic(lazyEvent.filters['global'].value.toLowerCase()) ||
|
|
414
|
+
getSeverityNameDiscountType(
|
|
415
|
+
lazyEvent.filters['global'].value.toLowerCase()
|
|
416
|
+
),
|
|
417
|
+
}
|
|
418
|
+
)
|
|
419
|
+
}
|
|
420
|
+
|
|
421
|
+
const filters = lazyEvent.filters
|
|
422
|
+
Object.keys(filters).forEach((key) => {
|
|
423
|
+
let value = filters[key].value
|
|
424
|
+
if (
|
|
425
|
+
(Array.isArray(value) && value.length > 0) ||
|
|
426
|
+
(!Array.isArray(value) && value && key !== 'global')
|
|
427
|
+
) {
|
|
428
|
+
const matchMode = filters[key].matchMode
|
|
429
|
+
if (!Array.isArray(value) && value) {
|
|
430
|
+
value = filters[key].value.toLowerCase()
|
|
431
|
+
}
|
|
432
|
+
const accessKey =
|
|
433
|
+
key.split('.').length > 1 ? `${key}` : `discount.${key}`
|
|
434
|
+
|
|
435
|
+
switch (matchMode) {
|
|
436
|
+
case 'custom':
|
|
437
|
+
if (
|
|
438
|
+
(key === 'number_of_times_used' || key === 'use_limit') &&
|
|
439
|
+
matchMode === 'custom'
|
|
440
|
+
) {
|
|
441
|
+
const [from, to] = value || [null, null]
|
|
442
|
+
|
|
443
|
+
if (from !== null && to === null) {
|
|
444
|
+
queryBuilder.andWhere(`discount.${key} >= :from`, {
|
|
445
|
+
from,
|
|
446
|
+
})
|
|
447
|
+
} else if (from === null && to !== null) {
|
|
448
|
+
queryBuilder.andWhere(`discount.${key} <= :to`, {
|
|
449
|
+
to,
|
|
450
|
+
})
|
|
451
|
+
} else if (from !== null && to !== null) {
|
|
452
|
+
queryBuilder.andWhere(`discount.${key} BETWEEN :from AND :to`, {
|
|
453
|
+
from,
|
|
454
|
+
to,
|
|
455
|
+
})
|
|
456
|
+
}
|
|
457
|
+
}
|
|
458
|
+
break
|
|
459
|
+
case 'contains':
|
|
460
|
+
queryBuilder.andWhere(`${accessKey} LIKE :${key}`, {
|
|
461
|
+
[key]: `%${value}%`,
|
|
462
|
+
})
|
|
463
|
+
break
|
|
464
|
+
case 'startsWith':
|
|
465
|
+
queryBuilder.andWhere(`${accessKey} LIKE :${key}`, {
|
|
466
|
+
[key]: `${value}%`,
|
|
467
|
+
})
|
|
468
|
+
break
|
|
469
|
+
case 'endsWith':
|
|
470
|
+
queryBuilder.andWhere(`${accessKey} LIKE :${key}`, {
|
|
471
|
+
[key]: `%${value}`,
|
|
472
|
+
})
|
|
473
|
+
break
|
|
474
|
+
case 'equals':
|
|
475
|
+
if (key === 'status') {
|
|
476
|
+
queryBuilder.andWhere('discount.status = :status', {
|
|
477
|
+
status: getStatusBasic(filters[key].value ?? ''),
|
|
478
|
+
})
|
|
479
|
+
} else if (key === 'typeText') {
|
|
480
|
+
queryBuilder.andWhere('discount.type = :type', {
|
|
481
|
+
type: getSeverityNameDiscountType(filters[key].value ?? ''),
|
|
482
|
+
})
|
|
483
|
+
} else if (key === 'updated_by') {
|
|
484
|
+
const updatedByIds = filters[key].value.map(
|
|
485
|
+
(element: Partner) => element.id
|
|
486
|
+
)
|
|
487
|
+
|
|
488
|
+
if (updatedByIds.length > 0) {
|
|
489
|
+
queryBuilder.andWhere(
|
|
490
|
+
'discount.updated_by IN (:...updatedByIds)',
|
|
491
|
+
{
|
|
492
|
+
updatedByIds,
|
|
493
|
+
}
|
|
494
|
+
)
|
|
495
|
+
}
|
|
496
|
+
} else {
|
|
497
|
+
queryBuilder.andWhere(`${accessKey} = :${key}`, {
|
|
498
|
+
[key]: value,
|
|
499
|
+
})
|
|
500
|
+
}
|
|
501
|
+
break
|
|
502
|
+
case 'notContains':
|
|
503
|
+
queryBuilder.andWhere(`${accessKey} NOT LIKE :${key}`, {
|
|
504
|
+
[key]: `%${value}%`,
|
|
505
|
+
})
|
|
506
|
+
break
|
|
507
|
+
case 'notEquals':
|
|
508
|
+
queryBuilder.andWhere(`${accessKey} != :${key}`, {
|
|
509
|
+
[key]: value,
|
|
510
|
+
})
|
|
511
|
+
break
|
|
512
|
+
case 'dateIs':
|
|
513
|
+
queryBuilder.andWhere(
|
|
514
|
+
`${
|
|
515
|
+
key !== 'expiration' && key !== 'start'
|
|
516
|
+
? 'DATE(CONVERT_TZ('
|
|
517
|
+
: ''
|
|
518
|
+
} ${accessKey} ${
|
|
519
|
+
key !== 'expiration' && key !== 'start'
|
|
520
|
+
? `, '+00:00', '${timezone}'))`
|
|
521
|
+
: ''
|
|
522
|
+
} = :${key}`,
|
|
523
|
+
{
|
|
524
|
+
[key]: value.split('T')[0],
|
|
525
|
+
}
|
|
526
|
+
)
|
|
527
|
+
break
|
|
528
|
+
case 'dateIsNot':
|
|
529
|
+
queryBuilder.andWhere(
|
|
530
|
+
`${
|
|
531
|
+
key !== 'expiration' && key !== 'start'
|
|
532
|
+
? 'DATE(CONVERT_TZ('
|
|
533
|
+
: ''
|
|
534
|
+
} ${accessKey} ${
|
|
535
|
+
key !== 'expiration' && key !== 'start'
|
|
536
|
+
? `, '+00:00', '${timezone}'))`
|
|
537
|
+
: ''
|
|
538
|
+
} != :${key}`,
|
|
539
|
+
{
|
|
540
|
+
[key]: value.split('T')[0],
|
|
541
|
+
}
|
|
542
|
+
)
|
|
543
|
+
break
|
|
544
|
+
case 'dateBefore':
|
|
545
|
+
queryBuilder.andWhere(
|
|
546
|
+
`${
|
|
547
|
+
key !== 'expiration' && key !== 'start'
|
|
548
|
+
? 'DATE(CONVERT_TZ('
|
|
549
|
+
: ''
|
|
550
|
+
} ${accessKey} ${
|
|
551
|
+
key !== 'expiration' && key !== 'start'
|
|
552
|
+
? `, '+00:00', '${timezone}'))`
|
|
553
|
+
: ''
|
|
554
|
+
} < :${key}`,
|
|
555
|
+
{
|
|
556
|
+
[key]: value.split('T')[0],
|
|
557
|
+
}
|
|
558
|
+
)
|
|
559
|
+
break
|
|
560
|
+
case 'dateAfter':
|
|
561
|
+
queryBuilder.andWhere(
|
|
562
|
+
`${
|
|
563
|
+
key !== 'expiration' && key !== 'start'
|
|
564
|
+
? 'DATE(CONVERT_TZ('
|
|
565
|
+
: ''
|
|
566
|
+
} ${accessKey} ${
|
|
567
|
+
key !== 'expiration' && key !== 'start'
|
|
568
|
+
? `, '+00:00', '${timezone}'))`
|
|
569
|
+
: ''
|
|
570
|
+
} > :${key}`,
|
|
571
|
+
{
|
|
572
|
+
[key]: value.split('T')[0],
|
|
573
|
+
}
|
|
574
|
+
)
|
|
575
|
+
break
|
|
576
|
+
default:
|
|
577
|
+
break
|
|
578
|
+
}
|
|
579
|
+
}
|
|
580
|
+
})
|
|
581
|
+
|
|
582
|
+
if (lazyEvent.sortField) {
|
|
583
|
+
const order = lazyEvent.sortOrder === 1 ? 'ASC' : 'DESC'
|
|
584
|
+
queryBuilder.orderBy(`discount.${lazyEvent.sortField}`, order)
|
|
585
|
+
}
|
|
586
|
+
|
|
587
|
+
const [discountsCodeCompany, totalRecords] =
|
|
588
|
+
await queryBuilder.getManyAndCount()
|
|
589
|
+
|
|
590
|
+
return {
|
|
591
|
+
data: discountsCodeCompany,
|
|
592
|
+
totalRecords,
|
|
593
|
+
}
|
|
594
|
+
} catch (error) {
|
|
595
|
+
return false
|
|
596
|
+
}
|
|
597
|
+
}
|
|
598
|
+
|
|
392
599
|
async anyOtherRepository(args: any) {
|
|
393
600
|
// Implementa otro método personalizado aquí
|
|
394
601
|
}
|