123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110 |
- package schema
- import (
- "entgo.io/ent"
- "entgo.io/ent/dialect/entsql"
- "entgo.io/ent/schema"
- "entgo.io/ent/schema/edge"
- "entgo.io/ent/schema/field"
- "entgo.io/ent/schema/index"
- "github.com/google/uuid"
- "sikey/w303a/http/internal/data/schematype"
- )
- type Child struct {
- ent.Schema
- }
- func (Child) Fields() []ent.Field {
- return []ent.Field{
- field.UUID("id", uuid.UUID{}).
- Default(uuid.New).
- SchemaType(schematype.UUID()).
- Unique().
- Comment("孩子ID"),
- field.String("child_name").
- MaxLen(125).
- SchemaType(schematype.String(125)).
- Comment("名字"),
- field.String("phone_number").
- MaxLen(125).
- NotEmpty().
- SchemaType(schematype.String(125)).
- Comment("手机号码"),
- field.String("area_code").
- Default("86").
- MaxLen(10).
- NotEmpty().
- SchemaType(schematype.String(10)).
- Comment("国际码"),
- field.String("avatar").
- MaxLen(512).
- Optional().
- Nillable().
- Comment("头像地址"),
- field.Int8("gender").
- Default(0).
- Max(3).
- Min(2).
- Comment("性别 2: 男 3: 女"),
- field.Int32("height").
- Default(120).
- Positive().
- Comment("身高 单位: cm"),
- field.Int32("weight").
- Default(100).
- Positive().
- Comment("体重 单位:g"),
- field.String("birthday").
- MaxLen(32).
- Optional().
- Nillable().
- Comment("生日"),
- field.Bool("is_enable_block_unknown_call").
- Default(true).
- Comment("是否拒接陌生人"),
- field.Bool("is_enable_fence").
- Default(false).
- Comment("是否开启围栏"),
- }
- }
- // Annotations of the Child.
- func (Child) Annotations() []schema.Annotation {
- return []schema.Annotation{
- entsql.Annotation{Table: "tb_child"},
- }
- }
- // Mixin of the Child.
- func (Child) Mixin() []ent.Mixin {
- return []ent.Mixin{
- TimeMixin{},
- }
- }
- // Edges of the Child.
- func (Child) Edges() []ent.Edge {
- return []ent.Edge{
- edge.To("childRefs", ChildRef.Type),
- edge.To("childDevice", DeviceBind.Type),
- edge.To("childContacts", Contacts.Type),
- }
- }
- // Indexes of the Child.
- func (Child) Indexes() []ent.Index {
- return []ent.Index{
- index.Fields("id").Unique(),
- }
- }
|