import { Body, Controller, Delete, Param, Patch, Post, Put, Get, } from '@nestjs/common'; import { SeasonPeriodDataOrchestrator } from '../domain/usecases/season-period-data.orchestrator'; import { SeasonPeriodDto } from './dto/season-period.dto'; import { MODULE_NAME } from 'src/core/strings/constants/module.constants'; import { ApiBearerAuth, ApiTags } from '@nestjs/swagger'; import { SeasonPeriodEntity } from '../domain/entities/season-period.entity'; import { BatchResult } from 'src/core/response/domain/ok-response.interface'; import { BatchIdsDto } from 'src/core/modules/infrastructure/dto/base-batch.dto'; import { Public } from 'src/core/guards'; import { UpdateSeasonPeriodDto } from './dto/update-season-period.dto'; import { UpdateSeasonPeriodItemDto } from './dto/update-season-period-item.dto'; import { UpdateSeasonPriceDto } from './dto/update-season-price.dto'; @ApiTags(`${MODULE_NAME.SEASON_PERIOD.split('-').join(' ')} - data`) @Controller(`v1/${MODULE_NAME.SEASON_PERIOD}`) @Public(false) @ApiBearerAuth('JWT') export class SeasonPeriodDataController { constructor(private orchestrator: SeasonPeriodDataOrchestrator) {} @Post() async create(@Body() data: SeasonPeriodDto): Promise { return await this.orchestrator.create(data); } @Post('/update-price') async updatePrice(@Body() body: UpdateSeasonPriceDto): Promise { return await this.orchestrator.updatePrice(body); } @Put('/batch-delete') async batchDeleted(@Body() body: BatchIdsDto): Promise { return await this.orchestrator.batchDelete(body.ids); } @Patch(':id/active') async active(@Param('id') dataId: string): Promise { return await this.orchestrator.active(dataId); } @Put('/batch-active') async batchActive(@Body() body: BatchIdsDto): Promise { return await this.orchestrator.batchActive(body.ids); } @Patch(':id/confirm') async confirm(@Param('id') dataId: string): Promise { return await this.orchestrator.confirm(dataId); } @Put('/batch-confirm') async batchConfirm(@Body() body: BatchIdsDto): Promise { return await this.orchestrator.batchConfirm(body.ids); } @Patch(':id/inactive') async inactive(@Param('id') dataId: string): Promise { return await this.orchestrator.inactive(dataId); } @Put('/batch-inactive') async batchInactive(@Body() body: BatchIdsDto): Promise { return await this.orchestrator.batchInactive(body.ids); } @Put(':id') async update( @Param('id') dataId: string, @Body() data: UpdateSeasonPeriodDto, ): Promise { return await this.orchestrator.update(dataId, data); } // pemisahan update data dengan update items dikarenakan payload (based on tampilan) berbeda @Put(':id/items') async updateItems( @Param('id') dataId: string, @Body() data: UpdateSeasonPeriodItemDto, ): Promise { return await this.orchestrator.update(dataId, data); } @Delete(':id') async delete(@Param('id') dataId: string): Promise { return await this.orchestrator.delete(dataId); } }