hospital-admin-api/api/model/userShipAddress.go
2023-09-18 14:17:40 +08:00

50 lines
2.7 KiB
Go
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

package model
import (
"gorm.io/gorm"
"hospital-admin-api/global"
"time"
)
// UserShipAddress 用户收货地址表
type UserShipAddress struct {
AddressId int64 `gorm:"column:address_id;type:bigint(19);primary_key;comment:主键id" json:"address_id"`
UserId int64 `gorm:"column:user_id;type:bigint(19);comment:用户id;NOT NULL" json:"user_id"`
ProvinceId int `gorm:"column:province_id;type:int(11);comment:省份id" json:"province_id"`
Province string `gorm:"column:province;type:varchar(40);comment:省份" json:"province"`
CityId int `gorm:"column:city_id;type:int(11);comment:城市id" json:"city_id"`
City string `gorm:"column:city;type:varchar(40);comment:城市" json:"city"`
CountyId int `gorm:"column:county_id;type:int(11);comment:区县id" json:"county_id"`
County string `gorm:"column:county;type:varchar(255);comment:区县" json:"county"`
ConsigneeTownId int `gorm:"column:consignee_town_id;type:int(11);comment:镇id" json:"consignee_town_id"`
ConsigneeTown string `gorm:"column:consignee_town;type:varchar(150);comment:镇" json:"consignee_town"`
Address string `gorm:"column:address;type:varchar(255);comment:详细地址" json:"address"`
AddressMask string `gorm:"column:address_mask;type:varchar(255);comment:详细地址(掩码)" json:"address_mask"`
ConsigneeName string `gorm:"column:consignee_name;type:varchar(150);comment:收货人姓名;NOT NULL" json:"consignee_name"`
ConsigneeNameMask string `gorm:"column:consignee_name_mask;type:varchar(150);comment:收货人姓名(掩码)" json:"consignee_name_mask"`
ConsigneeTel string `gorm:"column:consignee_tel;type:varchar(100);comment:收货人电话;NOT NULL" json:"consignee_tel"`
ConsigneeTelMask string `gorm:"column:consignee_tel_mask;type:varchar(100);comment:收货人电话(掩码)" json:"consignee_tel_mask"`
ConsigneeZipCode string `gorm:"column:consignee_zip_code;type:varchar(20);comment:收货邮编" json:"consignee_zip_code"`
IsDefault int `gorm:"column:is_default;type:tinyint(1);default:0;comment:默认地址0:否 1:是)" json:"is_default"`
Tag int `gorm:"column:tag;type:tinyint(1);comment:地址标签1:家 2:公司 3:学校 4:其他)" json:"tag"`
Model
}
func (m *UserShipAddress) TableName() string {
return "gdxz_user_ship_address"
}
func (m *UserShipAddress) BeforeCreate(tx *gorm.DB) error {
if m.AddressId == 0 {
m.AddressId = 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
}