You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

55 lines
1.8 KiB
Go

package schema
import (
"entgo.io/ent"
"entgo.io/ent/dialect/entsql"
"entgo.io/ent/schema"
"entgo.io/ent/schema/field"
"git.noahlan.cn/noahlan/ntool-biz/core/orm/nent/mixins"
"git.noahlan.cn/noahlan/ntool/nstd/tea"
)
type District struct {
ent.Schema
}
func (District) Fields() []ent.Field {
return []ent.Field{
field.Int64("id").
Annotations(entsql.Annotation{Incremental: tea.Bool(false)}).
Comment("ID | 主键"),
field.String("name").Comment("Region Name | 地区名称"),
field.String("short_name").Optional().Comment("Region ShortName | 地区缩写,省级"),
field.String("code").Unique().Comment("Region Code | 地区行政编号"),
field.String("province").Default("").Comment("Province Code | 省级行政编号,表示该地区归属"),
field.String("city").Optional().Comment("City Code | 地级行政编号,表示该地区归属"),
field.String("area").Optional().Comment("Area Code | 县级行政编号,表示该地区归属"),
field.String("street").Optional().Comment("Street Code | 乡级行政编号,表示该地区归属"),
field.Uint32("level").Default(1).Comment("Region Level | 地区级别 1-省、自治区、直辖市 2-地级市、地区、自治州、盟 3-市辖区、县级市、县 4-乡镇"),
field.Float("latitude").Default(0).Comment("Latitude | 纬度"),
field.Float("longitude").Default(0).Comment("Longitude | 经度"),
}
}
func (District) Mixin() []ent.Mixin {
return []ent.Mixin{
mixins.TimeMixin{},
}
}
func (District) Edges() []ent.Edge {
return []ent.Edge{}
}
func (District) Indexes() []ent.Index {
return []ent.Index{}
}
func (District) Annotations() []schema.Annotation {
return []schema.Annotation{
entsql.WithComments(true),
entsql.Annotation{Table: "sys_district"},
schema.Comment("系统地区表(中国)"),
}
}