update
This commit is contained in:
@ -70,19 +70,38 @@ export class AdministrativuController {
|
|||||||
|
|
||||||
const offset = (param.page - 1) * param.limit
|
const offset = (param.page - 1) * param.limit
|
||||||
|
|
||||||
|
const filterObj = param.filter ? JSON.parse(param.filter) : {};
|
||||||
|
// Remove foreign key from filter for CommonHelper.handleFilter
|
||||||
|
const filterWithoutFK = { ...filterObj };
|
||||||
|
delete filterWithoutFK.munisipo_id;
|
||||||
|
const filterStrWithoutFK = JSON.stringify(filterWithoutFK);
|
||||||
|
|
||||||
const { whereAttr, whereVal } = CommonHelper.handleFilter({
|
const { whereAttr, whereVal } = CommonHelper.handleFilter({
|
||||||
filter: param.filter,
|
filter: filterStrWithoutFK,
|
||||||
col_any_eq: ['code'],
|
col_any_eq: ['code'],
|
||||||
col_any_like: ['name']
|
col_any_like: ['name']
|
||||||
});
|
});
|
||||||
|
|
||||||
const res_count = repo.createQueryBuilder("Administrativu")
|
const res_count = repo.createQueryBuilder("Administrativu")
|
||||||
.where(whereAttr, whereVal);
|
.leftJoin("Administrativu.munisipo", "munisipo")
|
||||||
|
.where(whereAttr || "1=1", whereVal);
|
||||||
|
|
||||||
|
// Handle foreign key filter with relation
|
||||||
|
if (filterObj.munisipo_id) {
|
||||||
|
res_count.andWhere("munisipo.id = :munisipoId", { munisipoId: filterObj.munisipo_id });
|
||||||
|
}
|
||||||
|
|
||||||
const res_list = repo.createQueryBuilder("Administrativu")
|
const res_list = repo.createQueryBuilder("Administrativu")
|
||||||
.where(whereAttr, whereVal)
|
.leftJoin("Administrativu.munisipo", "munisipo")
|
||||||
|
.where(whereAttr || "1=1", whereVal)
|
||||||
.orderBy("Administrativu." + param.order_field, param.order_direction)
|
.orderBy("Administrativu." + param.order_field, param.order_direction)
|
||||||
.offset(offset)
|
.offset(offset)
|
||||||
.limit(param.limit);
|
.limit(param.limit);
|
||||||
|
|
||||||
|
// Handle foreign key filter with relation
|
||||||
|
if (filterObj.munisipo_id) {
|
||||||
|
res_list.andWhere("munisipo.id = :munisipoId", { munisipoId: filterObj.munisipo_id });
|
||||||
|
}
|
||||||
|
|
||||||
if (param.with_deleted) {
|
if (param.with_deleted) {
|
||||||
res_count.withDeleted();
|
res_count.withDeleted();
|
||||||
@ -143,8 +162,14 @@ export class AdministrativuController {
|
|||||||
|
|
||||||
const repo = OrmHelper.DB.getRepository(Administrativu);
|
const repo = OrmHelper.DB.getRepository(Administrativu);
|
||||||
|
|
||||||
|
const filterObj = param.filter ? JSON.parse(param.filter) : {};
|
||||||
|
// Remove foreign key from filter for CommonHelper.handleFilter
|
||||||
|
const filterWithoutFK = { ...filterObj };
|
||||||
|
delete filterWithoutFK.munisipo_id;
|
||||||
|
const filterStrWithoutFK = JSON.stringify(filterWithoutFK);
|
||||||
|
|
||||||
const { whereAttr, whereVal } = CommonHelper.handleFilter({
|
const { whereAttr, whereVal } = CommonHelper.handleFilter({
|
||||||
filter: param.filter,
|
filter: filterStrWithoutFK,
|
||||||
col_any_eq: ['code'],
|
col_any_eq: ['code'],
|
||||||
col_any_like: ['name']
|
col_any_like: ['name']
|
||||||
});
|
});
|
||||||
@ -169,8 +194,16 @@ export class AdministrativuController {
|
|||||||
const fetchAndWrite = async (page: any) => {
|
const fetchAndWrite = async (page: any) => {
|
||||||
const offset = (page - 1) * limit
|
const offset = (page - 1) * limit
|
||||||
|
|
||||||
const data = await repo.createQueryBuilder("Administrativu")
|
let query = repo.createQueryBuilder("Administrativu")
|
||||||
.where(whereAttr, whereVal)
|
.leftJoin("Administrativu.munisipo", "munisipo")
|
||||||
|
.where(whereAttr || "1=1", whereVal);
|
||||||
|
|
||||||
|
// Handle foreign key filter with relation
|
||||||
|
if (filterObj.munisipo_id) {
|
||||||
|
query = query.andWhere("munisipo.id = :munisipoId", { munisipoId: filterObj.munisipo_id });
|
||||||
|
}
|
||||||
|
|
||||||
|
const data = await query
|
||||||
.select([
|
.select([
|
||||||
'Administrativu.id',
|
'Administrativu.id',
|
||||||
'Administrativu.code',
|
'Administrativu.code',
|
||||||
|
|||||||
@ -70,19 +70,38 @@ export class AldeiaController {
|
|||||||
|
|
||||||
const offset = (param.page - 1) * param.limit
|
const offset = (param.page - 1) * param.limit
|
||||||
|
|
||||||
|
const filterObj = param.filter ? JSON.parse(param.filter) : {};
|
||||||
|
// Remove foreign key from filter for CommonHelper.handleFilter
|
||||||
|
const filterWithoutFK = { ...filterObj };
|
||||||
|
delete filterWithoutFK.suco_id;
|
||||||
|
const filterStrWithoutFK = JSON.stringify(filterWithoutFK);
|
||||||
|
|
||||||
const { whereAttr, whereVal } = CommonHelper.handleFilter({
|
const { whereAttr, whereVal } = CommonHelper.handleFilter({
|
||||||
filter: param.filter,
|
filter: filterStrWithoutFK,
|
||||||
col_any_eq: ['code'],
|
col_any_eq: ['code'],
|
||||||
col_any_like: ['name']
|
col_any_like: ['name']
|
||||||
});
|
});
|
||||||
|
|
||||||
const res_count = repo.createQueryBuilder("Aldeia")
|
const res_count = repo.createQueryBuilder("Aldeia")
|
||||||
.where(whereAttr, whereVal);
|
.leftJoin("Aldeia.suco", "suco")
|
||||||
|
.where(whereAttr || "1=1", whereVal);
|
||||||
|
|
||||||
|
// Handle foreign key filter with relation
|
||||||
|
if (filterObj.suco_id) {
|
||||||
|
res_count.andWhere("suco.id = :sucoId", { sucoId: filterObj.suco_id });
|
||||||
|
}
|
||||||
|
|
||||||
const res_list = repo.createQueryBuilder("Aldeia")
|
const res_list = repo.createQueryBuilder("Aldeia")
|
||||||
.where(whereAttr, whereVal)
|
.leftJoin("Aldeia.suco", "suco")
|
||||||
|
.where(whereAttr || "1=1", whereVal)
|
||||||
.orderBy("Aldeia." + param.order_field, param.order_direction)
|
.orderBy("Aldeia." + param.order_field, param.order_direction)
|
||||||
.offset(offset)
|
.offset(offset)
|
||||||
.limit(param.limit);
|
.limit(param.limit);
|
||||||
|
|
||||||
|
// Handle foreign key filter with relation
|
||||||
|
if (filterObj.suco_id) {
|
||||||
|
res_list.andWhere("suco.id = :sucoId", { sucoId: filterObj.suco_id });
|
||||||
|
}
|
||||||
|
|
||||||
if (param.with_deleted) {
|
if (param.with_deleted) {
|
||||||
res_count.withDeleted();
|
res_count.withDeleted();
|
||||||
@ -143,8 +162,14 @@ export class AldeiaController {
|
|||||||
|
|
||||||
const repo = OrmHelper.DB.getRepository(Aldeia);
|
const repo = OrmHelper.DB.getRepository(Aldeia);
|
||||||
|
|
||||||
|
const filterObj = param.filter ? JSON.parse(param.filter) : {};
|
||||||
|
// Remove foreign key from filter for CommonHelper.handleFilter
|
||||||
|
const filterWithoutFK = { ...filterObj };
|
||||||
|
delete filterWithoutFK.suco_id;
|
||||||
|
const filterStrWithoutFK = JSON.stringify(filterWithoutFK);
|
||||||
|
|
||||||
const { whereAttr, whereVal } = CommonHelper.handleFilter({
|
const { whereAttr, whereVal } = CommonHelper.handleFilter({
|
||||||
filter: param.filter,
|
filter: filterStrWithoutFK,
|
||||||
col_any_eq: ['code'],
|
col_any_eq: ['code'],
|
||||||
col_any_like: ['name']
|
col_any_like: ['name']
|
||||||
});
|
});
|
||||||
@ -169,8 +194,16 @@ export class AldeiaController {
|
|||||||
const fetchAndWrite = async (page: any) => {
|
const fetchAndWrite = async (page: any) => {
|
||||||
const offset = (page - 1) * limit
|
const offset = (page - 1) * limit
|
||||||
|
|
||||||
const data = await repo.createQueryBuilder("Aldeia")
|
let query = repo.createQueryBuilder("Aldeia")
|
||||||
.where(whereAttr, whereVal)
|
.leftJoin("Aldeia.suco", "suco")
|
||||||
|
.where(whereAttr || "1=1", whereVal);
|
||||||
|
|
||||||
|
// Handle foreign key filter with relation
|
||||||
|
if (filterObj.suco_id) {
|
||||||
|
query = query.andWhere("suco.id = :sucoId", { sucoId: filterObj.suco_id });
|
||||||
|
}
|
||||||
|
|
||||||
|
const data = await query
|
||||||
.select([
|
.select([
|
||||||
'Aldeia.id',
|
'Aldeia.id',
|
||||||
'Aldeia.code',
|
'Aldeia.code',
|
||||||
|
|||||||
@ -70,19 +70,38 @@ export class SucoController {
|
|||||||
|
|
||||||
const offset = (param.page - 1) * param.limit
|
const offset = (param.page - 1) * param.limit
|
||||||
|
|
||||||
|
const filterObj = param.filter ? JSON.parse(param.filter) : {};
|
||||||
|
// Remove foreign key from filter for CommonHelper.handleFilter
|
||||||
|
const filterWithoutFK = { ...filterObj };
|
||||||
|
delete filterWithoutFK.administrativu_id;
|
||||||
|
const filterStrWithoutFK = JSON.stringify(filterWithoutFK);
|
||||||
|
|
||||||
const { whereAttr, whereVal } = CommonHelper.handleFilter({
|
const { whereAttr, whereVal } = CommonHelper.handleFilter({
|
||||||
filter: param.filter,
|
filter: filterStrWithoutFK,
|
||||||
col_any_eq: ['code'],
|
col_any_eq: ['code'],
|
||||||
col_any_like: ['name']
|
col_any_like: ['name']
|
||||||
});
|
});
|
||||||
|
|
||||||
const res_count = repo.createQueryBuilder("Suco")
|
const res_count = repo.createQueryBuilder("Suco")
|
||||||
.where(whereAttr, whereVal);
|
.leftJoin("Suco.administrativu", "administrativu")
|
||||||
|
.where(whereAttr || "1=1", whereVal);
|
||||||
|
|
||||||
|
// Handle foreign key filter with relation
|
||||||
|
if (filterObj.administrativu_id) {
|
||||||
|
res_count.andWhere("administrativu.id = :administrativuId", { administrativuId: filterObj.administrativu_id });
|
||||||
|
}
|
||||||
|
|
||||||
const res_list = repo.createQueryBuilder("Suco")
|
const res_list = repo.createQueryBuilder("Suco")
|
||||||
.where(whereAttr, whereVal)
|
.leftJoin("Suco.administrativu", "administrativu")
|
||||||
|
.where(whereAttr || "1=1", whereVal)
|
||||||
.orderBy("Suco." + param.order_field, param.order_direction)
|
.orderBy("Suco." + param.order_field, param.order_direction)
|
||||||
.offset(offset)
|
.offset(offset)
|
||||||
.limit(param.limit);
|
.limit(param.limit);
|
||||||
|
|
||||||
|
// Handle foreign key filter with relation
|
||||||
|
if (filterObj.administrativu_id) {
|
||||||
|
res_list.andWhere("administrativu.id = :administrativuId", { administrativuId: filterObj.administrativu_id });
|
||||||
|
}
|
||||||
|
|
||||||
if (param.with_deleted) {
|
if (param.with_deleted) {
|
||||||
res_count.withDeleted();
|
res_count.withDeleted();
|
||||||
@ -143,8 +162,14 @@ export class SucoController {
|
|||||||
|
|
||||||
const repo = OrmHelper.DB.getRepository(Suco);
|
const repo = OrmHelper.DB.getRepository(Suco);
|
||||||
|
|
||||||
|
const filterObj = param.filter ? JSON.parse(param.filter) : {};
|
||||||
|
// Remove foreign key from filter for CommonHelper.handleFilter
|
||||||
|
const filterWithoutFK = { ...filterObj };
|
||||||
|
delete filterWithoutFK.administrativu_id;
|
||||||
|
const filterStrWithoutFK = JSON.stringify(filterWithoutFK);
|
||||||
|
|
||||||
const { whereAttr, whereVal } = CommonHelper.handleFilter({
|
const { whereAttr, whereVal } = CommonHelper.handleFilter({
|
||||||
filter: param.filter,
|
filter: filterStrWithoutFK,
|
||||||
col_any_eq: ['code'],
|
col_any_eq: ['code'],
|
||||||
col_any_like: ['name']
|
col_any_like: ['name']
|
||||||
});
|
});
|
||||||
@ -169,8 +194,16 @@ export class SucoController {
|
|||||||
const fetchAndWrite = async (page: any) => {
|
const fetchAndWrite = async (page: any) => {
|
||||||
const offset = (page - 1) * limit
|
const offset = (page - 1) * limit
|
||||||
|
|
||||||
const data = await repo.createQueryBuilder("Suco")
|
let query = repo.createQueryBuilder("Suco")
|
||||||
.where(whereAttr, whereVal)
|
.leftJoin("Suco.administrativu", "administrativu")
|
||||||
|
.where(whereAttr || "1=1", whereVal);
|
||||||
|
|
||||||
|
// Handle foreign key filter with relation
|
||||||
|
if (filterObj.administrativu_id) {
|
||||||
|
query = query.andWhere("administrativu.id = :administrativuId", { administrativuId: filterObj.administrativu_id });
|
||||||
|
}
|
||||||
|
|
||||||
|
const data = await query
|
||||||
.select([
|
.select([
|
||||||
'Suco.id',
|
'Suco.id',
|
||||||
'Suco.code',
|
'Suco.code',
|
||||||
|
|||||||
Reference in New Issue
Block a user