52 lines
1.4 KiB
TypeScript
52 lines
1.4 KiB
TypeScript
import { Column, Entity, Index, PrimaryGeneratedColumn } from 'typeorm';
|
|
import { TimestampedEntity } from './timestamped.entity';
|
|
|
|
export enum AssetAttributeDataType {
|
|
TEXT = 'TEXT',
|
|
NUMBER = 'NUMBER',
|
|
BOOLEAN = 'BOOLEAN',
|
|
DATE = 'DATE',
|
|
DATETIME = 'DATETIME',
|
|
SELECT = 'SELECT',
|
|
}
|
|
|
|
@Entity({ name: 'asset_attribute_definitions' })
|
|
@Index('idx_asset_attribute_definitions_type', ['assetTypeId', 'sortOrder'])
|
|
@Index('idx_asset_attribute_definitions_active', ['isActive'])
|
|
export class AssetAttributeDefinition extends TimestampedEntity {
|
|
@PrimaryGeneratedColumn('uuid')
|
|
id!: string;
|
|
|
|
@Column({ name: 'asset_type_id', type: 'uuid' })
|
|
assetTypeId!: string;
|
|
|
|
@Column({ type: 'varchar', length: 80 })
|
|
code!: string;
|
|
|
|
@Column({ type: 'varchar', length: 160 })
|
|
name!: string;
|
|
|
|
@Column({
|
|
name: 'data_type',
|
|
type: 'enum',
|
|
enum: AssetAttributeDataType,
|
|
enumName: 'asset_attribute_data_type',
|
|
})
|
|
dataType!: AssetAttributeDataType;
|
|
|
|
@Column({ name: 'is_required', type: 'boolean', default: false })
|
|
isRequired!: boolean;
|
|
|
|
@Column({ name: 'is_active', type: 'boolean', default: true })
|
|
isActive!: boolean;
|
|
|
|
@Column({ type: 'varchar', length: 40, nullable: true })
|
|
unit!: string | null;
|
|
|
|
@Column({ type: 'jsonb', nullable: true })
|
|
options!: string[] | null;
|
|
|
|
@Column({ name: 'sort_order', type: 'integer', default: 0 })
|
|
sortOrder!: number;
|
|
}
|