main
Some checks failed
Backend Deploy 🚀 / build-and-deploy (push) Has been cancelled

This commit is contained in:
Harun CAN
2026-03-30 00:21:32 +03:00
parent 85c35c73e8
commit acb103657b
29 changed files with 11473 additions and 13081 deletions

View File

@@ -35,6 +35,7 @@ import {
RoleResponseDto,
UserRoleResponseDto,
} from './dto/admin.dto';
import { AdminService } from './admin.service';
@ApiTags('Admin')
@ApiBearerAuth()
@@ -43,9 +44,61 @@ import {
export class AdminController {
constructor(
private readonly prisma: PrismaService,
private readonly adminService: AdminService,
@Inject(CACHE_MANAGER) private cacheManager: cacheManager.Cache,
) {}
// ================== System Stats ==================
@Get('stats')
@ApiOperation({ summary: 'Sistem istatistiklerini getir' })
async getSystemStats(): Promise<ApiResponse<any>> {
const stats = await this.adminService.getSystemStats();
return createSuccessResponse(stats);
}
// ================== Plan Management ==================
@Get('plans')
@ApiOperation({ summary: 'Tüm planları getir (admin detay)' })
async getAllPlans(): Promise<ApiResponse<any>> {
const plans = await this.adminService.getAllPlans();
return createSuccessResponse(plans);
}
@Put('plans/:id')
@ApiOperation({ summary: 'Plan güncelle' })
async updatePlan(
@Param('id') id: string,
@Body() data: any,
): Promise<ApiResponse<any>> {
const plan = await this.adminService.updatePlan(id, data);
return createSuccessResponse(plan, 'Plan güncellendi');
}
// ================== Credit Management ==================
@Post('users/:userId/credits')
@ApiOperation({ summary: 'Kullanıcıya kredi ver' })
async grantCredits(
@Param('userId') userId: string,
@Body() data: { amount: number; description: string },
): Promise<ApiResponse<any>> {
const tx = await this.adminService.grantCredits(userId, data.amount, data.description);
return createSuccessResponse(tx, 'Kredi yüklendi');
}
// ================== User Detail ==================
@Get('users/:id/detail')
@ApiOperation({ summary: 'Kullanıcı detay — abonelik, projeler, krediler' })
async getUserDetail(
@Param('id') id: string,
): Promise<ApiResponse<any>> {
const user = await this.adminService.getUserDetail(id);
return createSuccessResponse(user);
}
// ================== Users Management ==================
@Get('users')
@@ -268,3 +321,4 @@ export class AdminController {
return createSuccessResponse(null, 'Permission removed from role');
}
}