File size: 3,207 Bytes
675f6bd | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 | import { Controller, Get, Put, Body, Param, Query, UseGuards } from '@nestjs/common';
import { JwtAuthGuard } from '../common/guards/jwt-auth.guard';
import { RolesGuard } from '../common/guards/roles.guard';
import { Roles } from '../common/decorators/roles.decorator';
import { CurrentUser } from '../common/decorators/current-user.decorator';
import { ApiBearerAuth, ApiOperation, ApiTags } from '@nestjs/swagger';
import { AdminService } from './admin.service';
import { ResolveDisputeDto } from './dto/resolve-dispute.dto';
type ActorUser = { id: string };
@ApiTags('Admin')
@ApiBearerAuth()
@Controller('admin')
@UseGuards(JwtAuthGuard, RolesGuard)
@Roles('ADMIN')
export class AdminController {
constructor(private readonly adminService: AdminService) {}
@Put('projects/:id/suspend-spec')
@ApiOperation({ summary: 'Emergency pull-back of a published project spec' })
async suspendSpec(@Param('id') id: string) {
return this.adminService.suspendSpec(id);
}
@Put('users/:id/suspend')
@ApiOperation({ summary: 'Suspend a fraudulent or abusive account' })
async suspendUser(@Param('id') id: string) {
return this.adminService.suspendUser(id);
}
@Get('disputes')
@ApiOperation({ summary: 'Disputes queue, optionally filtered by state' })
async getDisputesQueue(@CurrentUser() user: ActorUser, @Query('state') state?: string) {
return this.adminService.getDisputesQueue(user.id, state);
}
@Put('disputes/:id/resolve')
@ApiOperation({ summary: 'Manually resolve an escalated dispute' })
async resolveDispute(
@Param('id') id: string,
@Body() dto: ResolveDisputeDto,
@CurrentUser() user: ActorUser,
) {
return this.adminService.resolveDispute(id, dto, user.id);
}
@Get('decisions')
@ApiOperation({ summary: 'Platform decisions log (LLM confidence, advisory notes, entity refs)' })
async getDecisions(
@Query('decisionType') decisionType?: string,
@Query('entityType') entityType?: string,
) {
return this.adminService.getDecisions({ decisionType, entityType });
}
@Get('transactions')
@ApiOperation({ summary: 'Wallet transaction ledger, filterable by type/user' })
async getTransactions(
@Query('type') type?: string,
@Query('userId') userId?: string,
) {
return this.adminService.getTransactions({ type, userId });
}
@Get('analytics')
@ApiOperation({ summary: 'Platform-wide computed aggregates' })
async getAnalytics() {
return this.adminService.getAnalytics();
}
@Get('withdrawals')
@ApiOperation({ summary: 'Withdrawal requests queue, optionally filtered by status' })
async getWithdrawalsQueue(@Query('status') status?: string) {
return this.adminService.getWithdrawalsQueue(status);
}
@Put('withdrawals/:id/complete')
@ApiOperation({ summary: 'Manually confirm a withdrawal was sent (no real Chi Hộ callback exists)' })
async completeWithdrawal(@Param('id') id: string) {
return this.adminService.completeWithdrawal(id);
}
@Put('withdrawals/:id/fail')
@ApiOperation({ summary: 'Mark a withdrawal as failed — refunds the wallet' })
async failWithdrawal(@Param('id') id: string) {
return this.adminService.failWithdrawal(id);
}
} |