mirror of
https://github.com/Tria-plc/edr-platform.git
synced 2026-08-29 18:48:11 +00:00
file upload settings
This commit is contained in:
@@ -0,0 +1,58 @@
|
||||
import { BaseEntity } from "@edr/api-common";
|
||||
import {
|
||||
Check,
|
||||
Column,
|
||||
Entity,
|
||||
Index,
|
||||
JoinColumn,
|
||||
ManyToOne,
|
||||
} from "typeorm";
|
||||
|
||||
import { FileUploadSetting } from "./file-upload-setting.entity";
|
||||
|
||||
@Entity({ name: "file_upload_fields" })
|
||||
@Index(["settingId", "fileKey"], { unique: true })
|
||||
@Check(`"max_files" > 0`)
|
||||
@Check(`"max_size_mb" > 0`)
|
||||
export class FileUploadField extends BaseEntity {
|
||||
@ManyToOne(() => FileUploadSetting, (setting) => setting.fields, {
|
||||
onDelete: "CASCADE",
|
||||
})
|
||||
@JoinColumn({ name: "setting_id" })
|
||||
setting!: FileUploadSetting;
|
||||
|
||||
@Column({ name: "setting_id", type: "uuid" })
|
||||
settingId!: string;
|
||||
|
||||
@Column({ name: "file_key", type: "varchar", length: 128 })
|
||||
fileKey!: string;
|
||||
|
||||
@Column({ name: "file_label", type: "varchar", length: 256 })
|
||||
fileLabel!: string;
|
||||
|
||||
@Column({ name: "help_text", type: "text", nullable: true })
|
||||
helpText?: string | null;
|
||||
|
||||
@Column({ name: "is_required", type: "boolean", default: false })
|
||||
isRequired!: boolean;
|
||||
|
||||
@Column({ name: "is_multiple", type: "boolean", default: false })
|
||||
isMultiple!: boolean;
|
||||
|
||||
@Column({ name: "max_files", type: "integer", default: 1 })
|
||||
maxFiles!: number;
|
||||
|
||||
@Column({
|
||||
name: "allowed_extensions",
|
||||
type: "text",
|
||||
array: true,
|
||||
default: () => "'{}'::text[]",
|
||||
})
|
||||
allowedExtensions!: string[];
|
||||
|
||||
@Column({ name: "max_size_mb", type: "integer", default: 10 })
|
||||
maxSizeMb!: number;
|
||||
|
||||
@Column({ name: "display_order", type: "integer", default: 0 })
|
||||
displayOrder!: number;
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
import { BaseEntity } from "@edr/api-common";
|
||||
import {
|
||||
Column,
|
||||
Entity,
|
||||
Index,
|
||||
OneToMany,
|
||||
} from "typeorm";
|
||||
|
||||
import { FileUploadField } from "./file-upload-field.entity";
|
||||
|
||||
@Entity({ name: "file_upload_settings" })
|
||||
@Index(["code"], { unique: true })
|
||||
export class FileUploadSetting extends BaseEntity {
|
||||
@Column({
|
||||
name: "code",
|
||||
type: "varchar",
|
||||
length: 128,
|
||||
unique: true,
|
||||
})
|
||||
code!: string;
|
||||
|
||||
@Column({
|
||||
name: "label",
|
||||
type: "varchar",
|
||||
length: 256,
|
||||
})
|
||||
label!: string;
|
||||
|
||||
@Column({
|
||||
name: "description",
|
||||
type: "text",
|
||||
nullable: true,
|
||||
})
|
||||
description?: string | null;
|
||||
|
||||
@Column({
|
||||
name: "entity",
|
||||
type: "varchar",
|
||||
length: 32,
|
||||
default: "other",
|
||||
})
|
||||
entity!: string;
|
||||
|
||||
@OneToMany(
|
||||
() => FileUploadField,
|
||||
(field) => field.setting,
|
||||
{
|
||||
cascade: true,
|
||||
}
|
||||
)
|
||||
fields!: FileUploadField[];
|
||||
}
|
||||
Reference in New Issue
Block a user