feat: add choices entity admin crud
This commit is contained in:
@@ -0,0 +1,45 @@
|
||||
import { IsNotEmpty, IsNumber, IsPositive, MaxLength } from 'class-validator';
|
||||
import { i18nValidationMessage as t } from 'nestjs-i18n';
|
||||
|
||||
export class CreateChoiceDTO {
|
||||
@IsPositive({
|
||||
message: t('validation.wrongField', {
|
||||
field: '$t(questions.fields.question)',
|
||||
}),
|
||||
})
|
||||
@IsNotEmpty({
|
||||
message: t('validation.requiredField', {
|
||||
field: '$t(questions.fields.question)',
|
||||
}),
|
||||
})
|
||||
question!: number;
|
||||
|
||||
@IsNotEmpty({
|
||||
message: t('validation.requiredField', {
|
||||
field: '$t(questions.fields.text)',
|
||||
}),
|
||||
})
|
||||
@MaxLength(255, {
|
||||
message: t('validation.maxLengthField', {
|
||||
field: '$t(users.fields.text)',
|
||||
max: 255,
|
||||
}),
|
||||
})
|
||||
text!: string;
|
||||
|
||||
@IsNumber()
|
||||
@IsNotEmpty({
|
||||
message: t('validation.requiredField', {
|
||||
field: '$t(questions.fields.value)',
|
||||
}),
|
||||
})
|
||||
value!: number;
|
||||
|
||||
@IsNumber()
|
||||
@IsNotEmpty({
|
||||
message: t('validation.requiredField', {
|
||||
field: '$t(questions.fields.order)',
|
||||
}),
|
||||
})
|
||||
order!: number;
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
import { PaginationQueryDTO } from '@/common/dtos/pagination-query.dto';
|
||||
import { PartialType } from '@nestjs/swagger';
|
||||
import { IsEnum, IsNumber, IsOptional, IsString } from 'class-validator';
|
||||
import { ChoiceSortField } from '../enums/choice-sort-field.enum';
|
||||
|
||||
export class FindChoicesDTO extends PartialType(PaginationQueryDTO) {
|
||||
@IsNumber()
|
||||
@IsOptional()
|
||||
id?: number;
|
||||
|
||||
@IsNumber()
|
||||
@IsOptional()
|
||||
question?: number;
|
||||
|
||||
@IsString()
|
||||
@IsOptional()
|
||||
text?: string;
|
||||
|
||||
@IsNumber()
|
||||
@IsOptional()
|
||||
value?: number;
|
||||
|
||||
@IsNumber()
|
||||
@IsOptional()
|
||||
choiceOrder?: number;
|
||||
|
||||
@IsEnum(ChoiceSortField)
|
||||
@IsOptional()
|
||||
sortBy?: ChoiceSortField;
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
import { PartialType } from '@nestjs/swagger';
|
||||
import { CreateChoiceDTO } from './create-choice.dto';
|
||||
|
||||
export class UpdateChoiceDTO extends PartialType(CreateChoiceDTO) {}
|
||||
Reference in New Issue
Block a user