feat:增加批量删除、软删除和软删除恢复
- 完成基础的软删除 - 完成树形数据的软删除(children未处理)
This commit is contained in:
@@ -11,8 +11,14 @@ import {
|
||||
SerializeOptions,
|
||||
} from '@nestjs/common';
|
||||
|
||||
import { CreateCategoryDto, QueryCategoryDto, UpdateCategoryDto } from '@/modules/content/dtos';
|
||||
import {
|
||||
CreateCategoryDto,
|
||||
QueryCategoryDto,
|
||||
QueryCategoryTreeDto,
|
||||
UpdateCategoryDto,
|
||||
} from '@/modules/content/dtos';
|
||||
import { CategoryService } from '@/modules/content/services';
|
||||
import { DeleteWithTrashDto, RestoreDto } from '@/modules/restful/dtos';
|
||||
|
||||
@Controller('categories')
|
||||
export class CategoryController {
|
||||
@@ -20,8 +26,8 @@ export class CategoryController {
|
||||
|
||||
@Get('tree')
|
||||
@SerializeOptions({ groups: ['category-tree'] })
|
||||
async tree() {
|
||||
return this.service.findTress();
|
||||
async tree(@Query() options: QueryCategoryTreeDto) {
|
||||
return this.service.findTrees(options);
|
||||
}
|
||||
|
||||
@Get()
|
||||
@@ -57,9 +63,19 @@ export class CategoryController {
|
||||
return this.service.update(data);
|
||||
}
|
||||
|
||||
@Delete(':id')
|
||||
@Delete()
|
||||
@SerializeOptions({ groups: ['category-detail'] })
|
||||
async delete(@Param('id', new ParseUUIDPipe()) id: string) {
|
||||
return this.service.delete(id);
|
||||
async delete(@Body() data: DeleteWithTrashDto) {
|
||||
const { ids, trash } = data;
|
||||
|
||||
return this.service.delete(ids, trash);
|
||||
}
|
||||
|
||||
@Patch('restore')
|
||||
@SerializeOptions({ groups: ['category-detail'] })
|
||||
async restore(@Body() data: RestoreDto) {
|
||||
const { ids } = data;
|
||||
|
||||
return this.service.restore(ids);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,17 +1,8 @@
|
||||
import {
|
||||
Body,
|
||||
Controller,
|
||||
Delete,
|
||||
Get,
|
||||
Param,
|
||||
ParseUUIDPipe,
|
||||
Post,
|
||||
Query,
|
||||
SerializeOptions,
|
||||
} from '@nestjs/common';
|
||||
import { Body, Controller, Delete, Get, Post, Query, SerializeOptions } from '@nestjs/common';
|
||||
|
||||
import { CreateCommentDto, QueryCommentDto, QueryCommentTreeDto } from '@/modules/content/dtos';
|
||||
import { CommentService } from '@/modules/content/services';
|
||||
import { DeleteDto } from '@/modules/restful/dtos';
|
||||
|
||||
@Controller('comments')
|
||||
export class CommentController {
|
||||
@@ -44,9 +35,10 @@ export class CommentController {
|
||||
return this.service.create(data);
|
||||
}
|
||||
|
||||
@Delete(':id')
|
||||
@Delete()
|
||||
@SerializeOptions({ groups: ['comment-detail'] })
|
||||
async delete(@Param('id', new ParseUUIDPipe()) id: string) {
|
||||
return this.service.delete(id);
|
||||
async delete(@Body() data: DeleteDto) {
|
||||
const { ids } = data;
|
||||
return this.service.delete(ids);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,6 +13,7 @@ import {
|
||||
|
||||
import { CreatePostDto, QueryPostDto, UpdatePostDto } from '@/modules/content/dtos';
|
||||
import { PostService } from '@/modules/content/services';
|
||||
import { DeleteDto, DeleteWithTrashDto } from '@/modules/restful/dtos';
|
||||
|
||||
/**
|
||||
* 文章控制器
|
||||
@@ -56,9 +57,19 @@ export class PostController {
|
||||
return this.postService.update(data);
|
||||
}
|
||||
|
||||
@Delete(':id')
|
||||
@Delete()
|
||||
@SerializeOptions({ groups: ['post-detail'] })
|
||||
async delete(@Param('id', new ParseUUIDPipe()) id: string) {
|
||||
return this.postService.delete(id);
|
||||
async delete(@Body() data: DeleteWithTrashDto) {
|
||||
const { ids, trash } = data;
|
||||
|
||||
return this.postService.delete(ids, trash);
|
||||
}
|
||||
|
||||
@Patch('restore')
|
||||
@SerializeOptions({ groups: ['post-detail'] })
|
||||
async restore(@Body() data: DeleteDto) {
|
||||
const { ids } = data;
|
||||
|
||||
return this.postService.restore(ids);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,8 +11,9 @@ import {
|
||||
SerializeOptions,
|
||||
} from '@nestjs/common';
|
||||
|
||||
import { CreateTagDto, QueryCategoryDto, UpdateTagDto } from '@/modules/content/dtos';
|
||||
import { CreateTagDto, QueryTagsDto, UpdateTagDto } from '@/modules/content/dtos';
|
||||
import { TagService } from '@/modules/content/services';
|
||||
import { DeleteDto, DeleteWithTrashDto } from '@/modules/restful/dtos';
|
||||
|
||||
@Controller('tags')
|
||||
export class TagController {
|
||||
@@ -22,7 +23,7 @@ export class TagController {
|
||||
@SerializeOptions({})
|
||||
async list(
|
||||
@Query()
|
||||
options: QueryCategoryDto,
|
||||
options: QueryTagsDto,
|
||||
) {
|
||||
return this.service.paginate(options);
|
||||
}
|
||||
@@ -54,9 +55,19 @@ export class TagController {
|
||||
return this.service.update(data);
|
||||
}
|
||||
|
||||
@Delete(':id')
|
||||
@SerializeOptions({})
|
||||
async delete(@Param('id', new ParseUUIDPipe()) id: string) {
|
||||
return this.service.delete(id);
|
||||
@Delete()
|
||||
@SerializeOptions({ groups: ['post-list'] })
|
||||
async delete(@Body() data: DeleteWithTrashDto) {
|
||||
const { ids, trash } = data;
|
||||
|
||||
return this.service.delete(ids, trash);
|
||||
}
|
||||
|
||||
@Patch('restore')
|
||||
@SerializeOptions({ groups: ['post-list'] })
|
||||
async restore(@Body() data: DeleteDto) {
|
||||
const { ids } = data;
|
||||
|
||||
return this.service.restore(ids);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user