lint
This commit is contained in:
@@ -22,7 +22,7 @@ export class BlogController {
|
|||||||
constructor(
|
constructor(
|
||||||
private readonly blogService: BlogService,
|
private readonly blogService: BlogService,
|
||||||
private readonly userService: UserService,
|
private readonly userService: UserService,
|
||||||
) { }
|
) {}
|
||||||
|
|
||||||
@Get()
|
@Get()
|
||||||
getBlogs() {
|
getBlogs() {
|
||||||
@@ -73,7 +73,10 @@ export class BlogController {
|
|||||||
|
|
||||||
/** @todo 对文章可读性进行更详细的判定 */
|
/** @todo 对文章可读性进行更详细的判定 */
|
||||||
|
|
||||||
if (!blog.permissions.includes(BlogPermission.Public) && !blog.permissions.includes(BlogPermission.ByPassword)) {
|
if (
|
||||||
|
!blog.permissions.includes(BlogPermission.Public) &&
|
||||||
|
!blog.permissions.includes(BlogPermission.ByPassword)
|
||||||
|
) {
|
||||||
throw new BadRequestException('文章不存在或未公开');
|
throw new BadRequestException('文章不存在或未公开');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ export class BlogService {
|
|||||||
private readonly blogRepository: Repository<Blog>,
|
private readonly blogRepository: Repository<Blog>,
|
||||||
@InjectRepository(BlogComment)
|
@InjectRepository(BlogComment)
|
||||||
private readonly blogCommentRepository: Repository<BlogComment>,
|
private readonly blogCommentRepository: Repository<BlogComment>,
|
||||||
) { }
|
) {}
|
||||||
|
|
||||||
async list(
|
async list(
|
||||||
option: {
|
option: {
|
||||||
@@ -104,30 +104,36 @@ export class BlogService {
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
return comments.map(comment => {
|
return comments.map((comment) => {
|
||||||
const { blog, user, ...rest } = comment;
|
const { user, ...rest } = comment;
|
||||||
|
delete rest.blog;
|
||||||
return {
|
return {
|
||||||
...rest,
|
...rest,
|
||||||
user: user ? {
|
user: user
|
||||||
|
? {
|
||||||
userId: user.userId,
|
userId: user.userId,
|
||||||
username: user.username,
|
username: user.username,
|
||||||
nickname: user.nickname,
|
nickname: user.nickname,
|
||||||
} : null,
|
|
||||||
}
|
}
|
||||||
})
|
: null,
|
||||||
|
};
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
async createComment(comment: Partial<BlogComment>) {
|
async createComment(comment: Partial<BlogComment>) {
|
||||||
const newComment = this.blogCommentRepository.create(comment);
|
const newComment = this.blogCommentRepository.create(comment);
|
||||||
const savedComment = await this.blogCommentRepository.save(newComment, {});
|
const savedComment = await this.blogCommentRepository.save(newComment, {});
|
||||||
const { blog, user, ...commentWithoutBlog } = savedComment;
|
const { user, ...commentWithoutBlog } = savedComment;
|
||||||
|
delete commentWithoutBlog.blog;
|
||||||
return {
|
return {
|
||||||
...commentWithoutBlog,
|
...commentWithoutBlog,
|
||||||
user: user ? {
|
user: user
|
||||||
|
? {
|
||||||
userId: user.userId,
|
userId: user.userId,
|
||||||
username: user.username,
|
username: user.username,
|
||||||
nickname: user.nickname,
|
nickname: user.nickname,
|
||||||
} : null,
|
}
|
||||||
|
: null,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
import { useOssSts } from "@/hooks/oss/use-oss-sts";
|
import { useOssSts } from "@/hooks/oss/use-oss-sts";
|
||||||
import { StsToken } from "@/lib/api/oss";
|
import { StsToken } from "@/lib/api/oss";
|
||||||
import OSS from "ali-oss";
|
|
||||||
import { useEffect } from "react";
|
import { useEffect } from "react";
|
||||||
|
|
||||||
export function useOssStore(options: { onStsTokenDataChanged?: (data: StsToken | undefined) => void; } = {}) {
|
export function useOssStore(options: { onStsTokenDataChanged?: (data: StsToken | undefined) => void; } = {}) {
|
||||||
@@ -10,7 +9,6 @@ export function useOssStore(options: { onStsTokenDataChanged?: (data: StsToken |
|
|||||||
options.onStsTokenDataChanged?.(stsTokenData);
|
options.onStsTokenDataChanged?.(stsTokenData);
|
||||||
}, [stsTokenData]);
|
}, [stsTokenData]);
|
||||||
|
|
||||||
/** @todo */
|
|
||||||
const refresh = async () => {
|
const refresh = async () => {
|
||||||
await mutate();
|
await mutate();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user