import { Body, Controller, Delete, Get, Param, Post, Put, Query } from '@nestjs/common'; import { ApiTags } from '@nestjs/swagger'; import { CurrentSessionUserId } from '../auth/current-session-user.decorator'; import { CreateCommonReportFieldDto, CreateBlacklistDto, CreateDrainageFieldDto, UpsertDrainageDetectionRuleDto, TestDrainageDetectionDto, CreatePhoneCarrierRuleDto, CreatePhoneSegmentDto, CreateSensitiveWordDto, DictionariesService, DictionaryStatusDto, ReorderCommonReportFieldsDto, UpdateDrainageFieldDto, } from './dictionaries.service'; @ApiTags('dictionaries') @Controller('admin/dictionaries') export class DictionariesController { constructor(private readonly dictionaries: DictionariesService) {} @Get('administrative-regions') listAdministrativeRegions() { return this.dictionaries.listAdministrativeRegions(); } @Get('phone-segments') listPhoneSegments( @Query('keyword') keyword?: string, @Query('page') page?: string, @Query('pageSize') pageSize?: string, ) { return this.dictionaries.listPhoneSegments({ keyword, page: Number(page) || undefined, pageSize: Number(pageSize) || undefined }); } @Post('phone-segments') createPhoneSegment(@Body() body: CreatePhoneSegmentDto) { return this.dictionaries.createPhoneSegment(body); } @Delete('phone-segments/:id') deletePhoneSegment(@Param('id') id: string) { return this.dictionaries.deletePhoneSegment(id); } @Get('phone-carrier-rules') listPhoneCarrierRules(@Query('keyword') keyword?: string, @Query('page') page?: string, @Query('pageSize') pageSize?: string) { return this.dictionaries.listPhoneCarrierRules({ keyword, page: Number(page) || undefined, pageSize: Number(pageSize) || undefined }); } @Post('phone-carrier-rules') createPhoneCarrierRule(@Body() body: CreatePhoneCarrierRuleDto) { return this.dictionaries.createPhoneCarrierRule(body); } @Delete('phone-carrier-rules/:id') deletePhoneCarrierRule(@Param('id') id: string) { return this.dictionaries.deletePhoneCarrierRule(id); } @Get('sensitive-words') listSensitiveWords(@Query('keyword') keyword?: string, @Query('status') status?: string) { return this.dictionaries.listSensitiveWords({ keyword, status }); } @Post('sensitive-words') createSensitiveWord(@Body() body: CreateSensitiveWordDto) { return this.dictionaries.createSensitiveWord(body); } @Post('sensitive-words/:id/status') changeSensitiveWordStatus(@Param('id') id: string, @Body() body: DictionaryStatusDto) { return this.dictionaries.changeSensitiveWordStatus(id, body); } @Delete('sensitive-words/:id') deleteSensitiveWord(@Param('id') id: string) { return this.dictionaries.changeSensitiveWordStatus(id, { status: 'deleted' }); } @Get('blacklists/global') listGlobalBlacklist(@Query('keyword') keyword?: string, @Query('status') status?: string) { return this.dictionaries.listGlobalBlacklist({ keyword, status }); } @Post('blacklists/global') createGlobalBlacklist(@Body() body: CreateBlacklistDto) { return this.dictionaries.createGlobalBlacklist(body); } @Post('blacklists/global/:id/status') changeGlobalBlacklistStatus(@Param('id') id: string, @Body() body: DictionaryStatusDto) { return this.dictionaries.changeGlobalBlacklistStatus(id, body); } @Delete('blacklists/global/:id') deleteGlobalBlacklist(@Param('id') id: string) { return this.dictionaries.changeGlobalBlacklistStatus(id, { status: 'deleted' }); } @Get('blacklists/enterprise') listEnterpriseBlacklist(@Query('tenantId') tenantId?: string, @Query('applicationId') applicationId?: string, @Query('keyword') keyword?: string, @Query('status') status?: string, @Query('enterpriseKeyword') enterpriseKeyword?: string, @Query('applicationKeyword') applicationKeyword?: string, @Query('phoneNumber') phoneNumber?: string, @Query('reasonKeyword') reasonKeyword?: string) { return this.dictionaries.listEnterpriseBlacklist({ tenantId, applicationId, keyword, status, enterpriseKeyword, applicationKeyword, phoneNumber, reasonKeyword }); } @Post('blacklists/enterprise') createEnterpriseBlacklist(@Body() body: CreateBlacklistDto) { return this.dictionaries.createEnterpriseBlacklist(body); } @Post('blacklists/enterprise/:id/status') changeEnterpriseBlacklistStatus(@Param('id') id: string, @Body() body: DictionaryStatusDto) { return this.dictionaries.changeEnterpriseBlacklistStatus(id, body); } @Delete('blacklists/enterprise/:id') deleteEnterpriseBlacklist(@Param('id') id: string) { return this.dictionaries.changeEnterpriseBlacklistStatus(id, { status: 'deleted' }); } @Get('drainage-fields') listDrainageFields() { return this.dictionaries.listDrainageFields(); } @Post('drainage-fields') createDrainageField(@Body() body: CreateDrainageFieldDto) { return this.dictionaries.createDrainageField(body); } @Put('drainage-fields/:id') updateDrainageField( @Param('id') id: string, @Body() body: UpdateDrainageFieldDto, @CurrentSessionUserId() operatorId?: string, ) { return this.dictionaries.updateDrainageField(id, body, operatorId); } @Delete('drainage-fields/:id') deleteDrainageField(@Param('id') id: string) { return this.dictionaries.deleteDrainageField(id); } @Get('drainage-detection-rules') listDrainageDetectionRules(@Query('keyword') keyword?: string, @Query('status') status?: string) { return this.dictionaries.listDrainageDetectionRules({ keyword, status }); } @Post('drainage-detection-rules/test') testDrainageDetection(@Body() body: TestDrainageDetectionDto) { return this.dictionaries.testDrainageDetection(body); } @Post('drainage-detection-rules') createDrainageDetectionRule(@Body() body: UpsertDrainageDetectionRuleDto, @CurrentSessionUserId() operatorId?: string) { return this.dictionaries.createDrainageDetectionRule({ ...body, operatorId }); } @Put('drainage-detection-rules/:id') updateDrainageDetectionRule(@Param('id') id: string, @Body() body: UpsertDrainageDetectionRuleDto, @CurrentSessionUserId() operatorId?: string) { return this.dictionaries.updateDrainageDetectionRule(id, { ...body, operatorId }); } @Post('drainage-detection-rules/:id/status') changeDrainageDetectionRuleStatus(@Param('id') id: string, @Body() body: DictionaryStatusDto, @CurrentSessionUserId() operatorId?: string) { return this.dictionaries.changeDrainageDetectionRuleStatus(id, { ...body, operatorId }); } @Get('common-report-fields') listCommonReportFields() { return this.dictionaries.listCommonReportFields(); } @Post('common-report-fields') createCommonReportField(@Body() body: CreateCommonReportFieldDto) { return this.dictionaries.createCommonReportField(body); } @Put('common-report-fields/order') reorderCommonReportFields( @Body() body: ReorderCommonReportFieldsDto, @CurrentSessionUserId() operatorId?: string, ) { return this.dictionaries.reorderCommonReportFields(body, operatorId); } @Delete('common-report-fields/:id') deleteCommonReportField(@Param('id') id: string) { return this.dictionaries.deleteCommonReportField(id); } @Put('common-report-fields/:id') updateCommonReportField(@Param('id') id: string, @Body() body: CreateCommonReportFieldDto, @CurrentSessionUserId() operatorId?: string) { return this.dictionaries.updateCommonReportField(id, body, operatorId); } }