46 lines
2.3 KiB
Go
46 lines
2.3 KiB
Go
package model
|
|
|
|
import (
|
|
"gorm.io/gorm"
|
|
"hospital-admin-api/global"
|
|
"time"
|
|
)
|
|
|
|
// Pharmacy 药房信息表
|
|
type Pharmacy struct {
|
|
PharmacyId int64 `gorm:"column:pharmacy_id;type:bigint(20);primary_key;comment:主键id" json:"pharmacy_id"`
|
|
PharmacyName string `gorm:"column:pharmacy_name;type:varchar(100);comment:药房名称;NOT NULL" json:"pharmacy_name"`
|
|
PharmacyCode string `gorm:"column:pharmacy_code;type:varchar(64);comment:药房代码;NOT NULL" json:"pharmacy_code"`
|
|
Postage float64 `gorm:"column:postage;type:decimal(10,2);default:0.00;comment:基础邮费" json:"postage"`
|
|
FreeShippingThreshold float64 `gorm:"column:free_shipping_threshold;type:decimal(10,2);default:0.00;comment:满XX包邮门槛金额" json:"free_shipping_threshold"`
|
|
IsPickup int `gorm:"column:is_pickup;type:tinyint(1);default:0;comment:是否支持自提(0:否 1:是)" json:"is_pickup"`
|
|
Telephone string `gorm:"column:telephone;type:varchar(30);comment:电话" json:"telephone"`
|
|
ProvinceId int `gorm:"column:province_id;type:int(11);default:0;comment:省份id" json:"province_id"`
|
|
Province string `gorm:"column:province;type:varchar(50);comment:省份" json:"province"`
|
|
CityId int `gorm:"column:city_id;type:int(11);default:0;comment:城市id" json:"city_id"`
|
|
City string `gorm:"column:city;type:varchar(50);comment:城市" json:"city"`
|
|
CountyId int `gorm:"column:county_id;type:int(11);default:0;comment:区县id" json:"county_id"`
|
|
County string `gorm:"column:county;type:varchar(50);comment:区县" json:"county"`
|
|
Address string `gorm:"column:address;type:varchar(255);comment:地址" json:"address"`
|
|
Status int `gorm:"column:status;type:tinyint(1);default:1;comment:状态(0:禁用 1:正常 2:删除)" json:"status"`
|
|
Model
|
|
}
|
|
|
|
func (m *Pharmacy) TableName() string {
|
|
return "gdxz_pharmacy"
|
|
}
|
|
|
|
func (m *Pharmacy) BeforeCreate(tx *gorm.DB) error {
|
|
if m.PharmacyId == 0 {
|
|
m.PharmacyId = 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
|
|
}
|