feat: add phone frequency controls and modularize codebase
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { Body, Controller, Get, Param, Post, Put, Query } from '@nestjs/common';
|
||||
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 { SendChainService } from '../send-chain/send-chain.service';
|
||||
@@ -8,11 +8,20 @@ import {
|
||||
ReviewSmsTaskDto,
|
||||
RiskReviewService,
|
||||
} from './risk-review.service';
|
||||
import {
|
||||
CreatePhoneFrequencyWhitelistDto,
|
||||
PhoneFrequencyService,
|
||||
UpdatePhoneFrequencyWhitelistDto,
|
||||
} from './phone-frequency.service';
|
||||
|
||||
@ApiTags('risk-review')
|
||||
@Controller('admin/risk-review')
|
||||
export class AdminRiskReviewController {
|
||||
constructor(private readonly riskReview: RiskReviewService, private readonly sendChain: SendChainService) {}
|
||||
constructor(
|
||||
private readonly riskReview: RiskReviewService,
|
||||
private readonly sendChain: SendChainService,
|
||||
private readonly phoneFrequency: PhoneFrequencyService,
|
||||
) {}
|
||||
|
||||
@Get('rules')
|
||||
listRules(@Query('applicationId') applicationId?: string) {
|
||||
@@ -34,6 +43,85 @@ export class AdminRiskReviewController {
|
||||
return this.riskReview.listHits(tenantId, taskId);
|
||||
}
|
||||
|
||||
@Get('phone-frequency-hits')
|
||||
listPhoneFrequencyHits(
|
||||
@Query('tenantId') tenantId?: string,
|
||||
@Query('applicationId') applicationId?: string,
|
||||
@Query('phoneNumber') phoneNumber?: string,
|
||||
@Query('status') status?: 'active' | 'expired' | 'released',
|
||||
@Query('createdAtFrom') createdAtFrom?: string,
|
||||
@Query('createdAtTo') createdAtTo?: string,
|
||||
@Query('page') page?: string,
|
||||
@Query('pageSize') pageSize?: string,
|
||||
) {
|
||||
return this.phoneFrequency.listHits({
|
||||
tenantId,
|
||||
applicationId,
|
||||
phoneNumber,
|
||||
status,
|
||||
createdAtFrom,
|
||||
createdAtTo,
|
||||
page: Number(page ?? 1),
|
||||
pageSize: Number(pageSize ?? 20),
|
||||
});
|
||||
}
|
||||
|
||||
@Post('phone-frequency-hits/:id/release')
|
||||
releasePhoneFrequencyHit(
|
||||
@Param('id') hitId: string,
|
||||
@Body() body: { reason?: string },
|
||||
@CurrentSessionUserId() reviewerId?: string,
|
||||
) {
|
||||
return this.phoneFrequency.releaseHit(hitId, reviewerId, body.reason);
|
||||
}
|
||||
|
||||
@Get('phone-frequency-whitelist')
|
||||
listPhoneFrequencyWhitelist(
|
||||
@Query('phoneNumber') phoneNumber?: string,
|
||||
@Query('keyword') keyword?: string,
|
||||
@Query('status') status?: 'active' | 'inactive' | 'deleted',
|
||||
@Query('updatedAtFrom') updatedAtFrom?: string,
|
||||
@Query('updatedAtTo') updatedAtTo?: string,
|
||||
@Query('page') page?: string,
|
||||
@Query('pageSize') pageSize?: string,
|
||||
) {
|
||||
return this.phoneFrequency.listWhitelist({
|
||||
phoneNumber,
|
||||
keyword,
|
||||
status,
|
||||
updatedAtFrom,
|
||||
updatedAtTo,
|
||||
page: Number(page ?? 1),
|
||||
pageSize: Number(pageSize ?? 20),
|
||||
});
|
||||
}
|
||||
|
||||
@Post('phone-frequency-whitelist')
|
||||
createPhoneFrequencyWhitelist(
|
||||
@Body() body: CreatePhoneFrequencyWhitelistDto,
|
||||
@CurrentSessionUserId() operatorId?: string,
|
||||
) {
|
||||
return this.phoneFrequency.createWhitelist(body, operatorId);
|
||||
}
|
||||
|
||||
@Put('phone-frequency-whitelist/:id')
|
||||
updatePhoneFrequencyWhitelist(
|
||||
@Param('id') id: string,
|
||||
@Body() body: UpdatePhoneFrequencyWhitelistDto,
|
||||
@CurrentSessionUserId() operatorId?: string,
|
||||
) {
|
||||
return this.phoneFrequency.updateWhitelist(id, body, operatorId);
|
||||
}
|
||||
|
||||
@Delete('phone-frequency-whitelist/:id')
|
||||
deletePhoneFrequencyWhitelist(
|
||||
@Param('id') id: string,
|
||||
@Body() body: { reason?: string },
|
||||
@CurrentSessionUserId() operatorId?: string,
|
||||
) {
|
||||
return this.phoneFrequency.deleteWhitelist(id, operatorId, body.reason);
|
||||
}
|
||||
|
||||
@Get('tasks')
|
||||
listTasks(@Query('tenantId') tenantId?: string, @Query('status') status?: string) {
|
||||
return this.riskReview.listTasks(tenantId, status);
|
||||
|
||||
Reference in New Issue
Block a user