add test case
This commit is contained in:
@@ -11,4 +11,5 @@ export const database = (): TypeOrmModuleOptions => ({
|
||||
database: '3r',
|
||||
synchronize: true,
|
||||
autoLoadEntities: true,
|
||||
timezone: '+08:00',
|
||||
});
|
||||
|
||||
@@ -6,6 +6,7 @@ import {
|
||||
Entity,
|
||||
JoinTable,
|
||||
ManyToMany,
|
||||
ManyToOne,
|
||||
OneToMany,
|
||||
PrimaryColumn,
|
||||
Relation,
|
||||
@@ -67,7 +68,7 @@ export class PostEntity extends BaseEntity {
|
||||
commentCount: number;
|
||||
|
||||
@Expose()
|
||||
@OneToMany(() => CategoryEntity, (category) => category.posts, {
|
||||
@ManyToOne(() => CategoryEntity, (category) => category.posts, {
|
||||
nullable: true,
|
||||
onDelete: 'SET NULL',
|
||||
})
|
||||
|
||||
@@ -10,11 +10,9 @@ import {
|
||||
QueryCommentTreeDto,
|
||||
} from '@/modules/content/dtos/comment.dto';
|
||||
import { CommentEntity } from '@/modules/content/entities/comment.entity';
|
||||
import { CommentRepository, PostRepository } from '@/modules/content/repositories';
|
||||
import { treePaginate } from '@/modules/database/utils';
|
||||
|
||||
import { CommentRepository } from '../repositories/comment.repository';
|
||||
import { PostRepository } from '../repositories/post.repository';
|
||||
|
||||
@Injectable()
|
||||
export class CommentService {
|
||||
constructor(
|
||||
@@ -82,7 +80,7 @@ export class CommentService {
|
||||
}
|
||||
parent = await this.repository.findOne({
|
||||
where: { id },
|
||||
relations: ['parent', 'children'],
|
||||
relations: ['parent', 'children', 'post'],
|
||||
});
|
||||
if (!parent) {
|
||||
throw new EntityNotFoundError(CommentEntity, `Parent Comment ${id} not found`);
|
||||
|
||||
Reference in New Issue
Block a user