src/modules/article/article.dto.ts
IntersectionType(
PaginateOptionWithHotSortDTO,
KeywordQueryDTO,
DateQueryDTO
)
Properties |
Optional category_slug |
Type : string
|
Decorators :
@IsString()
|
Defined in src/modules/article/article.dto.ts:75
|
Optional featured |
Type : boolean
|
Decorators :
@IsBoolean()
|
Defined in src/modules/article/article.dto.ts:65
|
lang |
Type : string
|
Decorators :
@IsIn(ARTICLE_LANGUAGES)
|
Defined in src/modules/article/article.dto.ts:81
|
Optional origin |
Type : OriginState
|
Decorators :
@IsIn(ARTICLE_ORIGIN_STATES)
|
Defined in src/modules/article/article.dto.ts:59
|
Optional public |
Type : PublicState
|
Decorators :
@WhenGuest({only: undefined, default: undefined})
|
Defined in src/modules/article/article.dto.ts:52
|
Optional state |
Type : PublishState
|
Decorators :
@WhenGuest({only: undefined, default: undefined})
|
Defined in src/modules/article/article.dto.ts:44
|
Optional tag_slug |
Type : string
|
Decorators :
@IsString()
|
Defined in src/modules/article/article.dto.ts:70
|
import { IntersectionType } from '@nestjs/mapped-types'
import { Transform } from 'class-transformer'
import {
IsString,
IsNotEmpty,
IsArray,
IsOptional,
IsDefined,
IsBoolean,
IsIn,
IsInt,
ArrayNotEmpty,
ArrayUnique
} from 'class-validator'
import { PublishState, PublicState, OriginState } from '@app/constants/biz.constant'
import { WhenGuest } from '@app/decorators/guest.decorator'
import { unknownToNumber, unknownToBoolean } from '@app/transformers/value.transformer'
import { DateQueryDTO, KeywordQueryDTO } from '@app/models/query.model'
import { PaginateOptionWithHotSortDTO } from '@app/models/paginate.model'
import {
ARTICLE_PUBLISH_STATES,
ARTICLE_PUBLIC_STATES,
ARTICLE_ORIGIN_STATES,
ARTICLE_LANGUAGES
} from './article.model'
export class ArticlePaginateQueryDTO extends IntersectionType(
PaginateOptionWithHotSortDTO,
KeywordQueryDTO,
DateQueryDTO
) {
@WhenGuest({ only: [PublishState.Published], default: PublishState.Published })
@IsIn(ARTICLE_PUBLISH_STATES)
@IsInt()
@IsNotEmpty()
@IsOptional()
@Transform(({ value }) => unknownToNumber(value))
state?: PublishState
@WhenGuest({ only: [PublicState.Public], default: PublicState.Public })
@IsIn(ARTICLE_PUBLIC_STATES)
@IsInt()
@IsNotEmpty()
@IsOptional()
@Transform(({ value }) => unknownToNumber(value))
public?: PublicState
@IsIn(ARTICLE_ORIGIN_STATES)
@IsInt()
@IsNotEmpty()
@IsOptional()
@Transform(({ value }) => unknownToNumber(value))
origin?: OriginState
@IsBoolean()
@IsNotEmpty()
@IsOptional()
@Transform(({ value }) => unknownToBoolean(value))
featured?: boolean
@IsString()
@IsNotEmpty()
@IsOptional()
tag_slug?: string
@IsString()
@IsNotEmpty()
@IsOptional()
category_slug?: string
@IsIn(ARTICLE_LANGUAGES)
@IsString()
@IsNotEmpty()
@IsOptional()
lang: string
}
export class ArticleCalendarQueryDTO {
@IsString()
@IsNotEmpty()
@IsOptional()
timezone?: string
}
export class ArticleIdsDTO {
@ArrayNotEmpty()
@ArrayUnique()
@IsArray()
article_ids: string[]
}
export class ArticlesStateDTO extends ArticleIdsDTO {
@IsIn(ARTICLE_PUBLISH_STATES)
@IsInt()
@IsDefined()
state: PublishState
}