|
@@ -6,6 +6,7 @@ import {
|
|
Post,
|
|
Post,
|
|
Body,
|
|
Body,
|
|
Headers,
|
|
Headers,
|
|
|
|
+ Delete,
|
|
} from '@nestjs/common';
|
|
} from '@nestjs/common';
|
|
import { AuthService } from 'src/auth/auth.service';
|
|
import { AuthService } from 'src/auth/auth.service';
|
|
import { DatasourceService } from 'src/datasource/datasource.service';
|
|
import { DatasourceService } from 'src/datasource/datasource.service';
|
|
@@ -14,6 +15,8 @@ interface PostBody {
|
|
title: string;
|
|
title: string;
|
|
content: string;
|
|
content: string;
|
|
tags: string[];
|
|
tags: string[];
|
|
|
|
+ cate: string;
|
|
|
|
+ description?: string;
|
|
}
|
|
}
|
|
|
|
|
|
@Controller('post')
|
|
@Controller('post')
|
|
@@ -45,6 +48,8 @@ export class PostController {
|
|
title: true,
|
|
title: true,
|
|
createdAt: true,
|
|
createdAt: true,
|
|
updatedAt: true,
|
|
updatedAt: true,
|
|
|
|
+ cate: true,
|
|
|
|
+ descirption: true,
|
|
tags: {
|
|
tags: {
|
|
select: {
|
|
select: {
|
|
name: true,
|
|
name: true,
|
|
@@ -73,6 +78,8 @@ export class PostController {
|
|
content: true,
|
|
content: true,
|
|
createdAt: true,
|
|
createdAt: true,
|
|
updatedAt: true,
|
|
updatedAt: true,
|
|
|
|
+ cate: true,
|
|
|
|
+ descirption: true,
|
|
tags: {
|
|
tags: {
|
|
select: {
|
|
select: {
|
|
name: true,
|
|
name: true,
|
|
@@ -110,6 +117,8 @@ export class PostController {
|
|
data: {
|
|
data: {
|
|
title: body.title,
|
|
title: body.title,
|
|
content: body.content,
|
|
content: body.content,
|
|
|
|
+ cate: body.cate,
|
|
|
|
+ descirption: body.description ?? '',
|
|
tags: {
|
|
tags: {
|
|
connectOrCreate: body.tags.map((tag) => ({
|
|
connectOrCreate: body.tags.map((tag) => ({
|
|
where: { name: tag },
|
|
where: { name: tag },
|
|
@@ -150,6 +159,8 @@ export class PostController {
|
|
data: {
|
|
data: {
|
|
title: body.title,
|
|
title: body.title,
|
|
content: body.content,
|
|
content: body.content,
|
|
|
|
+ cate: body.cate,
|
|
|
|
+ descirption: body.description ?? '',
|
|
tags: {
|
|
tags: {
|
|
set: [],
|
|
set: [],
|
|
connectOrCreate: body.tags.map((tag) => ({
|
|
connectOrCreate: body.tags.map((tag) => ({
|
|
@@ -169,7 +180,7 @@ export class PostController {
|
|
}));
|
|
}));
|
|
}
|
|
}
|
|
|
|
|
|
- @Post('delete/:id')
|
|
|
|
|
|
+ @Delete('delete/:id')
|
|
async deletePost(
|
|
async deletePost(
|
|
@Param('id') id: string,
|
|
@Param('id') id: string,
|
|
@Headers('Authorization') token: string,
|
|
@Headers('Authorization') token: string,
|