feat(SPG-349) REST API Read Tipe Season
parent
446295ee16
commit
73547451d4
|
@ -0,0 +1,17 @@
|
|||
import { Injectable } from '@nestjs/common';
|
||||
import { SeasonTypeEntity } from '../../domain/entities/season-type.entity';
|
||||
import { InjectRepository } from '@nestjs/typeorm';
|
||||
import { SeasonTypeModel } from '../models/season-type.model';
|
||||
import { CONNECTION_NAME } from 'src/core/strings/constants/base.constants';
|
||||
import { Repository } from 'typeorm';
|
||||
import { BaseReadService } from 'src/core/modules/data/service/base-read.service';
|
||||
|
||||
@Injectable()
|
||||
export class SeasonTypeReadService extends BaseReadService<SeasonTypeEntity> {
|
||||
constructor(
|
||||
@InjectRepository(SeasonTypeModel, CONNECTION_NAME.DEFAULT)
|
||||
private repo: Repository<SeasonTypeModel>,
|
||||
) {
|
||||
super(repo);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,3 @@
|
|||
import { BaseFilterEntity } from 'src/core/modules/domain/entities/base-filter.entity';
|
||||
|
||||
export interface FilterSeasonTypeEntity extends BaseFilterEntity {}
|
|
@ -0,0 +1,50 @@
|
|||
import { Injectable } from '@nestjs/common';
|
||||
import { BaseDetailManager } from 'src/core/modules/domain/usecase/managers/base-detail.manager';
|
||||
import { SeasonTypeEntity } from '../../entities/season-type.entity';
|
||||
import { RelationParam } from 'src/core/modules/domain/entities/base-filter.entity';
|
||||
|
||||
@Injectable()
|
||||
export class DetailSeasonTypeManager extends BaseDetailManager<SeasonTypeEntity> {
|
||||
async prepareData(): Promise<void> {
|
||||
return;
|
||||
}
|
||||
|
||||
async beforeProcess(): Promise<void> {
|
||||
return;
|
||||
}
|
||||
|
||||
async afterProcess(): Promise<void> {
|
||||
return;
|
||||
}
|
||||
|
||||
get relations(): RelationParam {
|
||||
return {
|
||||
// relation only join (for query purpose)
|
||||
joinRelations: [],
|
||||
|
||||
// relation join and select (relasi yang ingin ditampilkan),
|
||||
selectRelations: [],
|
||||
|
||||
// relation yang hanya ingin dihitung (akan return number)
|
||||
countRelations: [],
|
||||
};
|
||||
}
|
||||
|
||||
get selects(): string[] {
|
||||
return [
|
||||
`${this.tableName}.id`,
|
||||
`${this.tableName}.status`,
|
||||
`${this.tableName}.name`,
|
||||
`${this.tableName}.created_at`,
|
||||
`${this.tableName}.updated_at`,
|
||||
`${this.tableName}.creator_id`,
|
||||
`${this.tableName}.editor_id`,
|
||||
];
|
||||
}
|
||||
|
||||
get setFindProperties(): any {
|
||||
return {
|
||||
id: this.dataId,
|
||||
};
|
||||
}
|
||||
}
|
|
@ -0,0 +1,63 @@
|
|||
import { Injectable } from '@nestjs/common';
|
||||
import { BaseIndexManager } from 'src/core/modules/domain/usecase/managers/base-index.manager';
|
||||
import { SeasonTypeEntity } from '../../entities/season-type.entity';
|
||||
import { SelectQueryBuilder } from 'typeorm';
|
||||
import {
|
||||
Param,
|
||||
RelationParam,
|
||||
} from 'src/core/modules/domain/entities/base-filter.entity';
|
||||
|
||||
@Injectable()
|
||||
export class IndexSeasonTypeManager extends BaseIndexManager<SeasonTypeEntity> {
|
||||
async prepareData(): Promise<void> {
|
||||
return;
|
||||
}
|
||||
|
||||
async beforeProcess(): Promise<void> {
|
||||
return;
|
||||
}
|
||||
|
||||
async afterProcess(): Promise<void> {
|
||||
return;
|
||||
}
|
||||
|
||||
get relations(): RelationParam {
|
||||
return {
|
||||
// relation only join (for query purpose)
|
||||
joinRelations: [],
|
||||
|
||||
// relation join and select (relasi yang ingin ditampilkan),
|
||||
selectRelations: [],
|
||||
|
||||
// relation yang hanya ingin dihitung (akan return number)
|
||||
countRelations: [],
|
||||
};
|
||||
}
|
||||
|
||||
get selects(): string[] {
|
||||
return [
|
||||
`${this.tableName}.id`,
|
||||
`${this.tableName}.status`,
|
||||
`${this.tableName}.name`,
|
||||
`${this.tableName}.created_at`,
|
||||
`${this.tableName}.updated_at`,
|
||||
`${this.tableName}.creator_id`,
|
||||
`${this.tableName}.editor_id`,
|
||||
];
|
||||
}
|
||||
|
||||
get specificFilter(): Param[] {
|
||||
return [
|
||||
{
|
||||
cols: `${this.tableName}.name`,
|
||||
data: this.filterParam.names,
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
setQueryFilter(
|
||||
queryBuilder: SelectQueryBuilder<SeasonTypeEntity>,
|
||||
): SelectQueryBuilder<SeasonTypeEntity> {
|
||||
return queryBuilder;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,33 @@
|
|||
import { Injectable } from '@nestjs/common';
|
||||
import { IndexSeasonTypeManager } from './managers/index-season-type.manager';
|
||||
import { SeasonTypeReadService } from '../../data/services/season-type-read.service';
|
||||
import { SeasonTypeEntity } from '../entities/season-type.entity';
|
||||
import { PaginationResponse } from 'src/core/response/domain/ok-response.interface';
|
||||
import { BaseReadOrchestrator } from 'src/core/modules/domain/usecase/orchestrators/base-read.orchestrator';
|
||||
import { DetailSeasonTypeManager } from './managers/detail-season-type.manager';
|
||||
import { TABLE_NAME } from 'src/core/strings/constants/table.constants';
|
||||
|
||||
@Injectable()
|
||||
export class SeasonTypeReadOrchestrator extends BaseReadOrchestrator<SeasonTypeEntity> {
|
||||
constructor(
|
||||
private indexManager: IndexSeasonTypeManager,
|
||||
private detailManager: DetailSeasonTypeManager,
|
||||
private serviceData: SeasonTypeReadService,
|
||||
) {
|
||||
super();
|
||||
}
|
||||
|
||||
async index(params): Promise<PaginationResponse<SeasonTypeEntity>> {
|
||||
this.indexManager.setFilterParam(params);
|
||||
this.indexManager.setService(this.serviceData, TABLE_NAME.SEASON_TYPE);
|
||||
await this.indexManager.execute();
|
||||
return this.indexManager.getResult();
|
||||
}
|
||||
|
||||
async detail(dataId: string): Promise<SeasonTypeEntity> {
|
||||
this.detailManager.setData(dataId);
|
||||
this.detailManager.setService(this.serviceData, TABLE_NAME.SEASON_TYPE);
|
||||
await this.detailManager.execute();
|
||||
return this.detailManager.getResult();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,6 @@
|
|||
import { BaseFilterDto } from 'src/core/modules/infrastructure/dto/base-filter.dto';
|
||||
import { FilterSeasonTypeEntity } from '../../domain/entities/filter-season-type.entity';
|
||||
|
||||
export class FilterSeasonTypeDto
|
||||
extends BaseFilterDto
|
||||
implements FilterSeasonTypeEntity {}
|
Loading…
Reference in New Issue