123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311 |
- // Code generated by ent, DO NOT EDIT.
- package ent
- import (
- "fmt"
- "sikey/w303a/http/internal/data/ent/child"
- "strings"
- "time"
- "entgo.io/ent"
- "entgo.io/ent/dialect/sql"
- "github.com/google/uuid"
- )
- // Child is the model entity for the Child schema.
- type Child struct {
- config `json:"-"`
- // ID of the ent.
- // 孩子ID
- ID uuid.UUID `json:"id,omitempty"`
- // 创建时间
- CreatedAt time.Time `json:"created_at,omitempty"`
- // 更新时间
- UpdatedAt time.Time `json:"updated_at,omitempty"`
- // 删除时间
- DeletedAt *time.Time `json:"deleted_at,omitempty"`
- // 名字
- ChildName string `json:"child_name,omitempty"`
- // 手机号码
- PhoneNumber string `json:"phone_number,omitempty"`
- // 国际码
- AreaCode string `json:"area_code,omitempty"`
- // 头像地址
- Avatar *string `json:"avatar,omitempty"`
- // 性别 2: 男 3: 女
- Gender int8 `json:"gender,omitempty"`
- // 身高 单位: cm
- Height int32 `json:"height,omitempty"`
- // 体重 单位:g
- Weight int32 `json:"weight,omitempty"`
- // 生日
- Birthday *string `json:"birthday,omitempty"`
- // 是否拒接陌生人
- IsEnableBlockUnknownCall bool `json:"is_enable_block_unknown_call,omitempty"`
- // 是否开启围栏
- IsEnableFence bool `json:"is_enable_fence,omitempty"`
- // Edges holds the relations/edges for other nodes in the graph.
- // The values are being populated by the ChildQuery when eager-loading is set.
- Edges ChildEdges `json:"edges"`
- selectValues sql.SelectValues
- }
- // ChildEdges holds the relations/edges for other nodes in the graph.
- type ChildEdges struct {
- // ChildRefs holds the value of the childRefs edge.
- ChildRefs []*ChildRef `json:"childRefs,omitempty"`
- // ChildDevice holds the value of the childDevice edge.
- ChildDevice []*DeviceBind `json:"childDevice,omitempty"`
- // ChildContacts holds the value of the childContacts edge.
- ChildContacts []*Contacts `json:"childContacts,omitempty"`
- // loadedTypes holds the information for reporting if a
- // type was loaded (or requested) in eager-loading or not.
- loadedTypes [3]bool
- }
- // ChildRefsOrErr returns the ChildRefs value or an error if the edge
- // was not loaded in eager-loading.
- func (e ChildEdges) ChildRefsOrErr() ([]*ChildRef, error) {
- if e.loadedTypes[0] {
- return e.ChildRefs, nil
- }
- return nil, &NotLoadedError{edge: "childRefs"}
- }
- // ChildDeviceOrErr returns the ChildDevice value or an error if the edge
- // was not loaded in eager-loading.
- func (e ChildEdges) ChildDeviceOrErr() ([]*DeviceBind, error) {
- if e.loadedTypes[1] {
- return e.ChildDevice, nil
- }
- return nil, &NotLoadedError{edge: "childDevice"}
- }
- // ChildContactsOrErr returns the ChildContacts value or an error if the edge
- // was not loaded in eager-loading.
- func (e ChildEdges) ChildContactsOrErr() ([]*Contacts, error) {
- if e.loadedTypes[2] {
- return e.ChildContacts, nil
- }
- return nil, &NotLoadedError{edge: "childContacts"}
- }
- // scanValues returns the types for scanning values from sql.Rows.
- func (*Child) scanValues(columns []string) ([]any, error) {
- values := make([]any, len(columns))
- for i := range columns {
- switch columns[i] {
- case child.FieldIsEnableBlockUnknownCall, child.FieldIsEnableFence:
- values[i] = new(sql.NullBool)
- case child.FieldGender, child.FieldHeight, child.FieldWeight:
- values[i] = new(sql.NullInt64)
- case child.FieldChildName, child.FieldPhoneNumber, child.FieldAreaCode, child.FieldAvatar, child.FieldBirthday:
- values[i] = new(sql.NullString)
- case child.FieldCreatedAt, child.FieldUpdatedAt, child.FieldDeletedAt:
- values[i] = new(sql.NullTime)
- case child.FieldID:
- values[i] = new(uuid.UUID)
- default:
- values[i] = new(sql.UnknownType)
- }
- }
- return values, nil
- }
- // assignValues assigns the values that were returned from sql.Rows (after scanning)
- // to the Child fields.
- func (c *Child) assignValues(columns []string, values []any) error {
- if m, n := len(values), len(columns); m < n {
- return fmt.Errorf("mismatch number of scan values: %d != %d", m, n)
- }
- for i := range columns {
- switch columns[i] {
- case child.FieldID:
- if value, ok := values[i].(*uuid.UUID); !ok {
- return fmt.Errorf("unexpected type %T for field id", values[i])
- } else if value != nil {
- c.ID = *value
- }
- case child.FieldCreatedAt:
- if value, ok := values[i].(*sql.NullTime); !ok {
- return fmt.Errorf("unexpected type %T for field created_at", values[i])
- } else if value.Valid {
- c.CreatedAt = value.Time
- }
- case child.FieldUpdatedAt:
- if value, ok := values[i].(*sql.NullTime); !ok {
- return fmt.Errorf("unexpected type %T for field updated_at", values[i])
- } else if value.Valid {
- c.UpdatedAt = value.Time
- }
- case child.FieldDeletedAt:
- if value, ok := values[i].(*sql.NullTime); !ok {
- return fmt.Errorf("unexpected type %T for field deleted_at", values[i])
- } else if value.Valid {
- c.DeletedAt = new(time.Time)
- *c.DeletedAt = value.Time
- }
- case child.FieldChildName:
- if value, ok := values[i].(*sql.NullString); !ok {
- return fmt.Errorf("unexpected type %T for field child_name", values[i])
- } else if value.Valid {
- c.ChildName = value.String
- }
- case child.FieldPhoneNumber:
- if value, ok := values[i].(*sql.NullString); !ok {
- return fmt.Errorf("unexpected type %T for field phone_number", values[i])
- } else if value.Valid {
- c.PhoneNumber = value.String
- }
- case child.FieldAreaCode:
- if value, ok := values[i].(*sql.NullString); !ok {
- return fmt.Errorf("unexpected type %T for field area_code", values[i])
- } else if value.Valid {
- c.AreaCode = value.String
- }
- case child.FieldAvatar:
- if value, ok := values[i].(*sql.NullString); !ok {
- return fmt.Errorf("unexpected type %T for field avatar", values[i])
- } else if value.Valid {
- c.Avatar = new(string)
- *c.Avatar = value.String
- }
- case child.FieldGender:
- if value, ok := values[i].(*sql.NullInt64); !ok {
- return fmt.Errorf("unexpected type %T for field gender", values[i])
- } else if value.Valid {
- c.Gender = int8(value.Int64)
- }
- case child.FieldHeight:
- if value, ok := values[i].(*sql.NullInt64); !ok {
- return fmt.Errorf("unexpected type %T for field height", values[i])
- } else if value.Valid {
- c.Height = int32(value.Int64)
- }
- case child.FieldWeight:
- if value, ok := values[i].(*sql.NullInt64); !ok {
- return fmt.Errorf("unexpected type %T for field weight", values[i])
- } else if value.Valid {
- c.Weight = int32(value.Int64)
- }
- case child.FieldBirthday:
- if value, ok := values[i].(*sql.NullString); !ok {
- return fmt.Errorf("unexpected type %T for field birthday", values[i])
- } else if value.Valid {
- c.Birthday = new(string)
- *c.Birthday = value.String
- }
- case child.FieldIsEnableBlockUnknownCall:
- if value, ok := values[i].(*sql.NullBool); !ok {
- return fmt.Errorf("unexpected type %T for field is_enable_block_unknown_call", values[i])
- } else if value.Valid {
- c.IsEnableBlockUnknownCall = value.Bool
- }
- case child.FieldIsEnableFence:
- if value, ok := values[i].(*sql.NullBool); !ok {
- return fmt.Errorf("unexpected type %T for field is_enable_fence", values[i])
- } else if value.Valid {
- c.IsEnableFence = value.Bool
- }
- default:
- c.selectValues.Set(columns[i], values[i])
- }
- }
- return nil
- }
- // Value returns the ent.Value that was dynamically selected and assigned to the Child.
- // This includes values selected through modifiers, order, etc.
- func (c *Child) Value(name string) (ent.Value, error) {
- return c.selectValues.Get(name)
- }
- // QueryChildRefs queries the "childRefs" edge of the Child entity.
- func (c *Child) QueryChildRefs() *ChildRefQuery {
- return NewChildClient(c.config).QueryChildRefs(c)
- }
- // QueryChildDevice queries the "childDevice" edge of the Child entity.
- func (c *Child) QueryChildDevice() *DeviceBindQuery {
- return NewChildClient(c.config).QueryChildDevice(c)
- }
- // QueryChildContacts queries the "childContacts" edge of the Child entity.
- func (c *Child) QueryChildContacts() *ContactsQuery {
- return NewChildClient(c.config).QueryChildContacts(c)
- }
- // Update returns a builder for updating this Child.
- // Note that you need to call Child.Unwrap() before calling this method if this Child
- // was returned from a transaction, and the transaction was committed or rolled back.
- func (c *Child) Update() *ChildUpdateOne {
- return NewChildClient(c.config).UpdateOne(c)
- }
- // Unwrap unwraps the Child entity that was returned from a transaction after it was closed,
- // so that all future queries will be executed through the driver which created the transaction.
- func (c *Child) Unwrap() *Child {
- _tx, ok := c.config.driver.(*txDriver)
- if !ok {
- panic("ent: Child is not a transactional entity")
- }
- c.config.driver = _tx.drv
- return c
- }
- // String implements the fmt.Stringer.
- func (c *Child) String() string {
- var builder strings.Builder
- builder.WriteString("Child(")
- builder.WriteString(fmt.Sprintf("id=%v, ", c.ID))
- builder.WriteString("created_at=")
- builder.WriteString(c.CreatedAt.Format(time.ANSIC))
- builder.WriteString(", ")
- builder.WriteString("updated_at=")
- builder.WriteString(c.UpdatedAt.Format(time.ANSIC))
- builder.WriteString(", ")
- if v := c.DeletedAt; v != nil {
- builder.WriteString("deleted_at=")
- builder.WriteString(v.Format(time.ANSIC))
- }
- builder.WriteString(", ")
- builder.WriteString("child_name=")
- builder.WriteString(c.ChildName)
- builder.WriteString(", ")
- builder.WriteString("phone_number=")
- builder.WriteString(c.PhoneNumber)
- builder.WriteString(", ")
- builder.WriteString("area_code=")
- builder.WriteString(c.AreaCode)
- builder.WriteString(", ")
- if v := c.Avatar; v != nil {
- builder.WriteString("avatar=")
- builder.WriteString(*v)
- }
- builder.WriteString(", ")
- builder.WriteString("gender=")
- builder.WriteString(fmt.Sprintf("%v", c.Gender))
- builder.WriteString(", ")
- builder.WriteString("height=")
- builder.WriteString(fmt.Sprintf("%v", c.Height))
- builder.WriteString(", ")
- builder.WriteString("weight=")
- builder.WriteString(fmt.Sprintf("%v", c.Weight))
- builder.WriteString(", ")
- if v := c.Birthday; v != nil {
- builder.WriteString("birthday=")
- builder.WriteString(*v)
- }
- builder.WriteString(", ")
- builder.WriteString("is_enable_block_unknown_call=")
- builder.WriteString(fmt.Sprintf("%v", c.IsEnableBlockUnknownCall))
- builder.WriteString(", ")
- builder.WriteString("is_enable_fence=")
- builder.WriteString(fmt.Sprintf("%v", c.IsEnableFence))
- builder.WriteByte(')')
- return builder.String()
- }
- // Childs is a parsable slice of Child.
- type Childs []*Child
|