generated from fahricansecer/boilerplate-be
This commit is contained in:
@@ -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');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user