hero section added
hero article menagment implemented in admin UI
This commit is contained in:
1 parent
6d65d5975c
commit
add12b2fbf
10 files changed
+604
-217
No files matched your search
@@ -40,6 +40,12 @@ export class ArticlesController {
|
||||
return this.articlesService.findAll(dto);
|
||||
}
|
||||
|
||||
@Get('hero')
|
||||
@Public()
|
||||
findHero() {
|
||||
return this.articlesService.findHeroArticle();
|
||||
}
|
||||
|
||||
@Get(':id')
|
||||
@Public()
|
||||
findOne(@Param('id') id: string) {
|
||||
|
||||
@@ -6,7 +6,6 @@ import {
|
||||
IsUUID,
|
||||
IsNumber,
|
||||
IsBoolean,
|
||||
IsDate,
|
||||
} from 'class-validator';
|
||||
import {
|
||||
ArticleStatus,
|
||||
@@ -48,6 +47,10 @@ export class CreateArticleDto {
|
||||
@IsString()
|
||||
strapiId?: string;
|
||||
|
||||
@IsOptional()
|
||||
@IsBoolean()
|
||||
isHero?: boolean;
|
||||
|
||||
@IsOptional()
|
||||
@IsUUID()
|
||||
authorId?: string;
|
||||
@@ -135,6 +138,10 @@ export class UpdateArticleDto {
|
||||
@IsString()
|
||||
strapiId?: string;
|
||||
|
||||
@IsOptional()
|
||||
@IsBoolean()
|
||||
isHero?: boolean;
|
||||
|
||||
@IsOptional()
|
||||
@IsUUID()
|
||||
authorId?: string;
|
||||
@@ -217,6 +224,35 @@ export class FindArticlesDto {
|
||||
limit?: number;
|
||||
}
|
||||
|
||||
export class FindLiveBlogsDto {
|
||||
@IsOptional()
|
||||
@IsString()
|
||||
category?: string;
|
||||
|
||||
@IsOptional()
|
||||
@IsString()
|
||||
author?: string;
|
||||
|
||||
@IsOptional()
|
||||
@IsString()
|
||||
status?: string;
|
||||
|
||||
@IsOptional()
|
||||
@IsBoolean()
|
||||
isPinned?: boolean;
|
||||
|
||||
@IsOptional()
|
||||
@IsString()
|
||||
search?: string;
|
||||
|
||||
@IsOptional()
|
||||
@IsNumber()
|
||||
page?: number;
|
||||
|
||||
@IsOptional()
|
||||
limit?: number;
|
||||
}
|
||||
|
||||
export class CreateLiveBlogDto {
|
||||
@IsString()
|
||||
title: string;
|
||||
@@ -336,20 +372,16 @@ export class CreateLiveBlogUpdateDto {
|
||||
content: string;
|
||||
|
||||
@IsOptional()
|
||||
@IsBoolean()
|
||||
isPinned?: boolean;
|
||||
|
||||
@IsOptional()
|
||||
@IsUUID()
|
||||
authorId?: string;
|
||||
|
||||
@IsOptional()
|
||||
@IsDate()
|
||||
scheduledAt?: Date;
|
||||
@IsString()
|
||||
image?: string;
|
||||
|
||||
@IsOptional()
|
||||
@IsString()
|
||||
strapiId?: string;
|
||||
videoUrl?: string;
|
||||
|
||||
@IsOptional()
|
||||
@IsString()
|
||||
authorName?: string;
|
||||
}
|
||||
|
||||
export class UpdateLiveBlogUpdateDto {
|
||||
@@ -358,47 +390,18 @@ export class UpdateLiveBlogUpdateDto {
|
||||
content?: string;
|
||||
|
||||
@IsOptional()
|
||||
@IsBoolean()
|
||||
isPinned?: boolean;
|
||||
|
||||
@IsOptional()
|
||||
@IsUUID()
|
||||
authorId?: string;
|
||||
|
||||
@IsOptional()
|
||||
@IsDate()
|
||||
scheduledAt?: Date;
|
||||
@IsString()
|
||||
image?: string;
|
||||
|
||||
@IsOptional()
|
||||
@IsString()
|
||||
strapiId?: string;
|
||||
}
|
||||
|
||||
export class FindLiveBlogsDto {
|
||||
@IsOptional()
|
||||
@IsString()
|
||||
category?: string;
|
||||
videoUrl?: string;
|
||||
|
||||
@IsOptional()
|
||||
@IsString()
|
||||
author?: string;
|
||||
|
||||
@IsOptional()
|
||||
@IsString()
|
||||
status?: string;
|
||||
authorName?: string;
|
||||
|
||||
@IsOptional()
|
||||
@IsBoolean()
|
||||
isPinned?: boolean;
|
||||
|
||||
@IsOptional()
|
||||
@IsString()
|
||||
search?: string;
|
||||
|
||||
@IsOptional()
|
||||
@IsNumber()
|
||||
page?: number;
|
||||
|
||||
@IsOptional()
|
||||
limit?: number;
|
||||
}
|
||||
@@ -293,4 +293,15 @@ export class ArticlesService {
|
||||
await this.articleRepository.remove(article);
|
||||
this.logger.log(`Successfully deleted article with strapiId: ${strapiId}`);
|
||||
}
|
||||
|
||||
async findHeroArticle(): Promise<Article | null> {
|
||||
return this.articleRepository.findOne({
|
||||
where: {
|
||||
isHero: true,
|
||||
status: ArticleStatus.PUBLISHED,
|
||||
},
|
||||
relations: ['author', 'category'],
|
||||
order: { createdAt: 'DESC' },
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -254,6 +254,9 @@ export class Article {
|
||||
@Column({ default: 0 })
|
||||
telegramShares: number;
|
||||
|
||||
@Column({ default: false })
|
||||
isHero: boolean;
|
||||
|
||||
@CreateDateColumn()
|
||||
createdAt: Date;
|
||||
|
||||
|
||||
Reference in new issue
Block a user