print module

This commit is contained in:
2026-01-24 15:39:15 +03:30
parent 58e5e3e0d2
commit 64d6d1e391
10 changed files with 157 additions and 0 deletions
@@ -0,0 +1,19 @@
import { Entity, Property, ManyToOne, PrimaryKey, Unique } from '@mikro-orm/core';
import { BaseEntity } from '../../../common/entities/base.entity';
import { Field } from './field.entity';
@Entity({ tableName: 'field_option' })
export class FieldOption extends BaseEntity {
@PrimaryKey({ autoincrement: true, type: 'bigint' })
id: bigint;
@Property()
value: string;
@ManyToOne(() => Field)
field: Field;
@Property({ type: 'int', nullable: true })
order?: number;
}
@@ -0,0 +1,29 @@
import { Collection, Entity, Enum, ManyToOne, OneToMany, PrimaryKey, Property } from '@mikro-orm/core';
import { FieldOption } from './field-option.entity';
import { FieldType } from '../interface/print';
import { Section } from './section.entity';
@Entity({ tableName: 'field' })
export class Field {
@PrimaryKey({ type: 'bigint', autoincrement: true })
id: bigint
@OneToMany(() => FieldOption, (attrValue) => attrValue.field)
options = new Collection<FieldOption>(this)
@ManyToOne(() => Section)
section: Section
@Property()
name: string;
@Enum(() => FieldType)
type: FieldType;
@Property({ type: 'boolean', default: false })
isRequired: boolean = false;
@Property({ type: 'int', nullable: true })
order?: number;
}
@@ -0,0 +1,19 @@
import { Cascade, Collection, Entity, OneToMany, PrimaryKey, Property } from '@mikro-orm/core';
import { Field } from './field.entity';
@Entity({ tableName: 'section' })
export class Section {
@PrimaryKey({ type: 'bigint', autoincrement: true })
id: bigint
@OneToMany(() => Field, (attrValue) => attrValue.section, { cascade: [Cascade.PERSIST, Cascade.REMOVE] })
Fields = new Collection<Field>(this)
@Property()
title: string;
@Property({ type: 'int', nullable: true })
order?: number;
}