fix(relasi) penambahan relasi tenant get

pull/3/head
Aswin Ashar Abdullah 2024-06-20 15:22:56 +07:00
parent 766909798f
commit 84bf55011d
2 changed files with 43 additions and 29 deletions

View File

@ -23,7 +23,11 @@ export class DetailItemManager extends BaseDetailManager<ItemEntity> {
joinRelations: [],
// relation join and select (relasi yang ingin ditampilkan),
selectRelations: ['item_category', 'bundling_items'],
selectRelations: [
'item_category',
'bundling_items',
'tenant',
],
// relation yang hanya ingin dihitung (akan return number)
countRelations: [],
@ -32,19 +36,19 @@ export class DetailItemManager extends BaseDetailManager<ItemEntity> {
get selects(): string[] {
return [
`${this.tableName}.id`,
`${this.tableName}.created_at`,
`${this.tableName}.status`,
`${this.tableName}.item_type`,
`${this.tableName}.name`,
`${this.tableName}.limit_type`,
`${this.tableName}.limit_value`,
`${this.tableName}.hpp`,
`${this.tableName}.sales_margin`,
`${this.tableName}.total_price`,
`${this.tableName}.base_price`,
`${this.tableName}.use_queue`,
`${this.tableName}.show_to_booking`,
`${ this.tableName }.id`,
`${ this.tableName }.created_at`,
`${ this.tableName }.status`,
`${ this.tableName }.item_type`,
`${ this.tableName }.name`,
`${ this.tableName }.limit_type`,
`${ this.tableName }.limit_value`,
`${ this.tableName }.hpp`,
`${ this.tableName }.sales_margin`,
`${ this.tableName }.total_price`,
`${ this.tableName }.base_price`,
`${ this.tableName }.use_queue`,
`${ this.tableName }.show_to_booking`,
`item_category.id`,
`item_category.name`,
@ -53,6 +57,9 @@ export class DetailItemManager extends BaseDetailManager<ItemEntity> {
'bundling_items.name',
'bundling_items.hpp',
'bundling_items.base_price',
'tenant.id',
'tenant.name'
];
}

View File

@ -27,7 +27,11 @@ export class IndexItemManager extends BaseIndexManager<ItemEntity> {
joinRelations: [],
// relation join and select (relasi yang ingin ditampilkan),
selectRelations: ['item_category', 'bundling_items'],
selectRelations: [
'item_category',
'bundling_items',
'tenant',
],
// relation yang hanya ingin dihitung (akan return number)
countRelations: [],
@ -36,36 +40,39 @@ export class IndexItemManager extends BaseIndexManager<ItemEntity> {
get selects(): string[] {
return [
`${this.tableName}.id`,
`${this.tableName}.created_at`,
`${this.tableName}.status`,
`${this.tableName}.item_type`,
`${this.tableName}.name`,
`${this.tableName}.hpp`,
`${this.tableName}.limit_type`,
`${this.tableName}.limit_value`,
`${this.tableName}.base_price`,
`${ this.tableName }.id`,
`${ this.tableName }.created_at`,
`${ this.tableName }.status`,
`${ this.tableName }.item_type`,
`${ this.tableName }.name`,
`${ this.tableName }.hpp`,
`${ this.tableName }.limit_type`,
`${ this.tableName }.limit_value`,
`${ this.tableName }.base_price`,
`item_category.id`,
`item_category.name`,
'bundling_items.id',
'bundling_items.name',
'tenant.id',
'tenant.name'
];
}
get specificFilter(): Param[] {
return [
{
cols: `${this.tableName}.name`,
cols: `${ this.tableName }.name`,
data: this.filterParam.names,
},
{
cols: `${this.tableName}.item_type::text`,
cols: `${ this.tableName }.item_type::text`,
data: this.filterParam.item_types,
},
{
cols: `${this.tableName}.limit_type::text`,
cols: `${ this.tableName }.limit_type::text`,
data: this.filterParam.limit_types,
},
{
@ -79,11 +86,11 @@ export class IndexItemManager extends BaseIndexManager<ItemEntity> {
queryBuilder: SelectQueryBuilder<ItemEntity>,
): SelectQueryBuilder<ItemEntity> {
if (this.filterParam.tenant_ids?.length) {
queryBuilder.andWhere(`${this.tableName}.tenant_id In (:...tenantIds)`, {
queryBuilder.andWhere(`${ this.tableName }.tenant_id In (:...tenantIds)`, {
tenantIds: this.filterParam.tenant_ids,
});
} else if (!this.filterParam.all_item) {
queryBuilder.andWhere(`${this.tableName}.tenant_id Is Null`);
queryBuilder.andWhere(`${ this.tableName }.tenant_id Is Null`);
}
return queryBuilder;