40 lines
1.3 KiB
TypeScript
40 lines
1.3 KiB
TypeScript
import { ApiHideProperty, ApiProperty } from '@nestjs/swagger';
|
||
import { Column, Entity, JoinTable, ManyToMany, OneToMany, Relation } from 'typeorm';
|
||
import { CommonEntity } from '~/common/entity/common.entity';
|
||
import { Storage } from '../tools/storage/storage.entity';
|
||
import { ProductEntity } from '../product/product.entity';
|
||
import { SkDomain } from '~/common/decorators/domain.decorator';
|
||
|
||
@Entity({ name: 'company' })
|
||
export class CompanyEntity extends CommonEntity {
|
||
@Column({
|
||
name: 'name',
|
||
type: 'varchar',
|
||
unique: true,
|
||
length: 255,
|
||
comment: '公司名称'
|
||
})
|
||
@ApiProperty({ description: '公司名称' })
|
||
name: string;
|
||
|
||
@Column({ name: 'is_delete', type: 'tinyint', default: 0, comment: '是否删除' })
|
||
@ApiProperty({ description: '删除状态:0未删除,1已删除' })
|
||
isDelete: number;
|
||
|
||
@Column({ type: 'int', default: 1, comment: '所属域' })
|
||
@ApiProperty({ description: '所属域' })
|
||
domain: SkDomain;
|
||
|
||
@ApiHideProperty()
|
||
@OneToMany(() => ProductEntity, product => product.company)
|
||
products: Relation<ProductEntity[]>;
|
||
|
||
@ManyToMany(() => Storage, storage => storage.companys)
|
||
@JoinTable({
|
||
name: 'company_storage',
|
||
joinColumn: { name: 'company_id', referencedColumnName: 'id' },
|
||
inverseJoinColumn: { name: 'file_id', referencedColumnName: 'id' }
|
||
})
|
||
files: Relation<Storage[]>;
|
||
}
|