27 lines
809 B
Go
27 lines
809 B
Go
package model
|
|
|
|
import (
|
|
"gorm.io/gorm"
|
|
"vote-api/global"
|
|
)
|
|
|
|
// BaseArea 地区表
|
|
type BaseArea struct {
|
|
AreaId int64 `gorm:"column:area_id;type:bigint(19);primary_key;comment:地区编号" json:"area_id"`
|
|
AreaName string `gorm:"column:area_name;type:varchar(255);comment:名称" json:"area_name"`
|
|
ParentId int64 `gorm:"column:parent_id;type:bigint(19);comment:上级编号" json:"parent_id"`
|
|
Zip string `gorm:"column:zip;type:varchar(10);comment:邮编" json:"zip"`
|
|
AreaType int `gorm:"column:area_type;type:tinyint(4);comment:类型(1:国家,2:省,3:市,4:区县)" json:"area_type"`
|
|
}
|
|
|
|
func (m *BaseArea) TableName() string {
|
|
return "base_area"
|
|
}
|
|
|
|
func (m *BaseArea) BeforeCreate(tx *gorm.DB) error {
|
|
if m.AreaId == 0 {
|
|
m.AreaId = global.Snowflake.Generate().Int64()
|
|
}
|
|
return nil
|
|
}
|