zksu
/
API
forked from yoone/API
1
0
Fork 0
API/src/entity/site.entity.ts

70 lines
1.6 KiB
TypeScript

import { Column, Entity, JoinTable, ManyToMany, PrimaryGeneratedColumn } from 'typeorm';
import { Area } from './area.entity';
import { StockPoint } from './stock_point.entity';
@Entity('site')
export class Site {
@PrimaryGeneratedColumn()
id: number;
@Column({ length: 255, nullable: true })
apiUrl: string;
@Column({ name: 'website_url', length: 255, nullable: true })
websiteUrl?: string;
@Column({ name: 'webhook_url', length: 255, nullable: true })
webhookUrl?: string;
@Column({ length: 255, nullable: true })
consumerKey?: string;
@Column({ length: 255, nullable: true })
consumerSecret?: string;
@Column({ nullable: true })
token?: string;
@Column({ length: 255, unique: true })
name: string;
@Column({ length: 255, nullable: true })
description?: string;
@Column({ length: 32, default: 'woocommerce' })
type: string; // 平台类型:woocommerce | shopyy
@Column({ length: 64, nullable: true })
skuPrefix: string;
@Column({ default: false })
isDisabled: boolean;
@ManyToMany(() => Area, { cascade: true })
@JoinTable({
name: 'site_areas_area',
joinColumn: {
name: 'siteId',
referencedColumnName: 'id'
},
inverseJoinColumn: {
name: 'areaId',
referencedColumnName: 'id'
}
})
areas: Area[];
@ManyToMany(() => StockPoint, stockPoint => stockPoint.sites)
@JoinTable({
name: 'site_stock_points_stock_point',
joinColumn: {
name: 'siteId',
referencedColumnName: 'id'
},
inverseJoinColumn: {
name: 'stockPointId',
referencedColumnName: 'id'
}
})
stockPoints: StockPoint[];
}