123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125 |
- // Code generated by ent, DO NOT EDIT.
- package ent
- import (
- "fmt"
- "strings"
- "wechat-api/ent/message"
- "entgo.io/ent"
- "entgo.io/ent/dialect/sql"
- )
- // Message is the model entity for the Message schema.
- type Message struct {
- config `json:"-"`
- // ID of the ent.
- ID int `json:"id,omitempty"`
- // 属主微信id
- WxWxid string `json:"wx_wxid,omitempty"`
- // 微信id 公众号微信ID
- Wxid string `json:"wxid,omitempty"`
- // 微信消息内容
- Content string `json:"content,omitempty"`
- selectValues sql.SelectValues
- }
- // scanValues returns the types for scanning values from sql.Rows.
- func (*Message) scanValues(columns []string) ([]any, error) {
- values := make([]any, len(columns))
- for i := range columns {
- switch columns[i] {
- case message.FieldID:
- values[i] = new(sql.NullInt64)
- case message.FieldWxWxid, message.FieldWxid, message.FieldContent:
- values[i] = new(sql.NullString)
- default:
- values[i] = new(sql.UnknownType)
- }
- }
- return values, nil
- }
- // assignValues assigns the values that were returned from sql.Rows (after scanning)
- // to the Message fields.
- func (m *Message) 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 message.FieldID:
- value, ok := values[i].(*sql.NullInt64)
- if !ok {
- return fmt.Errorf("unexpected type %T for field id", value)
- }
- m.ID = int(value.Int64)
- case message.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 {
- m.WxWxid = value.String
- }
- case message.FieldWxid:
- if value, ok := values[i].(*sql.NullString); !ok {
- return fmt.Errorf("unexpected type %T for field wxid", values[i])
- } else if value.Valid {
- m.Wxid = value.String
- }
- case message.FieldContent:
- if value, ok := values[i].(*sql.NullString); !ok {
- return fmt.Errorf("unexpected type %T for field content", values[i])
- } else if value.Valid {
- m.Content = value.String
- }
- default:
- m.selectValues.Set(columns[i], values[i])
- }
- }
- return nil
- }
- // Value returns the ent.Value that was dynamically selected and assigned to the Message.
- // This includes values selected through modifiers, order, etc.
- func (m *Message) Value(name string) (ent.Value, error) {
- return m.selectValues.Get(name)
- }
- // Update returns a builder for updating this Message.
- // Note that you need to call Message.Unwrap() before calling this method if this Message
- // was returned from a transaction, and the transaction was committed or rolled back.
- func (m *Message) Update() *MessageUpdateOne {
- return NewMessageClient(m.config).UpdateOne(m)
- }
- // Unwrap unwraps the Message 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 (m *Message) Unwrap() *Message {
- _tx, ok := m.config.driver.(*txDriver)
- if !ok {
- panic("ent: Message is not a transactional entity")
- }
- m.config.driver = _tx.drv
- return m
- }
- // String implements the fmt.Stringer.
- func (m *Message) String() string {
- var builder strings.Builder
- builder.WriteString("Message(")
- builder.WriteString(fmt.Sprintf("id=%v, ", m.ID))
- builder.WriteString("wx_wxid=")
- builder.WriteString(m.WxWxid)
- builder.WriteString(", ")
- builder.WriteString("wxid=")
- builder.WriteString(m.Wxid)
- builder.WriteString(", ")
- builder.WriteString("content=")
- builder.WriteString(m.Content)
- builder.WriteByte(')')
- return builder.String()
- }
- // Messages is a parsable slice of Message.
- type Messages []*Message
|