|
@@ -1,6 +1,7 @@
|
|
import { AuthService } from '@/auth/auth.service'
|
|
import { AuthService } from '@/auth/auth.service'
|
|
import { PrismaService } from '@/prisma/prisma.service'
|
|
import { PrismaService } from '@/prisma/prisma.service'
|
|
import { RedisService } from '@/redis/redis.service'
|
|
import { RedisService } from '@/redis/redis.service'
|
|
|
|
+import { UserinfoService } from '@/userinfo/userinfo.service'
|
|
import { BadGatewayException, BadRequestException, HttpException, Injectable } from '@nestjs/common'
|
|
import { BadGatewayException, BadRequestException, HttpException, Injectable } from '@nestjs/common'
|
|
|
|
|
|
@Injectable()
|
|
@Injectable()
|
|
@@ -9,6 +10,7 @@ export class PostService {
|
|
private readonly prisma: PrismaService,
|
|
private readonly prisma: PrismaService,
|
|
private readonly redis: RedisService,
|
|
private readonly redis: RedisService,
|
|
private readonly auth: AuthService,
|
|
private readonly auth: AuthService,
|
|
|
|
+ private readonly userinfo: UserinfoService,
|
|
) {}
|
|
) {}
|
|
async post(authId: number, plateid: number = 0, { title, content }) {
|
|
async post(authId: number, plateid: number = 0, { title, content }) {
|
|
const res = await this.prisma.post.create({
|
|
const res = await this.prisma.post.create({
|
|
@@ -20,6 +22,11 @@ export class PostService {
|
|
},
|
|
},
|
|
select: { id: true },
|
|
select: { id: true },
|
|
})
|
|
})
|
|
|
|
+ this.userinfo.updateinfo(authId, {
|
|
|
|
+ exp: 1,
|
|
|
|
+ mapleCoin: 1,
|
|
|
|
+ level: 0,
|
|
|
|
+ })
|
|
return { code: 200, message: '发帖成功', data: res }
|
|
return { code: 200, message: '发帖成功', data: res }
|
|
}
|
|
}
|
|
async updated(userId: number, postid: number, { title, content, plateId }) {
|
|
async updated(userId: number, postid: number, { title, content, plateId }) {
|
|
@@ -93,15 +100,13 @@ export class PostService {
|
|
const data = await this.prisma.post.findMany({
|
|
const data = await this.prisma.post.findMany({
|
|
skip: (page - 1) * limit,
|
|
skip: (page - 1) * limit,
|
|
take: limit,
|
|
take: limit,
|
|
- where: {
|
|
|
|
- isTop: Number(isTop),
|
|
|
|
- },
|
|
|
|
select: {
|
|
select: {
|
|
id: true,
|
|
id: true,
|
|
title: true,
|
|
title: true,
|
|
content: true,
|
|
content: true,
|
|
authorId: true,
|
|
authorId: true,
|
|
updatedAt: true,
|
|
updatedAt: true,
|
|
|
|
+ isTop: true,
|
|
views: true,
|
|
views: true,
|
|
},
|
|
},
|
|
})
|
|
})
|