chore: compelete danak category service

This commit is contained in:
mahyargdz
2025-01-26 16:10:12 +03:30
parent e4425a07d6
commit bdd8ec06b4
17 changed files with 367 additions and 16 deletions
@@ -0,0 +1,26 @@
import { ApiPropertyOptional } from "@nestjs/swagger";
import { Type } from "class-transformer";
import { IsOptional, IsString, IsUUID } from "class-validator";
import { PaginationDto } from "../../../common/DTO/pagination.dto";
import { CategoryMessage } from "../../../common/enums/message.enum";
export class CategorySearchQueryDto {
@IsOptional()
@IsUUID("4", { message: CategoryMessage.PARENT_ID_SHOULD_BE_UUID })
@ApiPropertyOptional({ description: "Parent category id", example: "8b1e8b1e-8b1e-8b1e-8b1e-8b1e8b1e8b1e" })
parentId?: string;
}
export class CategoryListSearchQueryDto extends PaginationDto {
@IsOptional()
@Type(() => Number)
// @IsBoolean({ message: CategoryMessage.IS_ACTIVE_SHOULD_BE_BOOLEAN })
@ApiPropertyOptional({ description: "Category status", example: 1 })
isActive?: number;
@IsOptional()
@IsString({ message: CategoryMessage.SEARCH_QUERY_STRING })
@ApiPropertyOptional({ description: "Search query", example: "search query" })
q?: string;
}
@@ -1,5 +1,5 @@
import { ApiProperty, ApiPropertyOptional } from "@nestjs/swagger";
import { IsNotEmpty, IsOptional, IsString, IsUUID, IsUrl, Length } from "class-validator";
import { IsBoolean, IsNotEmpty, IsOptional, IsString, IsUUID, IsUrl, Length } from "class-validator";
import { CategoryMessage } from "../../../common/enums/message.enum";
@@ -15,6 +15,11 @@ export class CreateCategoryDto {
@ApiProperty({ description: "Category icon", example: "https://example.com/icon.png" })
icon: string;
@IsNotEmpty({ message: CategoryMessage.IS_ACTIVE_REQUIRED })
@IsBoolean({ message: CategoryMessage.IS_ACTIVE_REQUIRED })
@ApiProperty({ description: "Category status", example: true })
isActive: boolean;
@IsOptional()
@IsNotEmpty({ message: CategoryMessage.PARENT_ID_REQUIRED })
@IsUUID("4", { message: CategoryMessage.PARENT_ID_SHOULD_BE_UUID })
@@ -0,0 +1,76 @@
import { ApiProperty } from "@nestjs/swagger";
import { IsBoolean, IsDateString, IsEnum, IsInt, IsNotEmpty, IsString, IsUUID, IsUrl, Length, MaxLength } from "class-validator";
import { CategoryMessage, ServiceMessage } from "../../../common/enums/message.enum";
import { ServicesLanguage } from "../enums/services-language.enum";
export class CreateServiceDto {
@IsNotEmpty({ message: CategoryMessage.CAT_ID_NOT_EMPTY })
@IsUUID("4", { message: CategoryMessage.CAT_ID_SHOULD_BE_UUID })
@ApiProperty({ description: "The category id of the service", example: "00000000-0000-0000-0000-000000000000" })
categoryId: string;
@IsNotEmpty({ message: ServiceMessage.NAME_REQUIRED })
@IsString({ message: ServiceMessage.NAME_STRING })
@Length(3, 50, { message: ServiceMessage.NAME_LENGTH })
@ApiProperty({ description: "The name of the service", example: "Service Name" })
name: string;
@IsNotEmpty({ message: ServiceMessage.DESCRIPTION_REQUIRED })
@IsString({ message: ServiceMessage.DESCRIPTION_STRING })
@Length(10, 500, { message: ServiceMessage.DESCRIPTION_LENGTH })
@ApiProperty({ description: "The description of the service", example: "Service Description" })
description: string;
@IsNotEmpty({ message: ServiceMessage.AUTHOR_REQUIRED })
@IsString({ message: ServiceMessage.AUTHOR_STRING })
@Length(3, 100, { message: ServiceMessage.AUTHOR_LENGTH })
@ApiProperty({ description: "The author of the service", example: "danak corp" })
author: string;
@IsNotEmpty({ message: ServiceMessage.CREATE_DATE_REQUIRED })
@IsDateString({}, { message: ServiceMessage.CREATE_DATE_STRING })
@ApiProperty({ description: "The create date of the service", example: "2021-08-01T00:00:00.000Z" })
createDate: Date;
@IsNotEmpty({ message: ServiceMessage.USER_COUNT_REQUIRED })
@IsInt({ message: ServiceMessage.USER_COUNT_INT })
@ApiProperty({ description: "The user count of the service", example: 1000 })
userCount: number;
@IsNotEmpty({ message: ServiceMessage.SERVICE_LANGUAGE_REQUIRED })
@IsEnum(ServicesLanguage)
@ApiProperty({ enum: ServicesLanguage, description: "The language of the service", example: ServicesLanguage.ENGLISH })
serviceLanguage: ServicesLanguage;
@IsNotEmpty({ message: ServiceMessage.SOFTWARE_LANGUAGE_REQUIRED })
@IsString({ message: ServiceMessage.SOFTWARE_LANGUAGE_STRING })
@MaxLength(150, { message: ServiceMessage.SOFTWARE_LANGUAGE_LENGTH })
@ApiProperty({ description: "The software language of the service", example: "Python" })
softwareLanguage: string;
@IsNotEmpty({ message: ServiceMessage.META_DESCRIPTION_REQUIRED })
@IsString({ message: ServiceMessage.META_DESCRIPTION_REQUIRED })
@ApiProperty({ description: "The meta description of the service", example: "Service Meta Description" })
metaDescription: string;
@IsNotEmpty({ message: ServiceMessage.LINK_REQUIRED })
@IsUrl({ protocols: ["http", "https"], require_protocol: true }, { message: ServiceMessage.LINK_SHOULD_BE_URL })
@ApiProperty({ description: "The status of the service", example: "https://example.com" })
link: string;
@IsNotEmpty({ message: ServiceMessage.IS_DANAK_SUGGEST_REQUIRED })
@IsBoolean({ message: ServiceMessage.IS_DANAK_SUGGEST_BOOLEAN })
@ApiProperty({ description: "Is the service a Danak suggest?", example: true })
isDanakSuggest: boolean;
@IsNotEmpty({ message: ServiceMessage.ICON_REQUIRED })
@IsUrl({ protocols: ["http", "https"], require_protocol: true }, { message: ServiceMessage.ICON_SHOULD_BE_URL })
@ApiProperty({ description: "The icon url of the service", example: "https://example.com/icon.png" })
icon: string;
@IsNotEmpty({ message: ServiceMessage.IMAGES_REQUIRED })
@IsString({ each: true })
@ApiProperty({ description: "The images of the service", example: ["https://example.com/image1.png", "https://example.com/image2.png"] })
images: string[];
}