chore: add update and delete of learning and learnign category

This commit is contained in:
mahyargdz
2025-03-04 15:18:02 +03:30
parent 3db3a1de99
commit 1b1c532488
10 changed files with 157 additions and 99 deletions
+36 -33
View File
@@ -1,8 +1,9 @@
import { Body, Controller, Get, Param, Post } from "@nestjs/common";
import { Body, Controller, Delete, Get, Param, Patch, Post } from "@nestjs/common";
import { ApiOperation, ApiTags } from "@nestjs/swagger";
import { CreateLearningCategoryDto } from "./DTO/create-learning-category.dto";
import { CreateLearningDto } from "./DTO/create-learning.dto";
import { UpdateLearningCategoryDto } from "./DTO/update-learning-category.dto";
import { LearningService } from "./providers/learning.service";
import { AuthGuards } from "../../common/decorators/auth-guard.decorator";
import { PermissionsDec } from "../../common/decorators/permission.decorator";
@@ -15,16 +16,26 @@ import { PermissionEnum } from "../users/enums/permission.enum";
export class LearningController {
constructor(private readonly learningService: LearningService) {}
//************************ */
@ApiOperation({ summary: "Create learning" })
@ApiOperation({ summary: "Create learning video" })
@PermissionsDec(PermissionEnum.LEARNINGS)
@Post()
create(@Body() createDto: CreateLearningDto) {
return this.learningService.createLearning(createDto);
createLearningVideo(@Body() createDto: CreateLearningDto) {
return this.learningService.createLearningVideo(createDto);
}
//************************ */
@ApiOperation({ summary: "find learnings video" })
@Get()
findAllLearnings() {
return this.learningService.findLearningsVideos();
}
@ApiOperation({ summary: "find learning video by id" })
@Get(":id")
findLearningVideoById(@Param() paramDto: ParamDto) {
return this.learningService.findLearningVideoById(paramDto.id);
}
//----------------- category management ----------------------
@ApiOperation({ summary: "Create learning category" })
@PermissionsDec(PermissionEnum.LEARNINGS)
@@ -33,37 +44,29 @@ export class LearningController {
return this.learningService.createLearningCategory(createDto);
}
//************************ */
@ApiOperation({ summary: "find all learnings" })
@Get()
findAllLearnings() {
return this.learningService.findAllLearnings();
}
//************************ */
@ApiOperation({ summary: "find one learning by id" })
@Get(":id")
findOneLearning(@Param() paramDto: ParamDto) {
return this.learningService.findOneLearning(paramDto.id);
}
//************************ */
@ApiOperation({ summary: "find all learning category" })
@ApiOperation({ summary: "find learning categories" })
@Get("category")
findAllCategories() {
return this.learningService.findAllCategories();
findCategories() {
return this.learningService.findCategories();
}
//************************ */
@ApiOperation({ summary: "find one learning category by id" })
@Get("category/:id")
findOneCategory(@Param() paramDto: ParamDto) {
return this.learningService.findOneCategory(paramDto.id);
findCategoryById(@Param() paramDto: ParamDto) {
return this.learningService.findCategoryById(paramDto.id);
}
//************************ */
@ApiOperation({ summary: "update learning category ==> admin route" })
@PermissionsDec(PermissionEnum.LEARNINGS)
@Patch("category/:id")
updateLearningCategory(@Param() paramDto: ParamDto, @Body() updateDto: UpdateLearningCategoryDto) {
return this.learningService.updateLearningCategory(paramDto.id, updateDto);
}
@ApiOperation({ summary: "delete category by id" })
@PermissionsDec(PermissionEnum.LEARNINGS)
@Delete("category/:id")
deleteCategoryById(@Param() paramDto: ParamDto) {
return this.learningService.deleteCategoryById(paramDto.id);
}
}