test-entity-library-asm 2.2.2 → 2.2.4
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/entities/VerifyLocal.d.ts +1 -1
- package/dist/entities.views.routes.d.ts +1 -0
- package/dist/entities.views.routes.js +3 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.js +27 -1
- package/dist/repositories/VerifyLocalRepository.d.ts +11 -0
- package/dist/repositories/VerifyLocalRepository.js +148 -0
- package/package.json +1 -1
- package/src/entities/VerifyLocal.ts +1 -1
- package/src/entities.views.routes.ts +2 -0
- package/src/index.ts +23 -1
- package/src/repositories/VerifyLocalRepository.ts +104 -0
|
@@ -42,3 +42,4 @@ export { BusinessType } from './entities/BusinessType';
|
|
|
42
42
|
export { AuthenticationCredential } from './entities/AuthenticationCredential';
|
|
43
43
|
export { PosSystem } from './entities/PosSystem';
|
|
44
44
|
export { VerifyLocal } from './entities/VerifyLocal';
|
|
45
|
+
export { VerifyLocalRepository } from './repositories/VerifyLocalRepository';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.VerifyLocal = exports.PosSystem = exports.AuthenticationCredential = exports.BusinessType = exports.LocalsCompany = exports.UserAddress = exports.User = exports.TypeMeasureIngredient = exports.TerminalSession = exports.Terminal = exports.Square = exports.RequestStatus = exports.RequestProductGroupComplement = exports.RequestProduct = exports.Request = exports.Region = exports.ProductTopping = exports.ProductIngredient = exports.ProductGroupComplement = exports.ProductGroup = exports.Product = exports.Plan = exports.PaymentMethod = exports.PartnerRole = exports.PartnerPermission = exports.PartnerNotification = exports.Partner = exports.MasterRole = exports.MasterPermission = exports.Master = exports.LocalQualification = exports.Local = exports.DiscountCodeUser = exports.DiscountCodeCompany = exports.Day = exports.Country = exports.Configuration = exports.Company = exports.CodeRedemptionHistoryUser = exports.CodeRedemptionHistoryCompany = exports.City = exports.ScheduleCategory = exports.Category = exports.BusinessTypeProduct = void 0;
|
|
3
|
+
exports.VerifyLocalRepository = exports.VerifyLocal = exports.PosSystem = exports.AuthenticationCredential = exports.BusinessType = exports.LocalsCompany = exports.UserAddress = exports.User = exports.TypeMeasureIngredient = exports.TerminalSession = exports.Terminal = exports.Square = exports.RequestStatus = exports.RequestProductGroupComplement = exports.RequestProduct = exports.Request = exports.Region = exports.ProductTopping = exports.ProductIngredient = exports.ProductGroupComplement = exports.ProductGroup = exports.Product = exports.Plan = exports.PaymentMethod = exports.PartnerRole = exports.PartnerPermission = exports.PartnerNotification = exports.Partner = exports.MasterRole = exports.MasterPermission = exports.Master = exports.LocalQualification = exports.Local = exports.DiscountCodeUser = exports.DiscountCodeCompany = exports.Day = exports.Country = exports.Configuration = exports.Company = exports.CodeRedemptionHistoryUser = exports.CodeRedemptionHistoryCompany = exports.City = exports.ScheduleCategory = exports.Category = exports.BusinessTypeProduct = void 0;
|
|
4
4
|
var BusinessTypeProduct_1 = require("./entities/BusinessTypeProduct");
|
|
5
5
|
Object.defineProperty(exports, "BusinessTypeProduct", { enumerable: true, get: function () { return BusinessTypeProduct_1.BusinessTypeProduct; } });
|
|
6
6
|
var Category_1 = require("./entities/Category");
|
|
@@ -89,3 +89,5 @@ var PosSystem_1 = require("./entities/PosSystem");
|
|
|
89
89
|
Object.defineProperty(exports, "PosSystem", { enumerable: true, get: function () { return PosSystem_1.PosSystem; } });
|
|
90
90
|
var VerifyLocal_1 = require("./entities/VerifyLocal");
|
|
91
91
|
Object.defineProperty(exports, "VerifyLocal", { enumerable: true, get: function () { return VerifyLocal_1.VerifyLocal; } });
|
|
92
|
+
var VerifyLocalRepository_1 = require("./repositories/VerifyLocalRepository");
|
|
93
|
+
Object.defineProperty(exports, "VerifyLocalRepository", { enumerable: true, get: function () { return VerifyLocalRepository_1.VerifyLocalRepository; } });
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { NextFunction, Request, Response } from 'express';
|
|
2
2
|
import { DataSource, EntityTarget, ObjectLiteral, Repository } from 'typeorm';
|
|
3
|
+
import { VerifyLocalRepository } from '.';
|
|
3
4
|
export * from './entities.views.routes';
|
|
4
5
|
export declare function createDataBaseSource(): DataSource;
|
|
5
6
|
export declare function showEntityNameEntity<T extends ObjectLiteral>(entity: EntityTarget<T>): Promise<Repository<T>>;
|
|
@@ -7,3 +8,4 @@ export declare function showEntity(entityName: string): Promise<any>;
|
|
|
7
8
|
export declare function callStoredProcedure(storedProcedure: any, elements: any): Promise<any>;
|
|
8
9
|
export declare function timezoneMiddleware(req: Request, res: Response, next: NextFunction): void;
|
|
9
10
|
export declare function getTimeZone(): string;
|
|
11
|
+
export declare function getRepositoryByName(repositoryName: string): Promise<VerifyLocalRepository | null>;
|
package/dist/index.js
CHANGED
|
@@ -50,11 +50,12 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
50
50
|
}
|
|
51
51
|
};
|
|
52
52
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
53
|
-
exports.getTimeZone = exports.timezoneMiddleware = exports.callStoredProcedure = exports.showEntity = exports.showEntityNameEntity = exports.createDataBaseSource = void 0;
|
|
53
|
+
exports.getRepositoryByName = exports.getTimeZone = exports.timezoneMiddleware = exports.callStoredProcedure = exports.showEntity = exports.showEntityNameEntity = exports.createDataBaseSource = void 0;
|
|
54
54
|
var async_hooks_1 = require("async_hooks");
|
|
55
55
|
var dotenv_1 = require("dotenv");
|
|
56
56
|
var path_1 = require("path");
|
|
57
57
|
var typeorm_1 = require("typeorm");
|
|
58
|
+
var _1 = require(".");
|
|
58
59
|
__exportStar(require("./entities.views.routes"), exports);
|
|
59
60
|
var asyncLocalStorage = new async_hooks_1.AsyncLocalStorage();
|
|
60
61
|
var connection = null;
|
|
@@ -170,3 +171,28 @@ function getTimeZone() {
|
|
|
170
171
|
return (_a = store === null || store === void 0 ? void 0 : store.get('timezone')) !== null && _a !== void 0 ? _a : 'UTC';
|
|
171
172
|
}
|
|
172
173
|
exports.getTimeZone = getTimeZone;
|
|
174
|
+
// Función para obtener repositorios personalizados
|
|
175
|
+
function getRepositoryByName(repositoryName) {
|
|
176
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
177
|
+
return __generator(this, function (_a) {
|
|
178
|
+
switch (_a.label) {
|
|
179
|
+
case 0:
|
|
180
|
+
if (!!connection) return [3 /*break*/, 2];
|
|
181
|
+
connection = createDataBaseSource();
|
|
182
|
+
return [4 /*yield*/, connection.initialize()];
|
|
183
|
+
case 1:
|
|
184
|
+
_a.sent();
|
|
185
|
+
_a.label = 2;
|
|
186
|
+
case 2:
|
|
187
|
+
switch (repositoryName) {
|
|
188
|
+
case 'VerifyLocalRepository':
|
|
189
|
+
return [2 /*return*/, (0, typeorm_1.getCustomRepository)(_1.VerifyLocalRepository)];
|
|
190
|
+
default:
|
|
191
|
+
return [2 /*return*/, null];
|
|
192
|
+
}
|
|
193
|
+
return [2 /*return*/];
|
|
194
|
+
}
|
|
195
|
+
});
|
|
196
|
+
});
|
|
197
|
+
}
|
|
198
|
+
exports.getRepositoryByName = getRepositoryByName;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Repository } from 'typeorm';
|
|
2
|
+
import { VerifyLocal } from '../entities/VerifyLocal';
|
|
3
|
+
export declare class VerifyLocalRepository extends Repository<VerifyLocal> {
|
|
4
|
+
getVerifyLocals(status: number | null, page: number, pageSize: number, filters: any): Promise<{
|
|
5
|
+
data: VerifyLocal[];
|
|
6
|
+
total: number;
|
|
7
|
+
page: number;
|
|
8
|
+
pageSize: number;
|
|
9
|
+
totalPages: number;
|
|
10
|
+
}>;
|
|
11
|
+
}
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __extends = (this && this.__extends) || (function () {
|
|
3
|
+
var extendStatics = function (d, b) {
|
|
4
|
+
extendStatics = Object.setPrototypeOf ||
|
|
5
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
+
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
7
|
+
return extendStatics(d, b);
|
|
8
|
+
};
|
|
9
|
+
return function (d, b) {
|
|
10
|
+
if (typeof b !== "function" && b !== null)
|
|
11
|
+
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
12
|
+
extendStatics(d, b);
|
|
13
|
+
function __() { this.constructor = d; }
|
|
14
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
15
|
+
};
|
|
16
|
+
})();
|
|
17
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
18
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
19
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
20
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
21
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
22
|
+
};
|
|
23
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
24
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
25
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
26
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
27
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
28
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
29
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
30
|
+
});
|
|
31
|
+
};
|
|
32
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
33
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
34
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
35
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
36
|
+
function step(op) {
|
|
37
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
38
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
39
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
40
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
41
|
+
switch (op[0]) {
|
|
42
|
+
case 0: case 1: t = op; break;
|
|
43
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
44
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
45
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
46
|
+
default:
|
|
47
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
48
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
49
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
50
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
51
|
+
if (t[2]) _.ops.pop();
|
|
52
|
+
_.trys.pop(); continue;
|
|
53
|
+
}
|
|
54
|
+
op = body.call(thisArg, _);
|
|
55
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
56
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
57
|
+
}
|
|
58
|
+
};
|
|
59
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
60
|
+
exports.VerifyLocalRepository = void 0;
|
|
61
|
+
var typeorm_1 = require("typeorm");
|
|
62
|
+
var VerifyLocal_1 = require("../entities/VerifyLocal");
|
|
63
|
+
var VerifyLocalRepository = /** @class */ (function (_super) {
|
|
64
|
+
__extends(VerifyLocalRepository, _super);
|
|
65
|
+
function VerifyLocalRepository() {
|
|
66
|
+
return _super !== null && _super.apply(this, arguments) || this;
|
|
67
|
+
}
|
|
68
|
+
VerifyLocalRepository.prototype.getVerifyLocals = function (status, page, pageSize, filters) {
|
|
69
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
70
|
+
var queryBuilder, globalValue, _a, data, total;
|
|
71
|
+
return __generator(this, function (_b) {
|
|
72
|
+
switch (_b.label) {
|
|
73
|
+
case 0:
|
|
74
|
+
queryBuilder = this.createQueryBuilder('verifyLocal')
|
|
75
|
+
.skip((page - 1) * pageSize)
|
|
76
|
+
.take(pageSize);
|
|
77
|
+
// Filtro por estado si está definido
|
|
78
|
+
if (status !== null && status >= 0) {
|
|
79
|
+
queryBuilder.andWhere('verifyLocal.status = :status', { status: status });
|
|
80
|
+
}
|
|
81
|
+
// Filtro global que busca en múltiples campos
|
|
82
|
+
if (filters['global'] && filters['global'].value) {
|
|
83
|
+
globalValue = "%".concat(filters['global'].value, "%");
|
|
84
|
+
queryBuilder.andWhere('(JSON_EXTRACT(verifyLocal.local_information, "$.name") LIKE :globalValue ' +
|
|
85
|
+
'OR JSON_EXTRACT(verifyLocal.local_information, "$.square.address") LIKE :globalValue ' +
|
|
86
|
+
'OR JSON_EXTRACT(verifyLocal.local_information, "$.address.formatted_address") LIKE :globalValue ' +
|
|
87
|
+
'OR verifyLocal.status LIKE :globalValue)', { globalValue: globalValue });
|
|
88
|
+
}
|
|
89
|
+
// Filtros específicos de columnas
|
|
90
|
+
Object.keys(filters).forEach(function (key) {
|
|
91
|
+
var _a, _b, _c, _d;
|
|
92
|
+
if (key !== 'global' && filters[key].constraints) {
|
|
93
|
+
var filter = filters[key];
|
|
94
|
+
var value = filter.constraints[0].value;
|
|
95
|
+
var matchMode = filter.constraints[0].matchMode;
|
|
96
|
+
if (value !== null) {
|
|
97
|
+
var jsonPath = key
|
|
98
|
+
.split('.')
|
|
99
|
+
.map(function (segment) { return "$.".concat(segment); })
|
|
100
|
+
.join('');
|
|
101
|
+
switch (matchMode) {
|
|
102
|
+
case 'startsWith':
|
|
103
|
+
queryBuilder.andWhere("JSON_EXTRACT(verifyLocal.".concat(key.split('.')[0], ", \"").concat(jsonPath, "\") LIKE :").concat(key), (_a = {},
|
|
104
|
+
_a[key] = "".concat(value, "%"),
|
|
105
|
+
_a));
|
|
106
|
+
break;
|
|
107
|
+
case 'contains':
|
|
108
|
+
queryBuilder.andWhere("JSON_EXTRACT(verifyLocal.".concat(key.split('.')[0], ", \"").concat(jsonPath, "\") LIKE :").concat(key), (_b = {},
|
|
109
|
+
_b[key] = "%".concat(value, "%"),
|
|
110
|
+
_b));
|
|
111
|
+
break;
|
|
112
|
+
case 'equals':
|
|
113
|
+
queryBuilder.andWhere("JSON_EXTRACT(verifyLocal.".concat(key.split('.')[0], ", \"").concat(jsonPath, "\") = :").concat(key), (_c = {},
|
|
114
|
+
_c[key] = value,
|
|
115
|
+
_c));
|
|
116
|
+
break;
|
|
117
|
+
case 'dateIs':
|
|
118
|
+
queryBuilder.andWhere("DATE(JSON_EXTRACT(verifyLocal.".concat(key.split('.')[0], ", \"").concat(jsonPath, "\")) = :").concat(key), (_d = {},
|
|
119
|
+
_d[key] = value,
|
|
120
|
+
_d));
|
|
121
|
+
break;
|
|
122
|
+
// Agregar otros modos de coincidencia según sea necesario
|
|
123
|
+
default:
|
|
124
|
+
break;
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
});
|
|
129
|
+
return [4 /*yield*/, queryBuilder.getManyAndCount()];
|
|
130
|
+
case 1:
|
|
131
|
+
_a = _b.sent(), data = _a[0], total = _a[1];
|
|
132
|
+
return [2 /*return*/, {
|
|
133
|
+
data: data,
|
|
134
|
+
total: total,
|
|
135
|
+
page: page,
|
|
136
|
+
pageSize: pageSize,
|
|
137
|
+
totalPages: Math.ceil(total / pageSize),
|
|
138
|
+
}];
|
|
139
|
+
}
|
|
140
|
+
});
|
|
141
|
+
});
|
|
142
|
+
};
|
|
143
|
+
VerifyLocalRepository = __decorate([
|
|
144
|
+
(0, typeorm_1.EntityRepository)(VerifyLocal_1.VerifyLocal)
|
|
145
|
+
], VerifyLocalRepository);
|
|
146
|
+
return VerifyLocalRepository;
|
|
147
|
+
}(typeorm_1.Repository));
|
|
148
|
+
exports.VerifyLocalRepository = VerifyLocalRepository;
|
package/package.json
CHANGED
|
@@ -42,3 +42,5 @@ export { BusinessType } from './entities/BusinessType'
|
|
|
42
42
|
export { AuthenticationCredential } from './entities/AuthenticationCredential'
|
|
43
43
|
export { PosSystem } from './entities/PosSystem'
|
|
44
44
|
export { VerifyLocal } from './entities/VerifyLocal'
|
|
45
|
+
|
|
46
|
+
export { VerifyLocalRepository } from './repositories/VerifyLocalRepository'
|
package/src/index.ts
CHANGED
|
@@ -2,8 +2,15 @@ import { AsyncLocalStorage } from 'async_hooks'
|
|
|
2
2
|
import { config } from 'dotenv'
|
|
3
3
|
import { NextFunction, Request, Response } from 'express'
|
|
4
4
|
import { resolve } from 'path'
|
|
5
|
-
import {
|
|
5
|
+
import {
|
|
6
|
+
DataSource,
|
|
7
|
+
EntityTarget,
|
|
8
|
+
getCustomRepository,
|
|
9
|
+
ObjectLiteral,
|
|
10
|
+
Repository,
|
|
11
|
+
} from 'typeorm'
|
|
6
12
|
import { IType } from './interfaces'
|
|
13
|
+
import { VerifyLocalRepository } from '.'
|
|
7
14
|
export * from './entities.views.routes'
|
|
8
15
|
|
|
9
16
|
const asyncLocalStorage = new AsyncLocalStorage<Map<string, string>>()
|
|
@@ -104,3 +111,18 @@ export function getTimeZone(): string {
|
|
|
104
111
|
const store = asyncLocalStorage.getStore()
|
|
105
112
|
return store?.get('timezone') ?? 'UTC'
|
|
106
113
|
}
|
|
114
|
+
|
|
115
|
+
// Función para obtener repositorios personalizados
|
|
116
|
+
export async function getRepositoryByName(repositoryName: string) {
|
|
117
|
+
if (!connection) {
|
|
118
|
+
connection = createDataBaseSource()
|
|
119
|
+
await connection.initialize()
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
switch (repositoryName) {
|
|
123
|
+
case 'VerifyLocalRepository':
|
|
124
|
+
return getCustomRepository(VerifyLocalRepository)
|
|
125
|
+
default:
|
|
126
|
+
return null
|
|
127
|
+
}
|
|
128
|
+
}
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import { EntityRepository, Repository } from 'typeorm'
|
|
2
|
+
import { VerifyLocal } from '../entities/VerifyLocal'
|
|
3
|
+
|
|
4
|
+
@EntityRepository(VerifyLocal)
|
|
5
|
+
export class VerifyLocalRepository extends Repository<VerifyLocal> {
|
|
6
|
+
async getVerifyLocals(
|
|
7
|
+
status: number | null,
|
|
8
|
+
page: number,
|
|
9
|
+
pageSize: number,
|
|
10
|
+
filters: any
|
|
11
|
+
) {
|
|
12
|
+
const queryBuilder = this.createQueryBuilder('verifyLocal')
|
|
13
|
+
.skip((page - 1) * pageSize)
|
|
14
|
+
.take(pageSize)
|
|
15
|
+
|
|
16
|
+
// Filtro por estado si está definido
|
|
17
|
+
if (status !== null && status >= 0) {
|
|
18
|
+
queryBuilder.andWhere('verifyLocal.status = :status', { status })
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
// Filtro global que busca en múltiples campos
|
|
22
|
+
if (filters['global'] && filters['global'].value) {
|
|
23
|
+
const globalValue = `%${filters['global'].value}%`
|
|
24
|
+
queryBuilder.andWhere(
|
|
25
|
+
'(JSON_EXTRACT(verifyLocal.local_information, "$.name") LIKE :globalValue ' +
|
|
26
|
+
'OR JSON_EXTRACT(verifyLocal.local_information, "$.square.address") LIKE :globalValue ' +
|
|
27
|
+
'OR JSON_EXTRACT(verifyLocal.local_information, "$.address.formatted_address") LIKE :globalValue ' +
|
|
28
|
+
'OR verifyLocal.status LIKE :globalValue)',
|
|
29
|
+
{ globalValue }
|
|
30
|
+
)
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
// Filtros específicos de columnas
|
|
34
|
+
Object.keys(filters).forEach((key) => {
|
|
35
|
+
if (key !== 'global' && filters[key].constraints) {
|
|
36
|
+
const filter = filters[key]
|
|
37
|
+
const value = filter.constraints[0].value
|
|
38
|
+
const matchMode = filter.constraints[0].matchMode
|
|
39
|
+
|
|
40
|
+
if (value !== null) {
|
|
41
|
+
const jsonPath = key
|
|
42
|
+
.split('.')
|
|
43
|
+
.map((segment) => `$.${segment}`)
|
|
44
|
+
.join('')
|
|
45
|
+
switch (matchMode) {
|
|
46
|
+
case 'startsWith':
|
|
47
|
+
queryBuilder.andWhere(
|
|
48
|
+
`JSON_EXTRACT(verifyLocal.${
|
|
49
|
+
key.split('.')[0]
|
|
50
|
+
}, "${jsonPath}") LIKE :${key}`,
|
|
51
|
+
{
|
|
52
|
+
[key]: `${value}%`,
|
|
53
|
+
}
|
|
54
|
+
)
|
|
55
|
+
break
|
|
56
|
+
case 'contains':
|
|
57
|
+
queryBuilder.andWhere(
|
|
58
|
+
`JSON_EXTRACT(verifyLocal.${
|
|
59
|
+
key.split('.')[0]
|
|
60
|
+
}, "${jsonPath}") LIKE :${key}`,
|
|
61
|
+
{
|
|
62
|
+
[key]: `%${value}%`,
|
|
63
|
+
}
|
|
64
|
+
)
|
|
65
|
+
break
|
|
66
|
+
case 'equals':
|
|
67
|
+
queryBuilder.andWhere(
|
|
68
|
+
`JSON_EXTRACT(verifyLocal.${
|
|
69
|
+
key.split('.')[0]
|
|
70
|
+
}, "${jsonPath}") = :${key}`,
|
|
71
|
+
{
|
|
72
|
+
[key]: value,
|
|
73
|
+
}
|
|
74
|
+
)
|
|
75
|
+
break
|
|
76
|
+
case 'dateIs':
|
|
77
|
+
queryBuilder.andWhere(
|
|
78
|
+
`DATE(JSON_EXTRACT(verifyLocal.${
|
|
79
|
+
key.split('.')[0]
|
|
80
|
+
}, "${jsonPath}")) = :${key}`,
|
|
81
|
+
{
|
|
82
|
+
[key]: value,
|
|
83
|
+
}
|
|
84
|
+
)
|
|
85
|
+
break
|
|
86
|
+
// Agregar otros modos de coincidencia según sea necesario
|
|
87
|
+
default:
|
|
88
|
+
break
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
})
|
|
93
|
+
|
|
94
|
+
const [data, total] = await queryBuilder.getManyAndCount()
|
|
95
|
+
|
|
96
|
+
return {
|
|
97
|
+
data,
|
|
98
|
+
total,
|
|
99
|
+
page,
|
|
100
|
+
pageSize,
|
|
101
|
+
totalPages: Math.ceil(total / pageSize),
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
}
|