import { Body, Controller, Delete, Get, Param, Post, Query } from '@nestjs/common'; import { ApiTags } from '@nestjs/swagger'; import { CreateBlacklistDto, CreateDrainageFieldDto, CreatePhoneCarrierRuleDto, CreatePhoneSegmentDto, CreateSensitiveWordDto, DictionariesService, DictionaryStatusDto, } from './dictionaries.service'; @ApiTags('dictionaries') @Controller('admin/dictionaries') export class DictionariesController { constructor(private readonly dictionaries: DictionariesService) {} @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); } @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); } @Delete('drainage-fields/:id') deleteDrainageField(@Param('id') id: string) { return this.dictionaries.deleteDrainageField(id); } }