新增平台商品

This commit is contained in:
2023-12-21 15:16:20 +08:00
parent a92ac8262f
commit b38c3f17cd
9 changed files with 483 additions and 0 deletions
+43
View File
@@ -0,0 +1,43 @@
package model
import (
"gorm.io/gorm"
"hospital-admin-api/global"
"time"
)
// ProductPlatform 商品表-处方平台
type ProductPlatform struct {
ProductPlatformId int64 `gorm:"column:product_platform_id;type:bigint(19);primary_key;comment:主键id" json:"product_platform_id"`
ProductName string `gorm:"column:product_name;type:varchar(255);comment:商品名称" json:"product_name"`
ProductPrice float64 `gorm:"column:product_price;type:decimal(10,2);comment:商品价格" json:"product_price"`
ProductType int `gorm:"column:product_type;type:tinyint(4);default:1;comment:药品类型(0:未知 1:中成药 2:西药)" json:"product_type"`
ProductPlatformCode string `gorm:"column:product_platform_code;type:varchar(100);comment:处方平台商品编码" json:"product_platform_code"`
ProductPharmacyCode string `gorm:"column:product_pharmacy_code;type:varchar(100);comment:第三方药店商品编码" json:"product_pharmacy_code"`
ProductSpec string `gorm:"column:product_spec;type:varchar(255);comment:商品规格" json:"product_spec"`
LicenseNumber string `gorm:"column:license_number;type:varchar(255);comment:批准文号" json:"license_number"`
Manufacturer string `gorm:"column:manufacturer;type:varchar(255);comment:生产厂家" json:"manufacturer"`
SingleUnit string `gorm:"column:single_unit;type:varchar(50);comment:单次剂量单位" json:"single_unit"`
PackagingUnit string `gorm:"column:packaging_unit;type:varchar(20);comment:基本包装单位" json:"packaging_unit"`
PackagingCount string `gorm:"column:packaging_count;type:varchar(20);comment:基本包装数量" json:"packaging_count"`
RetailUnit string `gorm:"column:retail_unit;type:varchar(20);comment:零售单位" json:"retail_unit"`
Model
}
func (m *ProductPlatform) TableName() string {
return "gdxz_product_platform"
}
func (m *ProductPlatform) BeforeCreate(tx *gorm.DB) error {
if m.ProductPlatformId == 0 {
m.ProductPlatformId = global.Snowflake.Generate().Int64()
}
m.CreatedAt = LocalTime(time.Now())
tx.Statement.SetColumn("CreatedAt", m.CreatedAt)
m.UpdatedAt = LocalTime(time.Now())
tx.Statement.SetColumn("UpdatedAt", m.UpdatedAt)
return nil
}
+34
View File
@@ -0,0 +1,34 @@
package model
import (
"gorm.io/gorm"
"hospital-admin-api/global"
"time"
)
// ProductPlatformAmount 商品-库存表-处方平台
type ProductPlatformAmount struct {
AmountId int64 `gorm:"column:amount_id;type:bigint(19);primary_key;comment:主键id" json:"amount_id"`
ProductPlatformId int64 `gorm:"column:product_platform_id;type:bigint(19);comment:处方平台商品id" json:"product_platform_id"`
ProductPlatformCode string `gorm:"column:product_platform_code;type:varchar(100);comment:处方平台商品编码" json:"product_platform_code"`
Stock uint `gorm:"column:stock;type:int(11) unsigned;default:0;comment:现有库存" json:"stock"`
Model
}
func (m *ProductPlatformAmount) TableName() string {
return "gdxz_product_platform_amount"
}
func (m *ProductPlatformAmount) BeforeCreate(tx *gorm.DB) error {
if m.AmountId == 0 {
m.AmountId = global.Snowflake.Generate().Int64()
}
m.CreatedAt = LocalTime(time.Now())
tx.Statement.SetColumn("CreatedAt", m.CreatedAt)
m.UpdatedAt = LocalTime(time.Now())
tx.Statement.SetColumn("UpdatedAt", m.UpdatedAt)
return nil
}