announcments
This commit is contained in:
@@ -0,0 +1,49 @@
|
||||
import { ApiProperty } from '@nestjs/swagger';
|
||||
import {
|
||||
ArrayMinSize,
|
||||
IsArray,
|
||||
IsBoolean,
|
||||
IsDateString,
|
||||
IsNotEmpty,
|
||||
IsOptional,
|
||||
IsString,
|
||||
Length,
|
||||
MinLength,
|
||||
} from 'class-validator';
|
||||
|
||||
import { AnnouncementMessage } from '../../../common/enums/message.enum';
|
||||
|
||||
export class CreateAnnouncementDto {
|
||||
@IsNotEmpty({ message: AnnouncementMessage.TITLE_IS_REQUIRED })
|
||||
@IsString({ message: AnnouncementMessage.TITLE_STRING })
|
||||
@Length(5, 100, { message: AnnouncementMessage.TITLE_LENGTH })
|
||||
@ApiProperty({ description: 'Title of the announcement', example: 'اطلاعیه جدید' })
|
||||
title!: string;
|
||||
|
||||
@IsNotEmpty({ message: AnnouncementMessage.CONTENT_IS_REQUIRED })
|
||||
@IsString({ message: AnnouncementMessage.CONTENT_IS_STRING })
|
||||
@MinLength(10, { message: AnnouncementMessage.CONTENT_MUST_BE_LONGER })
|
||||
@ApiProperty({ description: 'Content of the announcement', example: 'اطلاعیه جدید برای کاربران' })
|
||||
content!: string;
|
||||
|
||||
@IsOptional()
|
||||
@IsDateString({}, { message: AnnouncementMessage.PUBLISH_AT_MUST_BE_DATE })
|
||||
@ApiProperty({ description: 'Publish date of the announcement', example: '2025-02-25T10:00:00Z' })
|
||||
publishAt?: string;
|
||||
|
||||
@IsOptional()
|
||||
@IsBoolean({ message: AnnouncementMessage.IMPORTANT_MUST_BE_BOOLEAN })
|
||||
@ApiProperty({ description: 'Is this announcement important?', example: false })
|
||||
isImportant?: boolean;
|
||||
|
||||
@IsOptional()
|
||||
@ArrayMinSize(1)
|
||||
@IsArray({ message: AnnouncementMessage.USER_IDS_MUST_BE_ARRAY })
|
||||
@IsString({ each: true, message: AnnouncementMessage.USER_MUST_BE_UUID })
|
||||
@ApiProperty({
|
||||
type: [String],
|
||||
description: 'Array of user ids to send announcement to (if empty, sends to all users)',
|
||||
example: [],
|
||||
})
|
||||
userIds?: string[];
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
import { ApiPropertyOptional } from '@nestjs/swagger';
|
||||
import { IsDateString, IsOptional, IsString } from 'class-validator';
|
||||
import { PaginationDto } from '../../../common/DTO/pagination.dto';
|
||||
import { CriticismMessage } from '../../../common/enums/message.enum';
|
||||
|
||||
export class SearchAnnouncementQueryDto extends PaginationDto {
|
||||
@IsOptional()
|
||||
@IsDateString()
|
||||
@ApiPropertyOptional({ description: 'since query', example: '2025-01-27' })
|
||||
since?: string;
|
||||
|
||||
@IsOptional()
|
||||
@IsDateString()
|
||||
@ApiPropertyOptional({ description: 'publishAt query', example: '2025-01-27' })
|
||||
publishAt?: string;
|
||||
|
||||
@IsOptional()
|
||||
@IsString({ message: CriticismMessage.SEARCH_QUERY_STRING })
|
||||
@ApiPropertyOptional({ description: 'Search query', example: 'search query' })
|
||||
q?: string;
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
import { PartialType } from '@nestjs/swagger';
|
||||
import { CreateAnnouncementDto } from './create-announcement.dto';
|
||||
|
||||
export class UpdateAnnouncementDto extends PartialType(CreateAnnouncementDto) {}
|
||||
Reference in New Issue
Block a user