Showing
1 changed file
with
4 additions
and
16 deletions
| ... | @@ -114,15 +114,6 @@ export class PostService { | ... | @@ -114,15 +114,6 @@ export class PostService { |
| 114 | return returndata; | 114 | return returndata; |
| 115 | } | 115 | } |
| 116 | 116 | ||
| 117 | - async getPostLike(id: number) { | ||
| 118 | - const likes = await this.prisma.postLike.count({ | ||
| 119 | - where: { | ||
| 120 | - postId: id, | ||
| 121 | - }, | ||
| 122 | - }); | ||
| 123 | - return likes; | ||
| 124 | - } | ||
| 125 | - | ||
| 126 | async getPostbyLevel(difficulty: number) { | 117 | async getPostbyLevel(difficulty: number) { |
| 127 | let level: Level; | 118 | let level: Level; |
| 128 | if (difficulty == 1) { | 119 | if (difficulty == 1) { |
| ... | @@ -197,16 +188,13 @@ export class PostService { | ... | @@ -197,16 +188,13 @@ export class PostService { |
| 197 | userId: user.id, | 188 | userId: user.id, |
| 198 | }, | 189 | }, |
| 199 | }) | 190 | }) |
| 200 | - ) { | 191 | + ) |
| 201 | - return { | 192 | + return this.getPost(id); |
| 202 | - message: 'You already liked this post', | ||
| 203 | - }; | ||
| 204 | - } | ||
| 205 | const post = await this.prisma.postLike.create({ | 193 | const post = await this.prisma.postLike.create({ |
| 206 | data: { | 194 | data: { |
| 207 | post: { | 195 | post: { |
| 208 | connect: { | 196 | connect: { |
| 209 | - id: id, | 197 | + id: num, |
| 210 | }, | 198 | }, |
| 211 | }, | 199 | }, |
| 212 | user: { | 200 | user: { |
| ... | @@ -216,7 +204,7 @@ export class PostService { | ... | @@ -216,7 +204,7 @@ export class PostService { |
| 216 | }, | 204 | }, |
| 217 | }, | 205 | }, |
| 218 | }); | 206 | }); |
| 219 | - return await this.getPostLike(id); | 207 | + return this.getPost(id); |
| 220 | } | 208 | } |
| 221 | 209 | ||
| 222 | async commentPost(token: string, id: number, content: string) { | 210 | async commentPost(token: string, id: number, content: string) { | ... | ... |
-
Please register or login to post a comment