generated from fahricansecer/boilerplate-be
This commit is contained in:
@@ -316,9 +316,68 @@ export class AdminController {
|
||||
await this.prisma.rolePermission.deleteMany({
|
||||
where: { roleId, permissionId },
|
||||
});
|
||||
// Invalidate roles_list because permissions are nested in roles
|
||||
await this.cacheManager.del('roles_list');
|
||||
return createSuccessResponse(null, 'Permission removed from role');
|
||||
}
|
||||
|
||||
// ================== Project Management (Admin) ==================
|
||||
|
||||
@Get('projects')
|
||||
@ApiOperation({ summary: 'Tüm projeleri getir (admin)' })
|
||||
async getAllProjects(
|
||||
@Query() query: { page?: number; limit?: number; status?: string; userId?: string },
|
||||
): Promise<ApiResponse<any>> {
|
||||
const result = await this.adminService.getAllProjects({
|
||||
page: query.page ? Number(query.page) : 1,
|
||||
limit: query.limit ? Number(query.limit) : 20,
|
||||
status: query.status,
|
||||
userId: query.userId,
|
||||
});
|
||||
return createSuccessResponse(result);
|
||||
}
|
||||
|
||||
@Delete('projects/:id')
|
||||
@ApiOperation({ summary: 'Projeyi sil (soft delete)' })
|
||||
async adminDeleteProject(@Param('id') id: string): Promise<ApiResponse<any>> {
|
||||
const result = await this.adminService.adminDeleteProject(id);
|
||||
return createSuccessResponse(result, 'Proje silindi');
|
||||
}
|
||||
|
||||
// ================== Render Job Management (Admin) ==================
|
||||
|
||||
@Get('render-jobs')
|
||||
@ApiOperation({ summary: 'Tüm render jobları getir (admin)' })
|
||||
async getAllRenderJobs(
|
||||
@Query() query: { page?: number; limit?: number; status?: string },
|
||||
): Promise<ApiResponse<any>> {
|
||||
const result = await this.adminService.getAllRenderJobs({
|
||||
page: query.page ? Number(query.page) : 1,
|
||||
limit: query.limit ? Number(query.limit) : 20,
|
||||
status: query.status,
|
||||
});
|
||||
return createSuccessResponse(result);
|
||||
}
|
||||
|
||||
// ================== Ban / Activate User ==================
|
||||
|
||||
@Put('users/:id/ban')
|
||||
@ApiOperation({ summary: 'Kullanıcıyı banla' })
|
||||
async banUser(@Param('id') id: string): Promise<ApiResponse<any>> {
|
||||
const user = await this.adminService.setUserActive(id, false);
|
||||
return createSuccessResponse(
|
||||
plainToInstance(UserResponseDto, user),
|
||||
'Kullanıcı banlandı',
|
||||
);
|
||||
}
|
||||
|
||||
@Put('users/:id/activate')
|
||||
@ApiOperation({ summary: 'Kullanıcıyı aktif et' })
|
||||
async activateUser(@Param('id') id: string): Promise<ApiResponse<any>> {
|
||||
const user = await this.adminService.setUserActive(id, true);
|
||||
return createSuccessResponse(
|
||||
plainToInstance(UserResponseDto, user),
|
||||
'Kullanıcı aktif edildi',
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user