chore: add update and delete for services and category and ads

This commit is contained in:
mahyargdz
2025-03-04 12:41:27 +03:30
parent 98734aee9d
commit ea184c643b
9 changed files with 144 additions and 31 deletions
@@ -1,4 +1,4 @@
import { Body, Controller, Get, HttpCode, HttpStatus, Param, Patch, Post, Query } from "@nestjs/common";
import { Body, Controller, Delete, Get, HttpCode, HttpStatus, Param, Patch, Post, Query } from "@nestjs/common";
import { ApiOperation, ApiTags } from "@nestjs/swagger";
import { AddReviewDto } from "./DTO/add-review.dto";
@@ -7,7 +7,9 @@ import { CreateCategoryDto } from "./DTO/create-category.dto";
import { CreateServiceDto } from "./DTO/create-service.dto";
import { DanakServiceReviewQueryDto } from "./DTO/danak-service-review-query.dto";
import { DanakServicesQueryDto, DanakServicesSearchQueryDto } from "./DTO/danak-services-search-query.dto";
import { UpdateCategoryDto } from "./DTO/update-category.dto";
import { UpdateReviewStatusDto } from "./DTO/update-review-status.dto";
import { UpdateServiceDto } from "./DTO/update-service.dto";
import { DanakServicesService } from "./providers/danak-services.service";
import { AuthGuards } from "../../common/decorators/auth-guard.decorator";
import { Pagination } from "../../common/decorators/pagination.decorator";
@@ -54,12 +56,21 @@ export class DanakServicesController {
return this.danakServicesService.getCategoriesUserSide();
}
// @AuthGuards()
// @ApiOperation({ summary: "get category services with category id" })
// @Get("categories/:id/services")
// getCategoryServices(@Param() paramDto: ParamDto) {
// return this.danakServicesService.getCategoryServices(paramDto.id);
// }
@AuthGuards()
@PermissionsDec(PermissionEnum.SERVICES)
@ApiOperation({ summary: "update category by id => admin route" })
@Patch("categories/:id")
updateCategory(@Param() paramDto: ParamDto, @Body() updateDto: UpdateCategoryDto) {
return this.danakServicesService.updateCategory(paramDto.id, updateDto);
}
@AuthGuards()
@PermissionsDec(PermissionEnum.SERVICES)
@ApiOperation({ summary: "delete category by id => admin route" })
@Delete("categories/:id")
deleteCategoryById(@Param() paramDto: ParamDto) {
return this.danakServicesService.deleteCategoryById(paramDto.id);
}
@AuthGuards()
@PermissionsDec(PermissionEnum.SERVICES)
@@ -116,6 +127,22 @@ export class DanakServicesController {
return this.danakServicesService.getDanakServiceByIdWithSubs(paramDto.id, isAdmin, userId);
}
@ApiOperation({ summary: "update danak service" })
@AuthGuards()
@PermissionsDec(PermissionEnum.SERVICES)
@Patch(":id")
updateDanakService(@Param() paramDto: ParamDto, @Body() updateDto: UpdateServiceDto) {
return this.danakServicesService.updateDanakService(paramDto.id, updateDto);
}
@ApiOperation({ summary: "delete danak service" })
@AuthGuards()
@PermissionsDec(PermissionEnum.SERVICES)
@Delete(":id")
deleteServiceById(@Param() paramDto: ParamDto) {
return this.danakServicesService.deleteServiceById(paramDto.id);
}
@ApiOperation({ summary: "get service users" })
@AuthGuards()
@PermissionsDec(PermissionEnum.SERVICES)