Compare commits
No commits in common. "908834cdd96ef3013f3ad9cc3b26b54d2a38b361" and "853543ece588a8456930c3bb09bc52a85f6131b1" have entirely different histories.
908834cdd9
...
853543ece5
|
@ -13,11 +13,9 @@ export abstract class BaseReadService<Entity> {
|
||||||
queryBuilder: SelectQueryBuilder<Entity>,
|
queryBuilder: SelectQueryBuilder<Entity>,
|
||||||
params: BaseFilterEntity,
|
params: BaseFilterEntity,
|
||||||
): Promise<PaginationResponse<Entity>> {
|
): Promise<PaginationResponse<Entity>> {
|
||||||
const limit = params.limit ?? 10;
|
|
||||||
const page = params.page ?? 1;
|
|
||||||
const [data, total] = await queryBuilder
|
const [data, total] = await queryBuilder
|
||||||
.take(+limit)
|
.take(+params.limit)
|
||||||
.skip(+limit * +page - +limit)
|
.skip(+params.limit * +params.page - +params.limit)
|
||||||
.getManyAndCount();
|
.getManyAndCount();
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
|
|
@ -6,7 +6,10 @@ import { Global, Module } from '@nestjs/common';
|
||||||
|
|
||||||
@Global()
|
@Global()
|
||||||
@Module({
|
@Module({
|
||||||
imports: [ConfigModule.forRoot(), CqrsModule],
|
imports: [
|
||||||
|
ConfigModule.forRoot(),
|
||||||
|
CqrsModule,
|
||||||
|
],
|
||||||
controllers: [MidtransController],
|
controllers: [MidtransController],
|
||||||
providers: [MidtransService],
|
providers: [MidtransService],
|
||||||
exports: [MidtransService],
|
exports: [MidtransService],
|
||||||
|
|
|
@ -124,6 +124,8 @@ export class IndexItemRateManager extends BaseIndexManager<ItemEntity> {
|
||||||
queryBuilder.andWhere(`${this.tableName}.tenant_id In (:...tenantIds)`, {
|
queryBuilder.andWhere(`${this.tableName}.tenant_id In (:...tenantIds)`, {
|
||||||
tenantIds: this.filterParam.tenant_ids,
|
tenantIds: this.filterParam.tenant_ids,
|
||||||
});
|
});
|
||||||
|
} else if (!this.filterParam.all_item) {
|
||||||
|
queryBuilder.andWhere(`${this.tableName}.tenant_id Is Null`);
|
||||||
}
|
}
|
||||||
|
|
||||||
return queryBuilder;
|
return queryBuilder;
|
||||||
|
|
|
@ -72,17 +72,17 @@ export class IndexItemRatesManager extends BaseIndexManager<ItemRateEntity> {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.filterParam.season_period_ids) {
|
if (this.filterParam.season_period_ids) {
|
||||||
queryBuilder.andWhere(`season_period.id In (:...seasonIdss)`, {
|
queryBuilder.andWhere(`season_period.id In (:...itemIds)`, {
|
||||||
seasonIdss: this.filterParam.season_period_ids,
|
itemIds: this.filterParam.season_period_ids,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.filterParam.start_date) {
|
if (this.filterParam.start_date) {
|
||||||
queryBuilder.andWhere(`season_period.start_date <= :inputStartDate`, {
|
queryBuilder.andWhere(`season_period.start_date < :inputStartDate`, {
|
||||||
inputStartDate: this.filterParam.end_date,
|
inputStartDate: this.filterParam.end_date,
|
||||||
});
|
});
|
||||||
|
|
||||||
queryBuilder.andWhere(`season_period.end_date >= :inputEndDate`, {
|
queryBuilder.andWhere(`season_period.end_date > :inputEndDate`, {
|
||||||
inputEndDate: this.filterParam.start_date,
|
inputEndDate: this.filterParam.start_date,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -85,6 +85,8 @@ export class IndexItemManager extends BaseIndexManager<ItemEntity> {
|
||||||
queryBuilder.andWhere(`${this.tableName}.tenant_id In (:...tenantIds)`, {
|
queryBuilder.andWhere(`${this.tableName}.tenant_id In (:...tenantIds)`, {
|
||||||
tenantIds: this.filterParam.tenant_ids,
|
tenantIds: this.filterParam.tenant_ids,
|
||||||
});
|
});
|
||||||
|
} else if (!this.filterParam.all_item) {
|
||||||
|
queryBuilder.andWhere(`${this.tableName}.tenant_id Is Null`);
|
||||||
}
|
}
|
||||||
|
|
||||||
return queryBuilder;
|
return queryBuilder;
|
||||||
|
|
|
@ -69,12 +69,13 @@ export class CurrentSeasonPeriodManager extends BaseIndexManager<SeasonPeriodEnt
|
||||||
setQueryFilter(
|
setQueryFilter(
|
||||||
queryBuilder: SelectQueryBuilder<SeasonPeriodEntity>,
|
queryBuilder: SelectQueryBuilder<SeasonPeriodEntity>,
|
||||||
): SelectQueryBuilder<SeasonPeriodEntity> {
|
): SelectQueryBuilder<SeasonPeriodEntity> {
|
||||||
queryBuilder.andWhere(`${this.tableName}.start_date <= :date`, {
|
queryBuilder.andWhere(
|
||||||
date: this.filterParam.date ?? new Date().toLocaleDateString(),
|
`${this.tableName}.start_date BETWEEN :from AND :to`,
|
||||||
});
|
{
|
||||||
queryBuilder.andWhere(`${this.tableName}.end_date >= :date`, {
|
from: this.filterParam.date ?? new Date().toLocaleDateString(),
|
||||||
date: this.filterParam.date ?? new Date().toLocaleDateString(),
|
to: this.filterParam.date ?? new Date().toLocaleDateString(),
|
||||||
});
|
},
|
||||||
|
);
|
||||||
|
|
||||||
queryBuilder.andWhere(`${this.tableName}.status In (:...statuses)`, {
|
queryBuilder.andWhere(`${this.tableName}.status In (:...statuses)`, {
|
||||||
statuses: [STATUS.ACTIVE],
|
statuses: [STATUS.ACTIVE],
|
||||||
|
|
|
@ -38,10 +38,10 @@ export async function ValidateSeasonPeriodHelper(dataService, data) {
|
||||||
|
|
||||||
let datas = await query
|
let datas = await query
|
||||||
.andWhere('data.priority = :priority', { priority: priority })
|
.andWhere('data.priority = :priority', { priority: priority })
|
||||||
.andWhere(`data.start_date <= :inputStartDate`, {
|
.andWhere(`data.start_date < :inputStartDate`, {
|
||||||
inputStartDate: data.end_date,
|
inputStartDate: data.end_date,
|
||||||
})
|
})
|
||||||
.andWhere(`data.end_date >= :inputEndDate`, {
|
.andWhere(`data.end_date > :inputEndDate`, {
|
||||||
inputEndDate: data.start_date,
|
inputEndDate: data.start_date,
|
||||||
})
|
})
|
||||||
.getMany();
|
.getMany();
|
||||||
|
|
|
@ -87,11 +87,11 @@ export class IndexTransactionManager extends BaseIndexManager<TransactionEntity>
|
||||||
data: this.filterParam.invoice_codes,
|
data: this.filterParam.invoice_codes,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
cols: `${this.tableName}.type::text`,
|
cols: `${this.tableName}.type`,
|
||||||
data: this.filterParam.types,
|
data: this.filterParam.types,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
cols: `${this.tableName}.customer_type::text`,
|
cols: `${this.tableName}.customer_type`,
|
||||||
data: this.filterParam.customer_types,
|
data: this.filterParam.customer_types,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -99,7 +99,7 @@ export class IndexTransactionManager extends BaseIndexManager<TransactionEntity>
|
||||||
data: this.filterParam.customer_names,
|
data: this.filterParam.customer_names,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
cols: `${this.tableName}.payment_type::text`,
|
cols: `${this.tableName}.payment_type`,
|
||||||
data: this.filterParam.payment_types,
|
data: this.filterParam.payment_types,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
|
@ -6,13 +6,10 @@ import {
|
||||||
Param,
|
Param,
|
||||||
RelationParam,
|
RelationParam,
|
||||||
} from 'src/core/modules/domain/entities/base-filter.entity';
|
} from 'src/core/modules/domain/entities/base-filter.entity';
|
||||||
import { ORDER_TYPE } from 'src/core/strings/constants/base.constants';
|
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class IndexFaqManager extends BaseIndexManager<FaqEntity> {
|
export class IndexFaqManager extends BaseIndexManager<FaqEntity> {
|
||||||
async prepareData(): Promise<void> {
|
async prepareData(): Promise<void> {
|
||||||
this.filterParam.order_by = `${this.tableName}.sort_order`;
|
|
||||||
this.filterParam.order_type = ORDER_TYPE.ASC;
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -41,7 +38,6 @@ export class IndexFaqManager extends BaseIndexManager<FaqEntity> {
|
||||||
return [
|
return [
|
||||||
`${this.tableName}.id`,
|
`${this.tableName}.id`,
|
||||||
`${this.tableName}.status`,
|
`${this.tableName}.status`,
|
||||||
`${this.tableName}.sort_order`,
|
|
||||||
`${this.tableName}.created_at`,
|
`${this.tableName}.created_at`,
|
||||||
`${this.tableName}.creator_name`,
|
`${this.tableName}.creator_name`,
|
||||||
`${this.tableName}.updated_at`,
|
`${this.tableName}.updated_at`,
|
||||||
|
|
|
@ -6,13 +6,10 @@ import {
|
||||||
Param,
|
Param,
|
||||||
RelationParam,
|
RelationParam,
|
||||||
} from 'src/core/modules/domain/entities/base-filter.entity';
|
} from 'src/core/modules/domain/entities/base-filter.entity';
|
||||||
import { ORDER_TYPE } from 'src/core/strings/constants/base.constants';
|
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class IndexTermConditionManager extends BaseIndexManager<TermConditionEntity> {
|
export class IndexTermConditionManager extends BaseIndexManager<TermConditionEntity> {
|
||||||
async prepareData(): Promise<void> {
|
async prepareData(): Promise<void> {
|
||||||
this.filterParam.order_by = `${this.tableName}.sort_order`;
|
|
||||||
this.filterParam.order_type = ORDER_TYPE.ASC;
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -41,7 +38,6 @@ export class IndexTermConditionManager extends BaseIndexManager<TermConditionEnt
|
||||||
return [
|
return [
|
||||||
`${this.tableName}.id`,
|
`${this.tableName}.id`,
|
||||||
`${this.tableName}.status`,
|
`${this.tableName}.status`,
|
||||||
`${this.tableName}.sort_order`,
|
|
||||||
`${this.tableName}.created_at`,
|
`${this.tableName}.created_at`,
|
||||||
`${this.tableName}.creator_name`,
|
`${this.tableName}.creator_name`,
|
||||||
`${this.tableName}.updated_at`,
|
`${this.tableName}.updated_at`,
|
||||||
|
|
Loading…
Reference in New Issue