123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467 |
- // Code generated by ent, DO NOT EDIT.
- package ent
- import (
- "fmt"
- "strings"
- "time"
- "wechat-api/ent/contact"
- "entgo.io/ent"
- "entgo.io/ent/dialect/sql"
- )
- // Contact is the model entity for the Contact schema.
- type Contact struct {
- config `json:"-"`
- // ID of the ent.
- ID uint64 `json:"id,omitempty"`
- // Create Time | 创建日期
- CreatedAt time.Time `json:"created_at,omitempty"`
- // Update Time | 修改日期
- UpdatedAt time.Time `json:"updated_at,omitempty"`
- // Status 1: normal 2: ban | 状态 1 正常 2 禁用
- Status uint8 `json:"status,omitempty"`
- // Delete Time | 删除日期
- DeletedAt time.Time `json:"deleted_at,omitempty"`
- // 属主微信id
- WxWxid string `json:"wx_wxid,omitempty"`
- // 联系人类型:1好友,2群组,3公众号,4企业微信联系人
- Type int `json:"type,omitempty"`
- // 微信id 公众号微信ID
- Wxid string `json:"wxid,omitempty"`
- // 微信账号
- Account string `json:"account,omitempty"`
- // 微信昵称 群备注名称
- Nickname string `json:"nickname,omitempty"`
- // 备注名
- Markname string `json:"markname,omitempty"`
- // 头像
- Headimg string `json:"headimg,omitempty"`
- // 性别 0未知 1男 2女
- Sex int `json:"sex,omitempty"`
- // 星标 65/67=星标 1/3=未星标
- Starrole string `json:"starrole,omitempty"`
- // 不让他看我的朋友圈 0可以看 1不让看
- Dontseeit int `json:"dontseeit,omitempty"`
- // 不看他的朋友圈 0可以看 1不看 1=开启了不看他 128/129=仅聊天
- Dontseeme int `json:"dontseeme,omitempty"`
- // 所属标签id清单,多开会用逗号隔开
- Lag string `json:"lag,omitempty"`
- // 群组id
- Gid string `json:"gid,omitempty"`
- // 群组名称
- Gname string `json:"gname,omitempty"`
- // v3数据
- V3 string `json:"v3,omitempty"`
- // 机构 ID
- OrganizationID uint64 `json:"organization_id,omitempty"`
- // 内容类型:1-微信 2-whatsapp
- Ctype uint64 `json:"ctype,omitempty"`
- // 年龄
- Cage int `json:"cage,omitempty"`
- // 姓名
- Cname string `json:"cname,omitempty"`
- // 地区
- Carea string `json:"carea,omitempty"`
- // 出生日期
- Cbirthday string `json:"cbirthday,omitempty"`
- // 出生地
- Cbirtharea string `json:"cbirtharea,omitempty"`
- // 身份证号
- CidcardNo string `json:"cidcard_no,omitempty"`
- // 称呼
- Ctitle string `json:"ctitle,omitempty"`
- // 国家区号
- Cc string `json:"cc,omitempty"`
- // 手机号
- Phone string `json:"phone,omitempty"`
- // Edges holds the relations/edges for other nodes in the graph.
- // The values are being populated by the ContactQuery when eager-loading is set.
- Edges ContactEdges `json:"edges"`
- selectValues sql.SelectValues
- }
- // ContactEdges holds the relations/edges for other nodes in the graph.
- type ContactEdges struct {
- // ContactRelationships holds the value of the contact_relationships edge.
- ContactRelationships []*LabelRelationship `json:"contact_relationships,omitempty"`
- // ContactMessages holds the value of the contact_messages edge.
- ContactMessages []*MessageRecords `json:"contact_messages,omitempty"`
- // loadedTypes holds the information for reporting if a
- // type was loaded (or requested) in eager-loading or not.
- loadedTypes [2]bool
- }
- // ContactRelationshipsOrErr returns the ContactRelationships value or an error if the edge
- // was not loaded in eager-loading.
- func (e ContactEdges) ContactRelationshipsOrErr() ([]*LabelRelationship, error) {
- if e.loadedTypes[0] {
- return e.ContactRelationships, nil
- }
- return nil, &NotLoadedError{edge: "contact_relationships"}
- }
- // ContactMessagesOrErr returns the ContactMessages value or an error if the edge
- // was not loaded in eager-loading.
- func (e ContactEdges) ContactMessagesOrErr() ([]*MessageRecords, error) {
- if e.loadedTypes[1] {
- return e.ContactMessages, nil
- }
- return nil, &NotLoadedError{edge: "contact_messages"}
- }
- // scanValues returns the types for scanning values from sql.Rows.
- func (*Contact) scanValues(columns []string) ([]any, error) {
- values := make([]any, len(columns))
- for i := range columns {
- switch columns[i] {
- case contact.FieldID, contact.FieldStatus, contact.FieldType, contact.FieldSex, contact.FieldDontseeit, contact.FieldDontseeme, contact.FieldOrganizationID, contact.FieldCtype, contact.FieldCage:
- values[i] = new(sql.NullInt64)
- case contact.FieldWxWxid, contact.FieldWxid, contact.FieldAccount, contact.FieldNickname, contact.FieldMarkname, contact.FieldHeadimg, contact.FieldStarrole, contact.FieldLag, contact.FieldGid, contact.FieldGname, contact.FieldV3, contact.FieldCname, contact.FieldCarea, contact.FieldCbirthday, contact.FieldCbirtharea, contact.FieldCidcardNo, contact.FieldCtitle, contact.FieldCc, contact.FieldPhone:
- values[i] = new(sql.NullString)
- case contact.FieldCreatedAt, contact.FieldUpdatedAt, contact.FieldDeletedAt:
- values[i] = new(sql.NullTime)
- default:
- values[i] = new(sql.UnknownType)
- }
- }
- return values, nil
- }
- // assignValues assigns the values that were returned from sql.Rows (after scanning)
- // to the Contact fields.
- func (c *Contact) 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 contact.FieldID:
- value, ok := values[i].(*sql.NullInt64)
- if !ok {
- return fmt.Errorf("unexpected type %T for field id", value)
- }
- c.ID = uint64(value.Int64)
- case contact.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 contact.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 contact.FieldStatus:
- if value, ok := values[i].(*sql.NullInt64); !ok {
- return fmt.Errorf("unexpected type %T for field status", values[i])
- } else if value.Valid {
- c.Status = uint8(value.Int64)
- }
- case contact.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 = value.Time
- }
- case contact.FieldWxWxid:
- if value, ok := values[i].(*sql.NullString); !ok {
- return fmt.Errorf("unexpected type %T for field wx_wxid", values[i])
- } else if value.Valid {
- c.WxWxid = value.String
- }
- case contact.FieldType:
- if value, ok := values[i].(*sql.NullInt64); !ok {
- return fmt.Errorf("unexpected type %T for field type", values[i])
- } else if value.Valid {
- c.Type = int(value.Int64)
- }
- case contact.FieldWxid:
- if value, ok := values[i].(*sql.NullString); !ok {
- return fmt.Errorf("unexpected type %T for field wxid", values[i])
- } else if value.Valid {
- c.Wxid = value.String
- }
- case contact.FieldAccount:
- if value, ok := values[i].(*sql.NullString); !ok {
- return fmt.Errorf("unexpected type %T for field account", values[i])
- } else if value.Valid {
- c.Account = value.String
- }
- case contact.FieldNickname:
- if value, ok := values[i].(*sql.NullString); !ok {
- return fmt.Errorf("unexpected type %T for field nickname", values[i])
- } else if value.Valid {
- c.Nickname = value.String
- }
- case contact.FieldMarkname:
- if value, ok := values[i].(*sql.NullString); !ok {
- return fmt.Errorf("unexpected type %T for field markname", values[i])
- } else if value.Valid {
- c.Markname = value.String
- }
- case contact.FieldHeadimg:
- if value, ok := values[i].(*sql.NullString); !ok {
- return fmt.Errorf("unexpected type %T for field headimg", values[i])
- } else if value.Valid {
- c.Headimg = value.String
- }
- case contact.FieldSex:
- if value, ok := values[i].(*sql.NullInt64); !ok {
- return fmt.Errorf("unexpected type %T for field sex", values[i])
- } else if value.Valid {
- c.Sex = int(value.Int64)
- }
- case contact.FieldStarrole:
- if value, ok := values[i].(*sql.NullString); !ok {
- return fmt.Errorf("unexpected type %T for field starrole", values[i])
- } else if value.Valid {
- c.Starrole = value.String
- }
- case contact.FieldDontseeit:
- if value, ok := values[i].(*sql.NullInt64); !ok {
- return fmt.Errorf("unexpected type %T for field dontseeit", values[i])
- } else if value.Valid {
- c.Dontseeit = int(value.Int64)
- }
- case contact.FieldDontseeme:
- if value, ok := values[i].(*sql.NullInt64); !ok {
- return fmt.Errorf("unexpected type %T for field dontseeme", values[i])
- } else if value.Valid {
- c.Dontseeme = int(value.Int64)
- }
- case contact.FieldLag:
- if value, ok := values[i].(*sql.NullString); !ok {
- return fmt.Errorf("unexpected type %T for field lag", values[i])
- } else if value.Valid {
- c.Lag = value.String
- }
- case contact.FieldGid:
- if value, ok := values[i].(*sql.NullString); !ok {
- return fmt.Errorf("unexpected type %T for field gid", values[i])
- } else if value.Valid {
- c.Gid = value.String
- }
- case contact.FieldGname:
- if value, ok := values[i].(*sql.NullString); !ok {
- return fmt.Errorf("unexpected type %T for field gname", values[i])
- } else if value.Valid {
- c.Gname = value.String
- }
- case contact.FieldV3:
- if value, ok := values[i].(*sql.NullString); !ok {
- return fmt.Errorf("unexpected type %T for field v3", values[i])
- } else if value.Valid {
- c.V3 = value.String
- }
- case contact.FieldOrganizationID:
- if value, ok := values[i].(*sql.NullInt64); !ok {
- return fmt.Errorf("unexpected type %T for field organization_id", values[i])
- } else if value.Valid {
- c.OrganizationID = uint64(value.Int64)
- }
- case contact.FieldCtype:
- if value, ok := values[i].(*sql.NullInt64); !ok {
- return fmt.Errorf("unexpected type %T for field ctype", values[i])
- } else if value.Valid {
- c.Ctype = uint64(value.Int64)
- }
- case contact.FieldCage:
- if value, ok := values[i].(*sql.NullInt64); !ok {
- return fmt.Errorf("unexpected type %T for field cage", values[i])
- } else if value.Valid {
- c.Cage = int(value.Int64)
- }
- case contact.FieldCname:
- if value, ok := values[i].(*sql.NullString); !ok {
- return fmt.Errorf("unexpected type %T for field cname", values[i])
- } else if value.Valid {
- c.Cname = value.String
- }
- case contact.FieldCarea:
- if value, ok := values[i].(*sql.NullString); !ok {
- return fmt.Errorf("unexpected type %T for field carea", values[i])
- } else if value.Valid {
- c.Carea = value.String
- }
- case contact.FieldCbirthday:
- if value, ok := values[i].(*sql.NullString); !ok {
- return fmt.Errorf("unexpected type %T for field cbirthday", values[i])
- } else if value.Valid {
- c.Cbirthday = value.String
- }
- case contact.FieldCbirtharea:
- if value, ok := values[i].(*sql.NullString); !ok {
- return fmt.Errorf("unexpected type %T for field cbirtharea", values[i])
- } else if value.Valid {
- c.Cbirtharea = value.String
- }
- case contact.FieldCidcardNo:
- if value, ok := values[i].(*sql.NullString); !ok {
- return fmt.Errorf("unexpected type %T for field cidcard_no", values[i])
- } else if value.Valid {
- c.CidcardNo = value.String
- }
- case contact.FieldCtitle:
- if value, ok := values[i].(*sql.NullString); !ok {
- return fmt.Errorf("unexpected type %T for field ctitle", values[i])
- } else if value.Valid {
- c.Ctitle = value.String
- }
- case contact.FieldCc:
- if value, ok := values[i].(*sql.NullString); !ok {
- return fmt.Errorf("unexpected type %T for field cc", values[i])
- } else if value.Valid {
- c.Cc = value.String
- }
- case contact.FieldPhone:
- if value, ok := values[i].(*sql.NullString); !ok {
- return fmt.Errorf("unexpected type %T for field phone", values[i])
- } else if value.Valid {
- c.Phone = value.String
- }
- default:
- c.selectValues.Set(columns[i], values[i])
- }
- }
- return nil
- }
- // Value returns the ent.Value that was dynamically selected and assigned to the Contact.
- // This includes values selected through modifiers, order, etc.
- func (c *Contact) Value(name string) (ent.Value, error) {
- return c.selectValues.Get(name)
- }
- // QueryContactRelationships queries the "contact_relationships" edge of the Contact entity.
- func (c *Contact) QueryContactRelationships() *LabelRelationshipQuery {
- return NewContactClient(c.config).QueryContactRelationships(c)
- }
- // QueryContactMessages queries the "contact_messages" edge of the Contact entity.
- func (c *Contact) QueryContactMessages() *MessageRecordsQuery {
- return NewContactClient(c.config).QueryContactMessages(c)
- }
- // Update returns a builder for updating this Contact.
- // Note that you need to call Contact.Unwrap() before calling this method if this Contact
- // was returned from a transaction, and the transaction was committed or rolled back.
- func (c *Contact) Update() *ContactUpdateOne {
- return NewContactClient(c.config).UpdateOne(c)
- }
- // Unwrap unwraps the Contact 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 *Contact) Unwrap() *Contact {
- _tx, ok := c.config.driver.(*txDriver)
- if !ok {
- panic("ent: Contact is not a transactional entity")
- }
- c.config.driver = _tx.drv
- return c
- }
- // String implements the fmt.Stringer.
- func (c *Contact) String() string {
- var builder strings.Builder
- builder.WriteString("Contact(")
- 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(", ")
- builder.WriteString("status=")
- builder.WriteString(fmt.Sprintf("%v", c.Status))
- builder.WriteString(", ")
- builder.WriteString("deleted_at=")
- builder.WriteString(c.DeletedAt.Format(time.ANSIC))
- builder.WriteString(", ")
- builder.WriteString("wx_wxid=")
- builder.WriteString(c.WxWxid)
- builder.WriteString(", ")
- builder.WriteString("type=")
- builder.WriteString(fmt.Sprintf("%v", c.Type))
- builder.WriteString(", ")
- builder.WriteString("wxid=")
- builder.WriteString(c.Wxid)
- builder.WriteString(", ")
- builder.WriteString("account=")
- builder.WriteString(c.Account)
- builder.WriteString(", ")
- builder.WriteString("nickname=")
- builder.WriteString(c.Nickname)
- builder.WriteString(", ")
- builder.WriteString("markname=")
- builder.WriteString(c.Markname)
- builder.WriteString(", ")
- builder.WriteString("headimg=")
- builder.WriteString(c.Headimg)
- builder.WriteString(", ")
- builder.WriteString("sex=")
- builder.WriteString(fmt.Sprintf("%v", c.Sex))
- builder.WriteString(", ")
- builder.WriteString("starrole=")
- builder.WriteString(c.Starrole)
- builder.WriteString(", ")
- builder.WriteString("dontseeit=")
- builder.WriteString(fmt.Sprintf("%v", c.Dontseeit))
- builder.WriteString(", ")
- builder.WriteString("dontseeme=")
- builder.WriteString(fmt.Sprintf("%v", c.Dontseeme))
- builder.WriteString(", ")
- builder.WriteString("lag=")
- builder.WriteString(c.Lag)
- builder.WriteString(", ")
- builder.WriteString("gid=")
- builder.WriteString(c.Gid)
- builder.WriteString(", ")
- builder.WriteString("gname=")
- builder.WriteString(c.Gname)
- builder.WriteString(", ")
- builder.WriteString("v3=")
- builder.WriteString(c.V3)
- builder.WriteString(", ")
- builder.WriteString("organization_id=")
- builder.WriteString(fmt.Sprintf("%v", c.OrganizationID))
- builder.WriteString(", ")
- builder.WriteString("ctype=")
- builder.WriteString(fmt.Sprintf("%v", c.Ctype))
- builder.WriteString(", ")
- builder.WriteString("cage=")
- builder.WriteString(fmt.Sprintf("%v", c.Cage))
- builder.WriteString(", ")
- builder.WriteString("cname=")
- builder.WriteString(c.Cname)
- builder.WriteString(", ")
- builder.WriteString("carea=")
- builder.WriteString(c.Carea)
- builder.WriteString(", ")
- builder.WriteString("cbirthday=")
- builder.WriteString(c.Cbirthday)
- builder.WriteString(", ")
- builder.WriteString("cbirtharea=")
- builder.WriteString(c.Cbirtharea)
- builder.WriteString(", ")
- builder.WriteString("cidcard_no=")
- builder.WriteString(c.CidcardNo)
- builder.WriteString(", ")
- builder.WriteString("ctitle=")
- builder.WriteString(c.Ctitle)
- builder.WriteString(", ")
- builder.WriteString("cc=")
- builder.WriteString(c.Cc)
- builder.WriteString(", ")
- builder.WriteString("phone=")
- builder.WriteString(c.Phone)
- builder.WriteByte(')')
- return builder.String()
- }
- // Contacts is a parsable slice of Contact.
- type Contacts []*Contact
|