Forráskód Böngészése

✨ feat(goods): 添加商品与商家的关联关系

- 导入Merchant实体类以建立关联
- 添加merchant字段及关联关系定义
- 设置merchant_id外键列,支持商品与商家的多对一关联
yourname 3 hónapja
szülő
commit
82e34f3bc6
1 módosított fájl, 5 hozzáadás és 0 törlés
  1. 5 0
      src/server/modules/goods/goods.entity.ts

+ 5 - 0
src/server/modules/goods/goods.entity.ts

@@ -2,6 +2,7 @@ import { Entity, PrimaryGeneratedColumn, Column, ManyToOne, JoinColumn, CreateDa
 import { GoodsCategory } from './goods-category.entity';
 import { Supplier } from '@/server/modules/supplier/supplier.entity';
 import { File } from '@/server/modules/files/file.entity';
+import { Merchant } from '@/server/modules/merchant/merchant.entity';
 
 @Entity('goods')
 export class Goods {
@@ -107,4 +108,8 @@ export class Goods {
   @ManyToOne(() => File, { nullable: true })
   @JoinColumn({ name: 'image_file_id', referencedColumnName: 'id' })
   imageFile!: File | null;
+
+  @ManyToOne(() => Merchant, { nullable: true })
+  @JoinColumn({ name: 'merchant_id', referencedColumnName: 'id' })
+  merchant!: Merchant | null;
 }