67 lines
1.7 KiB
TypeScript
67 lines
1.7 KiB
TypeScript
import { IsEnum, IsOptional } from 'class-validator';
|
|
import { PreguntaOpcion } from 'src/pregunta_opcion/entities/pregunta_opcion.entity';
|
|
import { SeccionPregunta } from 'src/seccion_pregunta/entities/seccion_pregunta.entity';
|
|
import { TipoPregunta } from 'src/tipo_pregunta/entities/tipo_pregunta.entity';
|
|
import {
|
|
Entity,
|
|
PrimaryGeneratedColumn,
|
|
Column,
|
|
ManyToOne,
|
|
OneToMany,
|
|
JoinColumn,
|
|
} from 'typeorm';
|
|
|
|
export enum TiposValidacion {
|
|
CORREO = 'correo',
|
|
CORREO_INSTITUCIONAL = 'correo_institucional',
|
|
TELEFONO = 'telefono',
|
|
NOMBRE = 'nombre',
|
|
APELLIDOS = 'apellidos',
|
|
ENTERO = 'entero',
|
|
DECIMAL = 'decimal',
|
|
COMUNIDAD_ALUMNO = 'comunidad_alumno',
|
|
CUENTA_ALUMNO = 'cuenta_alumno',
|
|
COMUNIDAD_TRABAJADOR = 'comunidad_trabajador',
|
|
CUENTA_TRABAJADOR = 'cuenta_trabajador',
|
|
GENERO = 'genero',
|
|
CARRERA = 'carrera',
|
|
INSTITUCION = 'institucion',
|
|
RFC = 'rfc',
|
|
}
|
|
|
|
@Entity()
|
|
export class Pregunta {
|
|
@PrimaryGeneratedColumn()
|
|
id_pregunta: number;
|
|
|
|
@Column()
|
|
pregunta: string;
|
|
|
|
@Column({ default: 0 })
|
|
contador_opcion: number;
|
|
|
|
@Column({ default: false })
|
|
obligatoria: boolean;
|
|
|
|
@ManyToOne(() => TipoPregunta, (tipo) => tipo.preguntas)
|
|
@JoinColumn({ name: 'id_tipo_pregunta' })
|
|
tipoPregunta: TipoPregunta;
|
|
|
|
@Column()
|
|
id_tipo_pregunta: number;
|
|
|
|
@Column({ type: 'enum', enum: TiposValidacion, nullable: true })
|
|
@IsOptional()
|
|
@IsEnum(TiposValidacion, { message: 'Validación no permitida' })
|
|
validacion?: TiposValidacion;
|
|
|
|
@OneToMany(
|
|
() => SeccionPregunta,
|
|
(seccionPregunta) => seccionPregunta.pregunta,
|
|
)
|
|
seccionPreguntas: SeccionPregunta[];
|
|
|
|
@OneToMany(() => PreguntaOpcion, (preguntaOpcion) => preguntaOpcion.pregunta)
|
|
opciones: PreguntaOpcion[];
|
|
}
|