123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216 |
- package ent
- import (
- "fmt"
- "strings"
- "time"
- "wechat-api/ent/msg"
- "entgo.io/ent"
- "entgo.io/ent/dialect/sql"
- )
- type Msg struct {
- config `json:"-"`
-
- ID uint64 `json:"id,omitempty"`
-
- CreatedAt time.Time `json:"created_at,omitempty"`
-
- UpdatedAt time.Time `json:"updated_at,omitempty"`
-
- DeletedAt time.Time `json:"deleted_at,omitempty"`
-
- Status uint8 `json:"status,omitempty"`
-
- Fromwxid string `json:"fromwxid,omitempty"`
-
- Toid string `json:"toid,omitempty"`
-
- Msgtype int32 `json:"msgtype,omitempty"`
-
- Msg string `json:"msg,omitempty"`
-
- BatchNo string `json:"batch_no,omitempty"`
-
- Cc string `json:"cc,omitempty"`
-
- Phone string `json:"phone,omitempty"`
- selectValues sql.SelectValues
- }
- func (*Msg) scanValues(columns []string) ([]any, error) {
- values := make([]any, len(columns))
- for i := range columns {
- switch columns[i] {
- case msg.FieldID, msg.FieldStatus, msg.FieldMsgtype:
- values[i] = new(sql.NullInt64)
- case msg.FieldFromwxid, msg.FieldToid, msg.FieldMsg, msg.FieldBatchNo, msg.FieldCc, msg.FieldPhone:
- values[i] = new(sql.NullString)
- case msg.FieldCreatedAt, msg.FieldUpdatedAt, msg.FieldDeletedAt:
- values[i] = new(sql.NullTime)
- default:
- values[i] = new(sql.UnknownType)
- }
- }
- return values, nil
- }
- func (m *Msg) 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 msg.FieldID:
- value, ok := values[i].(*sql.NullInt64)
- if !ok {
- return fmt.Errorf("unexpected type %T for field id", value)
- }
- m.ID = uint64(value.Int64)
- case msg.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 {
- m.CreatedAt = value.Time
- }
- case msg.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 {
- m.UpdatedAt = value.Time
- }
- case msg.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 {
- m.DeletedAt = value.Time
- }
- case msg.FieldStatus:
- if value, ok := values[i].(*sql.NullInt64); !ok {
- return fmt.Errorf("unexpected type %T for field status", values[i])
- } else if value.Valid {
- m.Status = uint8(value.Int64)
- }
- case msg.FieldFromwxid:
- if value, ok := values[i].(*sql.NullString); !ok {
- return fmt.Errorf("unexpected type %T for field fromwxid", values[i])
- } else if value.Valid {
- m.Fromwxid = value.String
- }
- case msg.FieldToid:
- if value, ok := values[i].(*sql.NullString); !ok {
- return fmt.Errorf("unexpected type %T for field toid", values[i])
- } else if value.Valid {
- m.Toid = value.String
- }
- case msg.FieldMsgtype:
- if value, ok := values[i].(*sql.NullInt64); !ok {
- return fmt.Errorf("unexpected type %T for field msgtype", values[i])
- } else if value.Valid {
- m.Msgtype = int32(value.Int64)
- }
- case msg.FieldMsg:
- if value, ok := values[i].(*sql.NullString); !ok {
- return fmt.Errorf("unexpected type %T for field msg", values[i])
- } else if value.Valid {
- m.Msg = value.String
- }
- case msg.FieldBatchNo:
- if value, ok := values[i].(*sql.NullString); !ok {
- return fmt.Errorf("unexpected type %T for field batch_no", values[i])
- } else if value.Valid {
- m.BatchNo = value.String
- }
- case msg.FieldCc:
- if value, ok := values[i].(*sql.NullString); !ok {
- return fmt.Errorf("unexpected type %T for field cc", values[i])
- } else if value.Valid {
- m.Cc = value.String
- }
- case msg.FieldPhone:
- if value, ok := values[i].(*sql.NullString); !ok {
- return fmt.Errorf("unexpected type %T for field phone", values[i])
- } else if value.Valid {
- m.Phone = value.String
- }
- default:
- m.selectValues.Set(columns[i], values[i])
- }
- }
- return nil
- }
- func (m *Msg) Value(name string) (ent.Value, error) {
- return m.selectValues.Get(name)
- }
- func (m *Msg) Update() *MsgUpdateOne {
- return NewMsgClient(m.config).UpdateOne(m)
- }
- func (m *Msg) Unwrap() *Msg {
- _tx, ok := m.config.driver.(*txDriver)
- if !ok {
- panic("ent: Msg is not a transactional entity")
- }
- m.config.driver = _tx.drv
- return m
- }
- func (m *Msg) String() string {
- var builder strings.Builder
- builder.WriteString("Msg(")
- builder.WriteString(fmt.Sprintf("id=%v, ", m.ID))
- builder.WriteString("created_at=")
- builder.WriteString(m.CreatedAt.Format(time.ANSIC))
- builder.WriteString(", ")
- builder.WriteString("updated_at=")
- builder.WriteString(m.UpdatedAt.Format(time.ANSIC))
- builder.WriteString(", ")
- builder.WriteString("deleted_at=")
- builder.WriteString(m.DeletedAt.Format(time.ANSIC))
- builder.WriteString(", ")
- builder.WriteString("status=")
- builder.WriteString(fmt.Sprintf("%v", m.Status))
- builder.WriteString(", ")
- builder.WriteString("fromwxid=")
- builder.WriteString(m.Fromwxid)
- builder.WriteString(", ")
- builder.WriteString("toid=")
- builder.WriteString(m.Toid)
- builder.WriteString(", ")
- builder.WriteString("msgtype=")
- builder.WriteString(fmt.Sprintf("%v", m.Msgtype))
- builder.WriteString(", ")
- builder.WriteString("msg=")
- builder.WriteString(m.Msg)
- builder.WriteString(", ")
- builder.WriteString("batch_no=")
- builder.WriteString(m.BatchNo)
- builder.WriteString(", ")
- builder.WriteString("cc=")
- builder.WriteString(m.Cc)
- builder.WriteString(", ")
- builder.WriteString("phone=")
- builder.WriteString(m.Phone)
- builder.WriteByte(')')
- return builder.String()
- }
- type Msgs []*Msg
|