Compare commits
1 Commits
1.6.25-alp
...
developmen
Author | SHA1 | Date |
---|---|---|
|
7bb539db0c |
|
@ -6,6 +6,8 @@ import {
|
|||
Param,
|
||||
RelationParam,
|
||||
} from 'src/core/modules/domain/entities/base-filter.entity';
|
||||
import * as moment from 'moment';
|
||||
import { ORDER_TYPE } from 'src/core/strings/constants/base.constants';
|
||||
|
||||
// TODO:
|
||||
// Implementasikan filter by start_time, end_timen, dan max_usage_time
|
||||
|
@ -13,6 +15,10 @@ import {
|
|||
@Injectable()
|
||||
export class IndexPublicTimeGroupManager extends BaseIndexManager<TimeGroupEntity> {
|
||||
async prepareData(): Promise<void> {
|
||||
Object.assign(this.filterParam, {
|
||||
order_by: `${this.tableName}.start_time`,
|
||||
order_type: ORDER_TYPE.ASC,
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -60,6 +66,15 @@ export class IndexPublicTimeGroupManager extends BaseIndexManager<TimeGroupEntit
|
|||
queryBuilder: SelectQueryBuilder<TimeGroupEntity>,
|
||||
): SelectQueryBuilder<TimeGroupEntity> {
|
||||
queryBuilder.andWhere(`items.id is not null`);
|
||||
|
||||
if (!this.filterParam.date) {
|
||||
const currentTime = moment().utcOffset('+07:00').format('HH:mm:ss');
|
||||
|
||||
queryBuilder.andWhere(`${this.tableName}.end_time >= :current_time`, {
|
||||
current_time: currentTime,
|
||||
});
|
||||
}
|
||||
|
||||
return queryBuilder;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -30,4 +30,12 @@ export class FilterTimeGroupDto
|
|||
@ApiProperty({ type: 'string', required: false })
|
||||
@ValidateIf((body) => body.max_usage_time_to)
|
||||
max_usage_time_to: string;
|
||||
|
||||
@ApiProperty({
|
||||
type: Date,
|
||||
required: false,
|
||||
example: '2024-01-01',
|
||||
})
|
||||
@ValidateIf((body) => body.date)
|
||||
date: Date;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue