Browse Source

增加msg表

DESKTOP-53URE31\USER 8 months ago
parent
commit
6d3b0a9196
18 changed files with 4888 additions and 6 deletions
  1. 147 6
      ent/client.go
  2. 2 0
      ent/ent.go
  3. 12 0
      ent/hook/hook.go
  4. 30 0
      ent/intercept/intercept.go
  5. 40 0
      ent/migrate/schema.go
  6. 194 0
      ent/msg.go
  7. 111 0
      ent/msg/msg.go
  8. 645 0
      ent/msg/where.go
  9. 1124 0
      ent/msg_create.go
  10. 88 0
      ent/msg_delete.go
  11. 526 0
      ent/msg_query.go
  12. 648 0
      ent/msg_update.go
  13. 973 0
      ent/mutation.go
  14. 82 0
      ent/pagination.go
  15. 3 0
      ent/predicate/predicate.go
  16. 44 0
      ent/schema/msg.go
  17. 216 0
      ent/set_not_nil.go
  18. 3 0
      ent/tx.go

+ 147 - 6
ent/client.go

@@ -17,6 +17,7 @@ import (
 	"wechat-api/ent/labelrelationship"
 	"wechat-api/ent/message"
 	"wechat-api/ent/messagerecords"
+	"wechat-api/ent/msg"
 	"wechat-api/ent/server"
 	"wechat-api/ent/sopnode"
 	"wechat-api/ent/sopstage"
@@ -48,6 +49,8 @@ type Client struct {
 	Message *MessageClient
 	// MessageRecords is the client for interacting with the MessageRecords builders.
 	MessageRecords *MessageRecordsClient
+	// Msg is the client for interacting with the Msg builders.
+	Msg *MsgClient
 	// Server is the client for interacting with the Server builders.
 	Server *ServerClient
 	// SopNode is the client for interacting with the SopNode builders.
@@ -75,6 +78,7 @@ func (c *Client) init() {
 	c.LabelRelationship = NewLabelRelationshipClient(c.config)
 	c.Message = NewMessageClient(c.config)
 	c.MessageRecords = NewMessageRecordsClient(c.config)
+	c.Msg = NewMsgClient(c.config)
 	c.Server = NewServerClient(c.config)
 	c.SopNode = NewSopNodeClient(c.config)
 	c.SopStage = NewSopStageClient(c.config)
@@ -178,6 +182,7 @@ func (c *Client) Tx(ctx context.Context) (*Tx, error) {
 		LabelRelationship: NewLabelRelationshipClient(cfg),
 		Message:           NewMessageClient(cfg),
 		MessageRecords:    NewMessageRecordsClient(cfg),
+		Msg:               NewMsgClient(cfg),
 		Server:            NewServerClient(cfg),
 		SopNode:           NewSopNodeClient(cfg),
 		SopStage:          NewSopStageClient(cfg),
@@ -208,6 +213,7 @@ func (c *Client) BeginTx(ctx context.Context, opts *sql.TxOptions) (*Tx, error)
 		LabelRelationship: NewLabelRelationshipClient(cfg),
 		Message:           NewMessageClient(cfg),
 		MessageRecords:    NewMessageRecordsClient(cfg),
+		Msg:               NewMsgClient(cfg),
 		Server:            NewServerClient(cfg),
 		SopNode:           NewSopNodeClient(cfg),
 		SopStage:          NewSopStageClient(cfg),
@@ -243,7 +249,7 @@ func (c *Client) Close() error {
 func (c *Client) Use(hooks ...Hook) {
 	for _, n := range []interface{ Use(...Hook) }{
 		c.BatchMsg, c.Contact, c.Label, c.LabelRelationship, c.Message,
-		c.MessageRecords, c.Server, c.SopNode, c.SopStage, c.SopTask, c.Wx,
+		c.MessageRecords, c.Msg, c.Server, c.SopNode, c.SopStage, c.SopTask, c.Wx,
 	} {
 		n.Use(hooks...)
 	}
@@ -254,7 +260,7 @@ func (c *Client) Use(hooks ...Hook) {
 func (c *Client) Intercept(interceptors ...Interceptor) {
 	for _, n := range []interface{ Intercept(...Interceptor) }{
 		c.BatchMsg, c.Contact, c.Label, c.LabelRelationship, c.Message,
-		c.MessageRecords, c.Server, c.SopNode, c.SopStage, c.SopTask, c.Wx,
+		c.MessageRecords, c.Msg, c.Server, c.SopNode, c.SopStage, c.SopTask, c.Wx,
 	} {
 		n.Intercept(interceptors...)
 	}
@@ -275,6 +281,8 @@ func (c *Client) Mutate(ctx context.Context, m Mutation) (Value, error) {
 		return c.Message.mutate(ctx, m)
 	case *MessageRecordsMutation:
 		return c.MessageRecords.mutate(ctx, m)
+	case *MsgMutation:
+		return c.Msg.mutate(ctx, m)
 	case *ServerMutation:
 		return c.Server.mutate(ctx, m)
 	case *SopNodeMutation:
@@ -1226,6 +1234,139 @@ func (c *MessageRecordsClient) mutate(ctx context.Context, m *MessageRecordsMuta
 	}
 }
 
+// MsgClient is a client for the Msg schema.
+type MsgClient struct {
+	config
+}
+
+// NewMsgClient returns a client for the Msg from the given config.
+func NewMsgClient(c config) *MsgClient {
+	return &MsgClient{config: c}
+}
+
+// Use adds a list of mutation hooks to the hooks stack.
+// A call to `Use(f, g, h)` equals to `msg.Hooks(f(g(h())))`.
+func (c *MsgClient) Use(hooks ...Hook) {
+	c.hooks.Msg = append(c.hooks.Msg, hooks...)
+}
+
+// Intercept adds a list of query interceptors to the interceptors stack.
+// A call to `Intercept(f, g, h)` equals to `msg.Intercept(f(g(h())))`.
+func (c *MsgClient) Intercept(interceptors ...Interceptor) {
+	c.inters.Msg = append(c.inters.Msg, interceptors...)
+}
+
+// Create returns a builder for creating a Msg entity.
+func (c *MsgClient) Create() *MsgCreate {
+	mutation := newMsgMutation(c.config, OpCreate)
+	return &MsgCreate{config: c.config, hooks: c.Hooks(), mutation: mutation}
+}
+
+// CreateBulk returns a builder for creating a bulk of Msg entities.
+func (c *MsgClient) CreateBulk(builders ...*MsgCreate) *MsgCreateBulk {
+	return &MsgCreateBulk{config: c.config, builders: builders}
+}
+
+// MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates
+// a builder and applies setFunc on it.
+func (c *MsgClient) MapCreateBulk(slice any, setFunc func(*MsgCreate, int)) *MsgCreateBulk {
+	rv := reflect.ValueOf(slice)
+	if rv.Kind() != reflect.Slice {
+		return &MsgCreateBulk{err: fmt.Errorf("calling to MsgClient.MapCreateBulk with wrong type %T, need slice", slice)}
+	}
+	builders := make([]*MsgCreate, rv.Len())
+	for i := 0; i < rv.Len(); i++ {
+		builders[i] = c.Create()
+		setFunc(builders[i], i)
+	}
+	return &MsgCreateBulk{config: c.config, builders: builders}
+}
+
+// Update returns an update builder for Msg.
+func (c *MsgClient) Update() *MsgUpdate {
+	mutation := newMsgMutation(c.config, OpUpdate)
+	return &MsgUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation}
+}
+
+// UpdateOne returns an update builder for the given entity.
+func (c *MsgClient) UpdateOne(m *Msg) *MsgUpdateOne {
+	mutation := newMsgMutation(c.config, OpUpdateOne, withMsg(m))
+	return &MsgUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
+}
+
+// UpdateOneID returns an update builder for the given id.
+func (c *MsgClient) UpdateOneID(id int) *MsgUpdateOne {
+	mutation := newMsgMutation(c.config, OpUpdateOne, withMsgID(id))
+	return &MsgUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
+}
+
+// Delete returns a delete builder for Msg.
+func (c *MsgClient) Delete() *MsgDelete {
+	mutation := newMsgMutation(c.config, OpDelete)
+	return &MsgDelete{config: c.config, hooks: c.Hooks(), mutation: mutation}
+}
+
+// DeleteOne returns a builder for deleting the given entity.
+func (c *MsgClient) DeleteOne(m *Msg) *MsgDeleteOne {
+	return c.DeleteOneID(m.ID)
+}
+
+// DeleteOneID returns a builder for deleting the given entity by its id.
+func (c *MsgClient) DeleteOneID(id int) *MsgDeleteOne {
+	builder := c.Delete().Where(msg.ID(id))
+	builder.mutation.id = &id
+	builder.mutation.op = OpDeleteOne
+	return &MsgDeleteOne{builder}
+}
+
+// Query returns a query builder for Msg.
+func (c *MsgClient) Query() *MsgQuery {
+	return &MsgQuery{
+		config: c.config,
+		ctx:    &QueryContext{Type: TypeMsg},
+		inters: c.Interceptors(),
+	}
+}
+
+// Get returns a Msg entity by its id.
+func (c *MsgClient) Get(ctx context.Context, id int) (*Msg, error) {
+	return c.Query().Where(msg.ID(id)).Only(ctx)
+}
+
+// GetX is like Get, but panics if an error occurs.
+func (c *MsgClient) GetX(ctx context.Context, id int) *Msg {
+	obj, err := c.Get(ctx, id)
+	if err != nil {
+		panic(err)
+	}
+	return obj
+}
+
+// Hooks returns the client hooks.
+func (c *MsgClient) Hooks() []Hook {
+	return c.hooks.Msg
+}
+
+// Interceptors returns the client interceptors.
+func (c *MsgClient) Interceptors() []Interceptor {
+	return c.inters.Msg
+}
+
+func (c *MsgClient) mutate(ctx context.Context, m *MsgMutation) (Value, error) {
+	switch m.Op() {
+	case OpCreate:
+		return (&MsgCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
+	case OpUpdate:
+		return (&MsgUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
+	case OpUpdateOne:
+		return (&MsgUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
+	case OpDelete, OpDeleteOne:
+		return (&MsgDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx)
+	default:
+		return nil, fmt.Errorf("ent: unknown Msg mutation op: %q", m.Op())
+	}
+}
+
 // ServerClient is a client for the Server schema.
 type ServerClient struct {
 	config
@@ -2032,12 +2173,12 @@ func (c *WxClient) mutate(ctx context.Context, m *WxMutation) (Value, error) {
 // hooks and interceptors per client, for fast access.
 type (
 	hooks struct {
-		BatchMsg, Contact, Label, LabelRelationship, Message, MessageRecords, Server,
-		SopNode, SopStage, SopTask, Wx []ent.Hook
+		BatchMsg, Contact, Label, LabelRelationship, Message, MessageRecords, Msg,
+		Server, SopNode, SopStage, SopTask, Wx []ent.Hook
 	}
 	inters struct {
-		BatchMsg, Contact, Label, LabelRelationship, Message, MessageRecords, Server,
-		SopNode, SopStage, SopTask, Wx []ent.Interceptor
+		BatchMsg, Contact, Label, LabelRelationship, Message, MessageRecords, Msg,
+		Server, SopNode, SopStage, SopTask, Wx []ent.Interceptor
 	}
 )
 

+ 2 - 0
ent/ent.go

@@ -14,6 +14,7 @@ import (
 	"wechat-api/ent/labelrelationship"
 	"wechat-api/ent/message"
 	"wechat-api/ent/messagerecords"
+	"wechat-api/ent/msg"
 	"wechat-api/ent/server"
 	"wechat-api/ent/sopnode"
 	"wechat-api/ent/sopstage"
@@ -89,6 +90,7 @@ func checkColumn(table, column string) error {
 			labelrelationship.Table: labelrelationship.ValidColumn,
 			message.Table:           message.ValidColumn,
 			messagerecords.Table:    messagerecords.ValidColumn,
+			msg.Table:               msg.ValidColumn,
 			server.Table:            server.ValidColumn,
 			sopnode.Table:           sopnode.ValidColumn,
 			sopstage.Table:          sopstage.ValidColumn,

+ 12 - 0
ent/hook/hook.go

@@ -80,6 +80,18 @@ func (f MessageRecordsFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.Val
 	return nil, fmt.Errorf("unexpected mutation type %T. expect *ent.MessageRecordsMutation", m)
 }
 
+// The MsgFunc type is an adapter to allow the use of ordinary
+// function as Msg mutator.
+type MsgFunc func(context.Context, *ent.MsgMutation) (ent.Value, error)
+
+// Mutate calls f(ctx, m).
+func (f MsgFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.Value, error) {
+	if mv, ok := m.(*ent.MsgMutation); ok {
+		return f(ctx, mv)
+	}
+	return nil, fmt.Errorf("unexpected mutation type %T. expect *ent.MsgMutation", m)
+}
+
 // The ServerFunc type is an adapter to allow the use of ordinary
 // function as Server mutator.
 type ServerFunc func(context.Context, *ent.ServerMutation) (ent.Value, error)

+ 30 - 0
ent/intercept/intercept.go

@@ -12,6 +12,7 @@ import (
 	"wechat-api/ent/labelrelationship"
 	"wechat-api/ent/message"
 	"wechat-api/ent/messagerecords"
+	"wechat-api/ent/msg"
 	"wechat-api/ent/predicate"
 	"wechat-api/ent/server"
 	"wechat-api/ent/sopnode"
@@ -240,6 +241,33 @@ func (f TraverseMessageRecords) Traverse(ctx context.Context, q ent.Query) error
 	return fmt.Errorf("unexpected query type %T. expect *ent.MessageRecordsQuery", q)
 }
 
+// The MsgFunc type is an adapter to allow the use of ordinary function as a Querier.
+type MsgFunc func(context.Context, *ent.MsgQuery) (ent.Value, error)
+
+// Query calls f(ctx, q).
+func (f MsgFunc) Query(ctx context.Context, q ent.Query) (ent.Value, error) {
+	if q, ok := q.(*ent.MsgQuery); ok {
+		return f(ctx, q)
+	}
+	return nil, fmt.Errorf("unexpected query type %T. expect *ent.MsgQuery", q)
+}
+
+// The TraverseMsg type is an adapter to allow the use of ordinary function as Traverser.
+type TraverseMsg func(context.Context, *ent.MsgQuery) error
+
+// Intercept is a dummy implementation of Intercept that returns the next Querier in the pipeline.
+func (f TraverseMsg) Intercept(next ent.Querier) ent.Querier {
+	return next
+}
+
+// Traverse calls f(ctx, q).
+func (f TraverseMsg) Traverse(ctx context.Context, q ent.Query) error {
+	if q, ok := q.(*ent.MsgQuery); ok {
+		return f(ctx, q)
+	}
+	return fmt.Errorf("unexpected query type %T. expect *ent.MsgQuery", q)
+}
+
 // The ServerFunc type is an adapter to allow the use of ordinary function as a Querier.
 type ServerFunc func(context.Context, *ent.ServerQuery) (ent.Value, error)
 
@@ -390,6 +418,8 @@ func NewQuery(q ent.Query) (Query, error) {
 		return &query[*ent.MessageQuery, predicate.Message, message.OrderOption]{typ: ent.TypeMessage, tq: q}, nil
 	case *ent.MessageRecordsQuery:
 		return &query[*ent.MessageRecordsQuery, predicate.MessageRecords, messagerecords.OrderOption]{typ: ent.TypeMessageRecords, tq: q}, nil
+	case *ent.MsgQuery:
+		return &query[*ent.MsgQuery, predicate.Msg, msg.OrderOption]{typ: ent.TypeMsg, tq: q}, nil
 	case *ent.ServerQuery:
 		return &query[*ent.ServerQuery, predicate.Server, server.OrderOption]{typ: ent.TypeServer, tq: q}, nil
 	case *ent.SopNodeQuery:

+ 40 - 0
ent/migrate/schema.go

@@ -224,6 +224,42 @@ var (
 			},
 		},
 	}
+	// MsgColumns holds the columns for the "msg" table.
+	MsgColumns = []*schema.Column{
+		{Name: "id", Type: field.TypeInt, Increment: true},
+		{Name: "created_at", Type: field.TypeTime, Comment: "Create Time | 创建日期"},
+		{Name: "updated_at", Type: field.TypeTime, Comment: "Update Time | 修改日期"},
+		{Name: "deleted_at", Type: field.TypeTime, Nullable: true, Comment: "Delete Time | 删除日期"},
+		{Name: "status", Type: field.TypeUint8, Nullable: true, Comment: "Status 1: normal 2: ban | 状态 1 正常 2 禁用"},
+		{Name: "fromwxid", Type: field.TypeString, Nullable: true, Comment: "发送方微信ID"},
+		{Name: "toid", Type: field.TypeString, Nullable: true, Comment: "接收人微信ID/群ID"},
+		{Name: "msgtype", Type: field.TypeInt32, Nullable: true, Comment: "消息类型"},
+		{Name: "msg", Type: field.TypeString, Nullable: true, Comment: "消息"},
+		{Name: "batch_no", Type: field.TypeString, Nullable: true, Comment: "批次号"},
+	}
+	// MsgTable holds the schema information for the "msg" table.
+	MsgTable = &schema.Table{
+		Name:       "msg",
+		Columns:    MsgColumns,
+		PrimaryKey: []*schema.Column{MsgColumns[0]},
+		Indexes: []*schema.Index{
+			{
+				Name:    "msg_batch_no",
+				Unique:  false,
+				Columns: []*schema.Column{MsgColumns[9]},
+			},
+			{
+				Name:    "msg_id",
+				Unique:  false,
+				Columns: []*schema.Column{MsgColumns[0]},
+			},
+			{
+				Name:    "msg_status",
+				Unique:  false,
+				Columns: []*schema.Column{MsgColumns[4]},
+			},
+		},
+	}
 	// ServerColumns holds the columns for the "server" table.
 	ServerColumns = []*schema.Column{
 		{Name: "id", Type: field.TypeUint64, Increment: true},
@@ -426,6 +462,7 @@ var (
 		LabelRelationshipTable,
 		MessagesTable,
 		MessageRecordsTable,
+		MsgTable,
 		ServerTable,
 		SopNodeTable,
 		SopStageTable,
@@ -458,6 +495,9 @@ func init() {
 	MessageRecordsTable.Annotation = &entsql.Annotation{
 		Table: "message_records",
 	}
+	MsgTable.Annotation = &entsql.Annotation{
+		Table: "msg",
+	}
 	ServerTable.Annotation = &entsql.Annotation{
 		Table: "server",
 	}

+ 194 - 0
ent/msg.go

@@ -0,0 +1,194 @@
+// Code generated by ent, DO NOT EDIT.
+
+package ent
+
+import (
+	"fmt"
+	"strings"
+	"time"
+	"wechat-api/ent/msg"
+
+	"entgo.io/ent"
+	"entgo.io/ent/dialect/sql"
+)
+
+// Msg is the model entity for the Msg schema.
+type Msg struct {
+	config `json:"-"`
+	// ID of the ent.
+	ID int `json:"id,omitempty"`
+	// Create Time | 创建日期
+	CreatedAt time.Time `json:"created_at,omitempty"`
+	// Update Time | 修改日期
+	UpdatedAt time.Time `json:"updated_at,omitempty"`
+	// Delete Time | 删除日期
+	DeletedAt time.Time `json:"deleted_at,omitempty"`
+	// Status 1: normal 2: ban | 状态 1 正常 2 禁用
+	Status uint8 `json:"status,omitempty"`
+	// 发送方微信ID
+	Fromwxid string `json:"fromwxid,omitempty"`
+	// 接收人微信ID/群ID
+	Toid string `json:"toid,omitempty"`
+	// 消息类型
+	Msgtype int32 `json:"msgtype,omitempty"`
+	// 消息
+	Msg string `json:"msg,omitempty"`
+	// 批次号
+	BatchNo      string `json:"batch_no,omitempty"`
+	selectValues sql.SelectValues
+}
+
+// scanValues returns the types for scanning values from sql.Rows.
+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:
+			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
+}
+
+// assignValues assigns the values that were returned from sql.Rows (after scanning)
+// to the Msg fields.
+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 = int(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
+			}
+		default:
+			m.selectValues.Set(columns[i], values[i])
+		}
+	}
+	return nil
+}
+
+// Value returns the ent.Value that was dynamically selected and assigned to the Msg.
+// This includes values selected through modifiers, order, etc.
+func (m *Msg) Value(name string) (ent.Value, error) {
+	return m.selectValues.Get(name)
+}
+
+// Update returns a builder for updating this Msg.
+// Note that you need to call Msg.Unwrap() before calling this method if this Msg
+// was returned from a transaction, and the transaction was committed or rolled back.
+func (m *Msg) Update() *MsgUpdateOne {
+	return NewMsgClient(m.config).UpdateOne(m)
+}
+
+// Unwrap unwraps the Msg 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 *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
+}
+
+// String implements the fmt.Stringer.
+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.WriteByte(')')
+	return builder.String()
+}
+
+// Msgs is a parsable slice of Msg.
+type Msgs []*Msg

+ 111 - 0
ent/msg/msg.go

@@ -0,0 +1,111 @@
+// Code generated by ent, DO NOT EDIT.
+
+package msg
+
+import (
+	"entgo.io/ent/dialect/sql"
+)
+
+const (
+	// Label holds the string label denoting the msg type in the database.
+	Label = "msg"
+	// FieldID holds the string denoting the id field in the database.
+	FieldID = "id"
+	// FieldCreatedAt holds the string denoting the created_at field in the database.
+	FieldCreatedAt = "created_at"
+	// FieldUpdatedAt holds the string denoting the updated_at field in the database.
+	FieldUpdatedAt = "updated_at"
+	// FieldDeletedAt holds the string denoting the deleted_at field in the database.
+	FieldDeletedAt = "deleted_at"
+	// FieldStatus holds the string denoting the status field in the database.
+	FieldStatus = "status"
+	// FieldFromwxid holds the string denoting the fromwxid field in the database.
+	FieldFromwxid = "fromwxid"
+	// FieldToid holds the string denoting the toid field in the database.
+	FieldToid = "toid"
+	// FieldMsgtype holds the string denoting the msgtype field in the database.
+	FieldMsgtype = "msgtype"
+	// FieldMsg holds the string denoting the msg field in the database.
+	FieldMsg = "msg"
+	// FieldBatchNo holds the string denoting the batch_no field in the database.
+	FieldBatchNo = "batch_no"
+	// Table holds the table name of the msg in the database.
+	Table = "msg"
+)
+
+// Columns holds all SQL columns for msg fields.
+var Columns = []string{
+	FieldID,
+	FieldCreatedAt,
+	FieldUpdatedAt,
+	FieldDeletedAt,
+	FieldStatus,
+	FieldFromwxid,
+	FieldToid,
+	FieldMsgtype,
+	FieldMsg,
+	FieldBatchNo,
+}
+
+// ValidColumn reports if the column name is valid (part of the table columns).
+func ValidColumn(column string) bool {
+	for i := range Columns {
+		if column == Columns[i] {
+			return true
+		}
+	}
+	return false
+}
+
+// OrderOption defines the ordering options for the Msg queries.
+type OrderOption func(*sql.Selector)
+
+// ByID orders the results by the id field.
+func ByID(opts ...sql.OrderTermOption) OrderOption {
+	return sql.OrderByField(FieldID, opts...).ToFunc()
+}
+
+// ByCreatedAt orders the results by the created_at field.
+func ByCreatedAt(opts ...sql.OrderTermOption) OrderOption {
+	return sql.OrderByField(FieldCreatedAt, opts...).ToFunc()
+}
+
+// ByUpdatedAt orders the results by the updated_at field.
+func ByUpdatedAt(opts ...sql.OrderTermOption) OrderOption {
+	return sql.OrderByField(FieldUpdatedAt, opts...).ToFunc()
+}
+
+// ByDeletedAt orders the results by the deleted_at field.
+func ByDeletedAt(opts ...sql.OrderTermOption) OrderOption {
+	return sql.OrderByField(FieldDeletedAt, opts...).ToFunc()
+}
+
+// ByStatus orders the results by the status field.
+func ByStatus(opts ...sql.OrderTermOption) OrderOption {
+	return sql.OrderByField(FieldStatus, opts...).ToFunc()
+}
+
+// ByFromwxid orders the results by the fromwxid field.
+func ByFromwxid(opts ...sql.OrderTermOption) OrderOption {
+	return sql.OrderByField(FieldFromwxid, opts...).ToFunc()
+}
+
+// ByToid orders the results by the toid field.
+func ByToid(opts ...sql.OrderTermOption) OrderOption {
+	return sql.OrderByField(FieldToid, opts...).ToFunc()
+}
+
+// ByMsgtype orders the results by the msgtype field.
+func ByMsgtype(opts ...sql.OrderTermOption) OrderOption {
+	return sql.OrderByField(FieldMsgtype, opts...).ToFunc()
+}
+
+// ByMsg orders the results by the msg field.
+func ByMsg(opts ...sql.OrderTermOption) OrderOption {
+	return sql.OrderByField(FieldMsg, opts...).ToFunc()
+}
+
+// ByBatchNo orders the results by the batch_no field.
+func ByBatchNo(opts ...sql.OrderTermOption) OrderOption {
+	return sql.OrderByField(FieldBatchNo, opts...).ToFunc()
+}

+ 645 - 0
ent/msg/where.go

@@ -0,0 +1,645 @@
+// Code generated by ent, DO NOT EDIT.
+
+package msg
+
+import (
+	"time"
+	"wechat-api/ent/predicate"
+
+	"entgo.io/ent/dialect/sql"
+)
+
+// ID filters vertices based on their ID field.
+func ID(id int) predicate.Msg {
+	return predicate.Msg(sql.FieldEQ(FieldID, id))
+}
+
+// IDEQ applies the EQ predicate on the ID field.
+func IDEQ(id int) predicate.Msg {
+	return predicate.Msg(sql.FieldEQ(FieldID, id))
+}
+
+// IDNEQ applies the NEQ predicate on the ID field.
+func IDNEQ(id int) predicate.Msg {
+	return predicate.Msg(sql.FieldNEQ(FieldID, id))
+}
+
+// IDIn applies the In predicate on the ID field.
+func IDIn(ids ...int) predicate.Msg {
+	return predicate.Msg(sql.FieldIn(FieldID, ids...))
+}
+
+// IDNotIn applies the NotIn predicate on the ID field.
+func IDNotIn(ids ...int) predicate.Msg {
+	return predicate.Msg(sql.FieldNotIn(FieldID, ids...))
+}
+
+// IDGT applies the GT predicate on the ID field.
+func IDGT(id int) predicate.Msg {
+	return predicate.Msg(sql.FieldGT(FieldID, id))
+}
+
+// IDGTE applies the GTE predicate on the ID field.
+func IDGTE(id int) predicate.Msg {
+	return predicate.Msg(sql.FieldGTE(FieldID, id))
+}
+
+// IDLT applies the LT predicate on the ID field.
+func IDLT(id int) predicate.Msg {
+	return predicate.Msg(sql.FieldLT(FieldID, id))
+}
+
+// IDLTE applies the LTE predicate on the ID field.
+func IDLTE(id int) predicate.Msg {
+	return predicate.Msg(sql.FieldLTE(FieldID, id))
+}
+
+// CreatedAt applies equality check predicate on the "created_at" field. It's identical to CreatedAtEQ.
+func CreatedAt(v time.Time) predicate.Msg {
+	return predicate.Msg(sql.FieldEQ(FieldCreatedAt, v))
+}
+
+// UpdatedAt applies equality check predicate on the "updated_at" field. It's identical to UpdatedAtEQ.
+func UpdatedAt(v time.Time) predicate.Msg {
+	return predicate.Msg(sql.FieldEQ(FieldUpdatedAt, v))
+}
+
+// DeletedAt applies equality check predicate on the "deleted_at" field. It's identical to DeletedAtEQ.
+func DeletedAt(v time.Time) predicate.Msg {
+	return predicate.Msg(sql.FieldEQ(FieldDeletedAt, v))
+}
+
+// Status applies equality check predicate on the "status" field. It's identical to StatusEQ.
+func Status(v uint8) predicate.Msg {
+	return predicate.Msg(sql.FieldEQ(FieldStatus, v))
+}
+
+// Fromwxid applies equality check predicate on the "fromwxid" field. It's identical to FromwxidEQ.
+func Fromwxid(v string) predicate.Msg {
+	return predicate.Msg(sql.FieldEQ(FieldFromwxid, v))
+}
+
+// Toid applies equality check predicate on the "toid" field. It's identical to ToidEQ.
+func Toid(v string) predicate.Msg {
+	return predicate.Msg(sql.FieldEQ(FieldToid, v))
+}
+
+// Msgtype applies equality check predicate on the "msgtype" field. It's identical to MsgtypeEQ.
+func Msgtype(v int32) predicate.Msg {
+	return predicate.Msg(sql.FieldEQ(FieldMsgtype, v))
+}
+
+// Msg applies equality check predicate on the "msg" field. It's identical to MsgEQ.
+func Msg(v string) predicate.Msg {
+	return predicate.Msg(sql.FieldEQ(FieldMsg, v))
+}
+
+// BatchNo applies equality check predicate on the "batch_no" field. It's identical to BatchNoEQ.
+func BatchNo(v string) predicate.Msg {
+	return predicate.Msg(sql.FieldEQ(FieldBatchNo, v))
+}
+
+// CreatedAtEQ applies the EQ predicate on the "created_at" field.
+func CreatedAtEQ(v time.Time) predicate.Msg {
+	return predicate.Msg(sql.FieldEQ(FieldCreatedAt, v))
+}
+
+// CreatedAtNEQ applies the NEQ predicate on the "created_at" field.
+func CreatedAtNEQ(v time.Time) predicate.Msg {
+	return predicate.Msg(sql.FieldNEQ(FieldCreatedAt, v))
+}
+
+// CreatedAtIn applies the In predicate on the "created_at" field.
+func CreatedAtIn(vs ...time.Time) predicate.Msg {
+	return predicate.Msg(sql.FieldIn(FieldCreatedAt, vs...))
+}
+
+// CreatedAtNotIn applies the NotIn predicate on the "created_at" field.
+func CreatedAtNotIn(vs ...time.Time) predicate.Msg {
+	return predicate.Msg(sql.FieldNotIn(FieldCreatedAt, vs...))
+}
+
+// CreatedAtGT applies the GT predicate on the "created_at" field.
+func CreatedAtGT(v time.Time) predicate.Msg {
+	return predicate.Msg(sql.FieldGT(FieldCreatedAt, v))
+}
+
+// CreatedAtGTE applies the GTE predicate on the "created_at" field.
+func CreatedAtGTE(v time.Time) predicate.Msg {
+	return predicate.Msg(sql.FieldGTE(FieldCreatedAt, v))
+}
+
+// CreatedAtLT applies the LT predicate on the "created_at" field.
+func CreatedAtLT(v time.Time) predicate.Msg {
+	return predicate.Msg(sql.FieldLT(FieldCreatedAt, v))
+}
+
+// CreatedAtLTE applies the LTE predicate on the "created_at" field.
+func CreatedAtLTE(v time.Time) predicate.Msg {
+	return predicate.Msg(sql.FieldLTE(FieldCreatedAt, v))
+}
+
+// UpdatedAtEQ applies the EQ predicate on the "updated_at" field.
+func UpdatedAtEQ(v time.Time) predicate.Msg {
+	return predicate.Msg(sql.FieldEQ(FieldUpdatedAt, v))
+}
+
+// UpdatedAtNEQ applies the NEQ predicate on the "updated_at" field.
+func UpdatedAtNEQ(v time.Time) predicate.Msg {
+	return predicate.Msg(sql.FieldNEQ(FieldUpdatedAt, v))
+}
+
+// UpdatedAtIn applies the In predicate on the "updated_at" field.
+func UpdatedAtIn(vs ...time.Time) predicate.Msg {
+	return predicate.Msg(sql.FieldIn(FieldUpdatedAt, vs...))
+}
+
+// UpdatedAtNotIn applies the NotIn predicate on the "updated_at" field.
+func UpdatedAtNotIn(vs ...time.Time) predicate.Msg {
+	return predicate.Msg(sql.FieldNotIn(FieldUpdatedAt, vs...))
+}
+
+// UpdatedAtGT applies the GT predicate on the "updated_at" field.
+func UpdatedAtGT(v time.Time) predicate.Msg {
+	return predicate.Msg(sql.FieldGT(FieldUpdatedAt, v))
+}
+
+// UpdatedAtGTE applies the GTE predicate on the "updated_at" field.
+func UpdatedAtGTE(v time.Time) predicate.Msg {
+	return predicate.Msg(sql.FieldGTE(FieldUpdatedAt, v))
+}
+
+// UpdatedAtLT applies the LT predicate on the "updated_at" field.
+func UpdatedAtLT(v time.Time) predicate.Msg {
+	return predicate.Msg(sql.FieldLT(FieldUpdatedAt, v))
+}
+
+// UpdatedAtLTE applies the LTE predicate on the "updated_at" field.
+func UpdatedAtLTE(v time.Time) predicate.Msg {
+	return predicate.Msg(sql.FieldLTE(FieldUpdatedAt, v))
+}
+
+// DeletedAtEQ applies the EQ predicate on the "deleted_at" field.
+func DeletedAtEQ(v time.Time) predicate.Msg {
+	return predicate.Msg(sql.FieldEQ(FieldDeletedAt, v))
+}
+
+// DeletedAtNEQ applies the NEQ predicate on the "deleted_at" field.
+func DeletedAtNEQ(v time.Time) predicate.Msg {
+	return predicate.Msg(sql.FieldNEQ(FieldDeletedAt, v))
+}
+
+// DeletedAtIn applies the In predicate on the "deleted_at" field.
+func DeletedAtIn(vs ...time.Time) predicate.Msg {
+	return predicate.Msg(sql.FieldIn(FieldDeletedAt, vs...))
+}
+
+// DeletedAtNotIn applies the NotIn predicate on the "deleted_at" field.
+func DeletedAtNotIn(vs ...time.Time) predicate.Msg {
+	return predicate.Msg(sql.FieldNotIn(FieldDeletedAt, vs...))
+}
+
+// DeletedAtGT applies the GT predicate on the "deleted_at" field.
+func DeletedAtGT(v time.Time) predicate.Msg {
+	return predicate.Msg(sql.FieldGT(FieldDeletedAt, v))
+}
+
+// DeletedAtGTE applies the GTE predicate on the "deleted_at" field.
+func DeletedAtGTE(v time.Time) predicate.Msg {
+	return predicate.Msg(sql.FieldGTE(FieldDeletedAt, v))
+}
+
+// DeletedAtLT applies the LT predicate on the "deleted_at" field.
+func DeletedAtLT(v time.Time) predicate.Msg {
+	return predicate.Msg(sql.FieldLT(FieldDeletedAt, v))
+}
+
+// DeletedAtLTE applies the LTE predicate on the "deleted_at" field.
+func DeletedAtLTE(v time.Time) predicate.Msg {
+	return predicate.Msg(sql.FieldLTE(FieldDeletedAt, v))
+}
+
+// DeletedAtIsNil applies the IsNil predicate on the "deleted_at" field.
+func DeletedAtIsNil() predicate.Msg {
+	return predicate.Msg(sql.FieldIsNull(FieldDeletedAt))
+}
+
+// DeletedAtNotNil applies the NotNil predicate on the "deleted_at" field.
+func DeletedAtNotNil() predicate.Msg {
+	return predicate.Msg(sql.FieldNotNull(FieldDeletedAt))
+}
+
+// StatusEQ applies the EQ predicate on the "status" field.
+func StatusEQ(v uint8) predicate.Msg {
+	return predicate.Msg(sql.FieldEQ(FieldStatus, v))
+}
+
+// StatusNEQ applies the NEQ predicate on the "status" field.
+func StatusNEQ(v uint8) predicate.Msg {
+	return predicate.Msg(sql.FieldNEQ(FieldStatus, v))
+}
+
+// StatusIn applies the In predicate on the "status" field.
+func StatusIn(vs ...uint8) predicate.Msg {
+	return predicate.Msg(sql.FieldIn(FieldStatus, vs...))
+}
+
+// StatusNotIn applies the NotIn predicate on the "status" field.
+func StatusNotIn(vs ...uint8) predicate.Msg {
+	return predicate.Msg(sql.FieldNotIn(FieldStatus, vs...))
+}
+
+// StatusGT applies the GT predicate on the "status" field.
+func StatusGT(v uint8) predicate.Msg {
+	return predicate.Msg(sql.FieldGT(FieldStatus, v))
+}
+
+// StatusGTE applies the GTE predicate on the "status" field.
+func StatusGTE(v uint8) predicate.Msg {
+	return predicate.Msg(sql.FieldGTE(FieldStatus, v))
+}
+
+// StatusLT applies the LT predicate on the "status" field.
+func StatusLT(v uint8) predicate.Msg {
+	return predicate.Msg(sql.FieldLT(FieldStatus, v))
+}
+
+// StatusLTE applies the LTE predicate on the "status" field.
+func StatusLTE(v uint8) predicate.Msg {
+	return predicate.Msg(sql.FieldLTE(FieldStatus, v))
+}
+
+// StatusIsNil applies the IsNil predicate on the "status" field.
+func StatusIsNil() predicate.Msg {
+	return predicate.Msg(sql.FieldIsNull(FieldStatus))
+}
+
+// StatusNotNil applies the NotNil predicate on the "status" field.
+func StatusNotNil() predicate.Msg {
+	return predicate.Msg(sql.FieldNotNull(FieldStatus))
+}
+
+// FromwxidEQ applies the EQ predicate on the "fromwxid" field.
+func FromwxidEQ(v string) predicate.Msg {
+	return predicate.Msg(sql.FieldEQ(FieldFromwxid, v))
+}
+
+// FromwxidNEQ applies the NEQ predicate on the "fromwxid" field.
+func FromwxidNEQ(v string) predicate.Msg {
+	return predicate.Msg(sql.FieldNEQ(FieldFromwxid, v))
+}
+
+// FromwxidIn applies the In predicate on the "fromwxid" field.
+func FromwxidIn(vs ...string) predicate.Msg {
+	return predicate.Msg(sql.FieldIn(FieldFromwxid, vs...))
+}
+
+// FromwxidNotIn applies the NotIn predicate on the "fromwxid" field.
+func FromwxidNotIn(vs ...string) predicate.Msg {
+	return predicate.Msg(sql.FieldNotIn(FieldFromwxid, vs...))
+}
+
+// FromwxidGT applies the GT predicate on the "fromwxid" field.
+func FromwxidGT(v string) predicate.Msg {
+	return predicate.Msg(sql.FieldGT(FieldFromwxid, v))
+}
+
+// FromwxidGTE applies the GTE predicate on the "fromwxid" field.
+func FromwxidGTE(v string) predicate.Msg {
+	return predicate.Msg(sql.FieldGTE(FieldFromwxid, v))
+}
+
+// FromwxidLT applies the LT predicate on the "fromwxid" field.
+func FromwxidLT(v string) predicate.Msg {
+	return predicate.Msg(sql.FieldLT(FieldFromwxid, v))
+}
+
+// FromwxidLTE applies the LTE predicate on the "fromwxid" field.
+func FromwxidLTE(v string) predicate.Msg {
+	return predicate.Msg(sql.FieldLTE(FieldFromwxid, v))
+}
+
+// FromwxidContains applies the Contains predicate on the "fromwxid" field.
+func FromwxidContains(v string) predicate.Msg {
+	return predicate.Msg(sql.FieldContains(FieldFromwxid, v))
+}
+
+// FromwxidHasPrefix applies the HasPrefix predicate on the "fromwxid" field.
+func FromwxidHasPrefix(v string) predicate.Msg {
+	return predicate.Msg(sql.FieldHasPrefix(FieldFromwxid, v))
+}
+
+// FromwxidHasSuffix applies the HasSuffix predicate on the "fromwxid" field.
+func FromwxidHasSuffix(v string) predicate.Msg {
+	return predicate.Msg(sql.FieldHasSuffix(FieldFromwxid, v))
+}
+
+// FromwxidIsNil applies the IsNil predicate on the "fromwxid" field.
+func FromwxidIsNil() predicate.Msg {
+	return predicate.Msg(sql.FieldIsNull(FieldFromwxid))
+}
+
+// FromwxidNotNil applies the NotNil predicate on the "fromwxid" field.
+func FromwxidNotNil() predicate.Msg {
+	return predicate.Msg(sql.FieldNotNull(FieldFromwxid))
+}
+
+// FromwxidEqualFold applies the EqualFold predicate on the "fromwxid" field.
+func FromwxidEqualFold(v string) predicate.Msg {
+	return predicate.Msg(sql.FieldEqualFold(FieldFromwxid, v))
+}
+
+// FromwxidContainsFold applies the ContainsFold predicate on the "fromwxid" field.
+func FromwxidContainsFold(v string) predicate.Msg {
+	return predicate.Msg(sql.FieldContainsFold(FieldFromwxid, v))
+}
+
+// ToidEQ applies the EQ predicate on the "toid" field.
+func ToidEQ(v string) predicate.Msg {
+	return predicate.Msg(sql.FieldEQ(FieldToid, v))
+}
+
+// ToidNEQ applies the NEQ predicate on the "toid" field.
+func ToidNEQ(v string) predicate.Msg {
+	return predicate.Msg(sql.FieldNEQ(FieldToid, v))
+}
+
+// ToidIn applies the In predicate on the "toid" field.
+func ToidIn(vs ...string) predicate.Msg {
+	return predicate.Msg(sql.FieldIn(FieldToid, vs...))
+}
+
+// ToidNotIn applies the NotIn predicate on the "toid" field.
+func ToidNotIn(vs ...string) predicate.Msg {
+	return predicate.Msg(sql.FieldNotIn(FieldToid, vs...))
+}
+
+// ToidGT applies the GT predicate on the "toid" field.
+func ToidGT(v string) predicate.Msg {
+	return predicate.Msg(sql.FieldGT(FieldToid, v))
+}
+
+// ToidGTE applies the GTE predicate on the "toid" field.
+func ToidGTE(v string) predicate.Msg {
+	return predicate.Msg(sql.FieldGTE(FieldToid, v))
+}
+
+// ToidLT applies the LT predicate on the "toid" field.
+func ToidLT(v string) predicate.Msg {
+	return predicate.Msg(sql.FieldLT(FieldToid, v))
+}
+
+// ToidLTE applies the LTE predicate on the "toid" field.
+func ToidLTE(v string) predicate.Msg {
+	return predicate.Msg(sql.FieldLTE(FieldToid, v))
+}
+
+// ToidContains applies the Contains predicate on the "toid" field.
+func ToidContains(v string) predicate.Msg {
+	return predicate.Msg(sql.FieldContains(FieldToid, v))
+}
+
+// ToidHasPrefix applies the HasPrefix predicate on the "toid" field.
+func ToidHasPrefix(v string) predicate.Msg {
+	return predicate.Msg(sql.FieldHasPrefix(FieldToid, v))
+}
+
+// ToidHasSuffix applies the HasSuffix predicate on the "toid" field.
+func ToidHasSuffix(v string) predicate.Msg {
+	return predicate.Msg(sql.FieldHasSuffix(FieldToid, v))
+}
+
+// ToidIsNil applies the IsNil predicate on the "toid" field.
+func ToidIsNil() predicate.Msg {
+	return predicate.Msg(sql.FieldIsNull(FieldToid))
+}
+
+// ToidNotNil applies the NotNil predicate on the "toid" field.
+func ToidNotNil() predicate.Msg {
+	return predicate.Msg(sql.FieldNotNull(FieldToid))
+}
+
+// ToidEqualFold applies the EqualFold predicate on the "toid" field.
+func ToidEqualFold(v string) predicate.Msg {
+	return predicate.Msg(sql.FieldEqualFold(FieldToid, v))
+}
+
+// ToidContainsFold applies the ContainsFold predicate on the "toid" field.
+func ToidContainsFold(v string) predicate.Msg {
+	return predicate.Msg(sql.FieldContainsFold(FieldToid, v))
+}
+
+// MsgtypeEQ applies the EQ predicate on the "msgtype" field.
+func MsgtypeEQ(v int32) predicate.Msg {
+	return predicate.Msg(sql.FieldEQ(FieldMsgtype, v))
+}
+
+// MsgtypeNEQ applies the NEQ predicate on the "msgtype" field.
+func MsgtypeNEQ(v int32) predicate.Msg {
+	return predicate.Msg(sql.FieldNEQ(FieldMsgtype, v))
+}
+
+// MsgtypeIn applies the In predicate on the "msgtype" field.
+func MsgtypeIn(vs ...int32) predicate.Msg {
+	return predicate.Msg(sql.FieldIn(FieldMsgtype, vs...))
+}
+
+// MsgtypeNotIn applies the NotIn predicate on the "msgtype" field.
+func MsgtypeNotIn(vs ...int32) predicate.Msg {
+	return predicate.Msg(sql.FieldNotIn(FieldMsgtype, vs...))
+}
+
+// MsgtypeGT applies the GT predicate on the "msgtype" field.
+func MsgtypeGT(v int32) predicate.Msg {
+	return predicate.Msg(sql.FieldGT(FieldMsgtype, v))
+}
+
+// MsgtypeGTE applies the GTE predicate on the "msgtype" field.
+func MsgtypeGTE(v int32) predicate.Msg {
+	return predicate.Msg(sql.FieldGTE(FieldMsgtype, v))
+}
+
+// MsgtypeLT applies the LT predicate on the "msgtype" field.
+func MsgtypeLT(v int32) predicate.Msg {
+	return predicate.Msg(sql.FieldLT(FieldMsgtype, v))
+}
+
+// MsgtypeLTE applies the LTE predicate on the "msgtype" field.
+func MsgtypeLTE(v int32) predicate.Msg {
+	return predicate.Msg(sql.FieldLTE(FieldMsgtype, v))
+}
+
+// MsgtypeIsNil applies the IsNil predicate on the "msgtype" field.
+func MsgtypeIsNil() predicate.Msg {
+	return predicate.Msg(sql.FieldIsNull(FieldMsgtype))
+}
+
+// MsgtypeNotNil applies the NotNil predicate on the "msgtype" field.
+func MsgtypeNotNil() predicate.Msg {
+	return predicate.Msg(sql.FieldNotNull(FieldMsgtype))
+}
+
+// MsgEQ applies the EQ predicate on the "msg" field.
+func MsgEQ(v string) predicate.Msg {
+	return predicate.Msg(sql.FieldEQ(FieldMsg, v))
+}
+
+// MsgNEQ applies the NEQ predicate on the "msg" field.
+func MsgNEQ(v string) predicate.Msg {
+	return predicate.Msg(sql.FieldNEQ(FieldMsg, v))
+}
+
+// MsgIn applies the In predicate on the "msg" field.
+func MsgIn(vs ...string) predicate.Msg {
+	return predicate.Msg(sql.FieldIn(FieldMsg, vs...))
+}
+
+// MsgNotIn applies the NotIn predicate on the "msg" field.
+func MsgNotIn(vs ...string) predicate.Msg {
+	return predicate.Msg(sql.FieldNotIn(FieldMsg, vs...))
+}
+
+// MsgGT applies the GT predicate on the "msg" field.
+func MsgGT(v string) predicate.Msg {
+	return predicate.Msg(sql.FieldGT(FieldMsg, v))
+}
+
+// MsgGTE applies the GTE predicate on the "msg" field.
+func MsgGTE(v string) predicate.Msg {
+	return predicate.Msg(sql.FieldGTE(FieldMsg, v))
+}
+
+// MsgLT applies the LT predicate on the "msg" field.
+func MsgLT(v string) predicate.Msg {
+	return predicate.Msg(sql.FieldLT(FieldMsg, v))
+}
+
+// MsgLTE applies the LTE predicate on the "msg" field.
+func MsgLTE(v string) predicate.Msg {
+	return predicate.Msg(sql.FieldLTE(FieldMsg, v))
+}
+
+// MsgContains applies the Contains predicate on the "msg" field.
+func MsgContains(v string) predicate.Msg {
+	return predicate.Msg(sql.FieldContains(FieldMsg, v))
+}
+
+// MsgHasPrefix applies the HasPrefix predicate on the "msg" field.
+func MsgHasPrefix(v string) predicate.Msg {
+	return predicate.Msg(sql.FieldHasPrefix(FieldMsg, v))
+}
+
+// MsgHasSuffix applies the HasSuffix predicate on the "msg" field.
+func MsgHasSuffix(v string) predicate.Msg {
+	return predicate.Msg(sql.FieldHasSuffix(FieldMsg, v))
+}
+
+// MsgIsNil applies the IsNil predicate on the "msg" field.
+func MsgIsNil() predicate.Msg {
+	return predicate.Msg(sql.FieldIsNull(FieldMsg))
+}
+
+// MsgNotNil applies the NotNil predicate on the "msg" field.
+func MsgNotNil() predicate.Msg {
+	return predicate.Msg(sql.FieldNotNull(FieldMsg))
+}
+
+// MsgEqualFold applies the EqualFold predicate on the "msg" field.
+func MsgEqualFold(v string) predicate.Msg {
+	return predicate.Msg(sql.FieldEqualFold(FieldMsg, v))
+}
+
+// MsgContainsFold applies the ContainsFold predicate on the "msg" field.
+func MsgContainsFold(v string) predicate.Msg {
+	return predicate.Msg(sql.FieldContainsFold(FieldMsg, v))
+}
+
+// BatchNoEQ applies the EQ predicate on the "batch_no" field.
+func BatchNoEQ(v string) predicate.Msg {
+	return predicate.Msg(sql.FieldEQ(FieldBatchNo, v))
+}
+
+// BatchNoNEQ applies the NEQ predicate on the "batch_no" field.
+func BatchNoNEQ(v string) predicate.Msg {
+	return predicate.Msg(sql.FieldNEQ(FieldBatchNo, v))
+}
+
+// BatchNoIn applies the In predicate on the "batch_no" field.
+func BatchNoIn(vs ...string) predicate.Msg {
+	return predicate.Msg(sql.FieldIn(FieldBatchNo, vs...))
+}
+
+// BatchNoNotIn applies the NotIn predicate on the "batch_no" field.
+func BatchNoNotIn(vs ...string) predicate.Msg {
+	return predicate.Msg(sql.FieldNotIn(FieldBatchNo, vs...))
+}
+
+// BatchNoGT applies the GT predicate on the "batch_no" field.
+func BatchNoGT(v string) predicate.Msg {
+	return predicate.Msg(sql.FieldGT(FieldBatchNo, v))
+}
+
+// BatchNoGTE applies the GTE predicate on the "batch_no" field.
+func BatchNoGTE(v string) predicate.Msg {
+	return predicate.Msg(sql.FieldGTE(FieldBatchNo, v))
+}
+
+// BatchNoLT applies the LT predicate on the "batch_no" field.
+func BatchNoLT(v string) predicate.Msg {
+	return predicate.Msg(sql.FieldLT(FieldBatchNo, v))
+}
+
+// BatchNoLTE applies the LTE predicate on the "batch_no" field.
+func BatchNoLTE(v string) predicate.Msg {
+	return predicate.Msg(sql.FieldLTE(FieldBatchNo, v))
+}
+
+// BatchNoContains applies the Contains predicate on the "batch_no" field.
+func BatchNoContains(v string) predicate.Msg {
+	return predicate.Msg(sql.FieldContains(FieldBatchNo, v))
+}
+
+// BatchNoHasPrefix applies the HasPrefix predicate on the "batch_no" field.
+func BatchNoHasPrefix(v string) predicate.Msg {
+	return predicate.Msg(sql.FieldHasPrefix(FieldBatchNo, v))
+}
+
+// BatchNoHasSuffix applies the HasSuffix predicate on the "batch_no" field.
+func BatchNoHasSuffix(v string) predicate.Msg {
+	return predicate.Msg(sql.FieldHasSuffix(FieldBatchNo, v))
+}
+
+// BatchNoIsNil applies the IsNil predicate on the "batch_no" field.
+func BatchNoIsNil() predicate.Msg {
+	return predicate.Msg(sql.FieldIsNull(FieldBatchNo))
+}
+
+// BatchNoNotNil applies the NotNil predicate on the "batch_no" field.
+func BatchNoNotNil() predicate.Msg {
+	return predicate.Msg(sql.FieldNotNull(FieldBatchNo))
+}
+
+// BatchNoEqualFold applies the EqualFold predicate on the "batch_no" field.
+func BatchNoEqualFold(v string) predicate.Msg {
+	return predicate.Msg(sql.FieldEqualFold(FieldBatchNo, v))
+}
+
+// BatchNoContainsFold applies the ContainsFold predicate on the "batch_no" field.
+func BatchNoContainsFold(v string) predicate.Msg {
+	return predicate.Msg(sql.FieldContainsFold(FieldBatchNo, v))
+}
+
+// And groups predicates with the AND operator between them.
+func And(predicates ...predicate.Msg) predicate.Msg {
+	return predicate.Msg(sql.AndPredicates(predicates...))
+}
+
+// Or groups predicates with the OR operator between them.
+func Or(predicates ...predicate.Msg) predicate.Msg {
+	return predicate.Msg(sql.OrPredicates(predicates...))
+}
+
+// Not applies the not operator on the given predicate.
+func Not(p predicate.Msg) predicate.Msg {
+	return predicate.Msg(sql.NotPredicates(p))
+}

+ 1124 - 0
ent/msg_create.go

@@ -0,0 +1,1124 @@
+// Code generated by ent, DO NOT EDIT.
+
+package ent
+
+import (
+	"context"
+	"errors"
+	"fmt"
+	"time"
+	"wechat-api/ent/msg"
+
+	"entgo.io/ent/dialect/sql"
+	"entgo.io/ent/dialect/sql/sqlgraph"
+	"entgo.io/ent/schema/field"
+)
+
+// MsgCreate is the builder for creating a Msg entity.
+type MsgCreate struct {
+	config
+	mutation *MsgMutation
+	hooks    []Hook
+	conflict []sql.ConflictOption
+}
+
+// SetCreatedAt sets the "created_at" field.
+func (mc *MsgCreate) SetCreatedAt(t time.Time) *MsgCreate {
+	mc.mutation.SetCreatedAt(t)
+	return mc
+}
+
+// SetUpdatedAt sets the "updated_at" field.
+func (mc *MsgCreate) SetUpdatedAt(t time.Time) *MsgCreate {
+	mc.mutation.SetUpdatedAt(t)
+	return mc
+}
+
+// SetDeletedAt sets the "deleted_at" field.
+func (mc *MsgCreate) SetDeletedAt(t time.Time) *MsgCreate {
+	mc.mutation.SetDeletedAt(t)
+	return mc
+}
+
+// SetNillableDeletedAt sets the "deleted_at" field if the given value is not nil.
+func (mc *MsgCreate) SetNillableDeletedAt(t *time.Time) *MsgCreate {
+	if t != nil {
+		mc.SetDeletedAt(*t)
+	}
+	return mc
+}
+
+// SetStatus sets the "status" field.
+func (mc *MsgCreate) SetStatus(u uint8) *MsgCreate {
+	mc.mutation.SetStatus(u)
+	return mc
+}
+
+// SetNillableStatus sets the "status" field if the given value is not nil.
+func (mc *MsgCreate) SetNillableStatus(u *uint8) *MsgCreate {
+	if u != nil {
+		mc.SetStatus(*u)
+	}
+	return mc
+}
+
+// SetFromwxid sets the "fromwxid" field.
+func (mc *MsgCreate) SetFromwxid(s string) *MsgCreate {
+	mc.mutation.SetFromwxid(s)
+	return mc
+}
+
+// SetNillableFromwxid sets the "fromwxid" field if the given value is not nil.
+func (mc *MsgCreate) SetNillableFromwxid(s *string) *MsgCreate {
+	if s != nil {
+		mc.SetFromwxid(*s)
+	}
+	return mc
+}
+
+// SetToid sets the "toid" field.
+func (mc *MsgCreate) SetToid(s string) *MsgCreate {
+	mc.mutation.SetToid(s)
+	return mc
+}
+
+// SetNillableToid sets the "toid" field if the given value is not nil.
+func (mc *MsgCreate) SetNillableToid(s *string) *MsgCreate {
+	if s != nil {
+		mc.SetToid(*s)
+	}
+	return mc
+}
+
+// SetMsgtype sets the "msgtype" field.
+func (mc *MsgCreate) SetMsgtype(i int32) *MsgCreate {
+	mc.mutation.SetMsgtype(i)
+	return mc
+}
+
+// SetNillableMsgtype sets the "msgtype" field if the given value is not nil.
+func (mc *MsgCreate) SetNillableMsgtype(i *int32) *MsgCreate {
+	if i != nil {
+		mc.SetMsgtype(*i)
+	}
+	return mc
+}
+
+// SetMsg sets the "msg" field.
+func (mc *MsgCreate) SetMsg(s string) *MsgCreate {
+	mc.mutation.SetMsg(s)
+	return mc
+}
+
+// SetNillableMsg sets the "msg" field if the given value is not nil.
+func (mc *MsgCreate) SetNillableMsg(s *string) *MsgCreate {
+	if s != nil {
+		mc.SetMsg(*s)
+	}
+	return mc
+}
+
+// SetBatchNo sets the "batch_no" field.
+func (mc *MsgCreate) SetBatchNo(s string) *MsgCreate {
+	mc.mutation.SetBatchNo(s)
+	return mc
+}
+
+// SetNillableBatchNo sets the "batch_no" field if the given value is not nil.
+func (mc *MsgCreate) SetNillableBatchNo(s *string) *MsgCreate {
+	if s != nil {
+		mc.SetBatchNo(*s)
+	}
+	return mc
+}
+
+// SetID sets the "id" field.
+func (mc *MsgCreate) SetID(i int) *MsgCreate {
+	mc.mutation.SetID(i)
+	return mc
+}
+
+// Mutation returns the MsgMutation object of the builder.
+func (mc *MsgCreate) Mutation() *MsgMutation {
+	return mc.mutation
+}
+
+// Save creates the Msg in the database.
+func (mc *MsgCreate) Save(ctx context.Context) (*Msg, error) {
+	return withHooks(ctx, mc.sqlSave, mc.mutation, mc.hooks)
+}
+
+// SaveX calls Save and panics if Save returns an error.
+func (mc *MsgCreate) SaveX(ctx context.Context) *Msg {
+	v, err := mc.Save(ctx)
+	if err != nil {
+		panic(err)
+	}
+	return v
+}
+
+// Exec executes the query.
+func (mc *MsgCreate) Exec(ctx context.Context) error {
+	_, err := mc.Save(ctx)
+	return err
+}
+
+// ExecX is like Exec, but panics if an error occurs.
+func (mc *MsgCreate) ExecX(ctx context.Context) {
+	if err := mc.Exec(ctx); err != nil {
+		panic(err)
+	}
+}
+
+// check runs all checks and user-defined validators on the builder.
+func (mc *MsgCreate) check() error {
+	if _, ok := mc.mutation.CreatedAt(); !ok {
+		return &ValidationError{Name: "created_at", err: errors.New(`ent: missing required field "Msg.created_at"`)}
+	}
+	if _, ok := mc.mutation.UpdatedAt(); !ok {
+		return &ValidationError{Name: "updated_at", err: errors.New(`ent: missing required field "Msg.updated_at"`)}
+	}
+	return nil
+}
+
+func (mc *MsgCreate) sqlSave(ctx context.Context) (*Msg, error) {
+	if err := mc.check(); err != nil {
+		return nil, err
+	}
+	_node, _spec := mc.createSpec()
+	if err := sqlgraph.CreateNode(ctx, mc.driver, _spec); err != nil {
+		if sqlgraph.IsConstraintError(err) {
+			err = &ConstraintError{msg: err.Error(), wrap: err}
+		}
+		return nil, err
+	}
+	if _spec.ID.Value != _node.ID {
+		id := _spec.ID.Value.(int64)
+		_node.ID = int(id)
+	}
+	mc.mutation.id = &_node.ID
+	mc.mutation.done = true
+	return _node, nil
+}
+
+func (mc *MsgCreate) createSpec() (*Msg, *sqlgraph.CreateSpec) {
+	var (
+		_node = &Msg{config: mc.config}
+		_spec = sqlgraph.NewCreateSpec(msg.Table, sqlgraph.NewFieldSpec(msg.FieldID, field.TypeInt))
+	)
+	_spec.OnConflict = mc.conflict
+	if id, ok := mc.mutation.ID(); ok {
+		_node.ID = id
+		_spec.ID.Value = id
+	}
+	if value, ok := mc.mutation.CreatedAt(); ok {
+		_spec.SetField(msg.FieldCreatedAt, field.TypeTime, value)
+		_node.CreatedAt = value
+	}
+	if value, ok := mc.mutation.UpdatedAt(); ok {
+		_spec.SetField(msg.FieldUpdatedAt, field.TypeTime, value)
+		_node.UpdatedAt = value
+	}
+	if value, ok := mc.mutation.DeletedAt(); ok {
+		_spec.SetField(msg.FieldDeletedAt, field.TypeTime, value)
+		_node.DeletedAt = value
+	}
+	if value, ok := mc.mutation.Status(); ok {
+		_spec.SetField(msg.FieldStatus, field.TypeUint8, value)
+		_node.Status = value
+	}
+	if value, ok := mc.mutation.Fromwxid(); ok {
+		_spec.SetField(msg.FieldFromwxid, field.TypeString, value)
+		_node.Fromwxid = value
+	}
+	if value, ok := mc.mutation.Toid(); ok {
+		_spec.SetField(msg.FieldToid, field.TypeString, value)
+		_node.Toid = value
+	}
+	if value, ok := mc.mutation.Msgtype(); ok {
+		_spec.SetField(msg.FieldMsgtype, field.TypeInt32, value)
+		_node.Msgtype = value
+	}
+	if value, ok := mc.mutation.Msg(); ok {
+		_spec.SetField(msg.FieldMsg, field.TypeString, value)
+		_node.Msg = value
+	}
+	if value, ok := mc.mutation.BatchNo(); ok {
+		_spec.SetField(msg.FieldBatchNo, field.TypeString, value)
+		_node.BatchNo = value
+	}
+	return _node, _spec
+}
+
+// OnConflict allows configuring the `ON CONFLICT` / `ON DUPLICATE KEY` clause
+// of the `INSERT` statement. For example:
+//
+//	client.Msg.Create().
+//		SetCreatedAt(v).
+//		OnConflict(
+//			// Update the row with the new values
+//			// the was proposed for insertion.
+//			sql.ResolveWithNewValues(),
+//		).
+//		// Override some of the fields with custom
+//		// update values.
+//		Update(func(u *ent.MsgUpsert) {
+//			SetCreatedAt(v+v).
+//		}).
+//		Exec(ctx)
+func (mc *MsgCreate) OnConflict(opts ...sql.ConflictOption) *MsgUpsertOne {
+	mc.conflict = opts
+	return &MsgUpsertOne{
+		create: mc,
+	}
+}
+
+// OnConflictColumns calls `OnConflict` and configures the columns
+// as conflict target. Using this option is equivalent to using:
+//
+//	client.Msg.Create().
+//		OnConflict(sql.ConflictColumns(columns...)).
+//		Exec(ctx)
+func (mc *MsgCreate) OnConflictColumns(columns ...string) *MsgUpsertOne {
+	mc.conflict = append(mc.conflict, sql.ConflictColumns(columns...))
+	return &MsgUpsertOne{
+		create: mc,
+	}
+}
+
+type (
+	// MsgUpsertOne is the builder for "upsert"-ing
+	//  one Msg node.
+	MsgUpsertOne struct {
+		create *MsgCreate
+	}
+
+	// MsgUpsert is the "OnConflict" setter.
+	MsgUpsert struct {
+		*sql.UpdateSet
+	}
+)
+
+// SetCreatedAt sets the "created_at" field.
+func (u *MsgUpsert) SetCreatedAt(v time.Time) *MsgUpsert {
+	u.Set(msg.FieldCreatedAt, v)
+	return u
+}
+
+// UpdateCreatedAt sets the "created_at" field to the value that was provided on create.
+func (u *MsgUpsert) UpdateCreatedAt() *MsgUpsert {
+	u.SetExcluded(msg.FieldCreatedAt)
+	return u
+}
+
+// SetUpdatedAt sets the "updated_at" field.
+func (u *MsgUpsert) SetUpdatedAt(v time.Time) *MsgUpsert {
+	u.Set(msg.FieldUpdatedAt, v)
+	return u
+}
+
+// UpdateUpdatedAt sets the "updated_at" field to the value that was provided on create.
+func (u *MsgUpsert) UpdateUpdatedAt() *MsgUpsert {
+	u.SetExcluded(msg.FieldUpdatedAt)
+	return u
+}
+
+// SetDeletedAt sets the "deleted_at" field.
+func (u *MsgUpsert) SetDeletedAt(v time.Time) *MsgUpsert {
+	u.Set(msg.FieldDeletedAt, v)
+	return u
+}
+
+// UpdateDeletedAt sets the "deleted_at" field to the value that was provided on create.
+func (u *MsgUpsert) UpdateDeletedAt() *MsgUpsert {
+	u.SetExcluded(msg.FieldDeletedAt)
+	return u
+}
+
+// ClearDeletedAt clears the value of the "deleted_at" field.
+func (u *MsgUpsert) ClearDeletedAt() *MsgUpsert {
+	u.SetNull(msg.FieldDeletedAt)
+	return u
+}
+
+// SetStatus sets the "status" field.
+func (u *MsgUpsert) SetStatus(v uint8) *MsgUpsert {
+	u.Set(msg.FieldStatus, v)
+	return u
+}
+
+// UpdateStatus sets the "status" field to the value that was provided on create.
+func (u *MsgUpsert) UpdateStatus() *MsgUpsert {
+	u.SetExcluded(msg.FieldStatus)
+	return u
+}
+
+// AddStatus adds v to the "status" field.
+func (u *MsgUpsert) AddStatus(v uint8) *MsgUpsert {
+	u.Add(msg.FieldStatus, v)
+	return u
+}
+
+// ClearStatus clears the value of the "status" field.
+func (u *MsgUpsert) ClearStatus() *MsgUpsert {
+	u.SetNull(msg.FieldStatus)
+	return u
+}
+
+// SetFromwxid sets the "fromwxid" field.
+func (u *MsgUpsert) SetFromwxid(v string) *MsgUpsert {
+	u.Set(msg.FieldFromwxid, v)
+	return u
+}
+
+// UpdateFromwxid sets the "fromwxid" field to the value that was provided on create.
+func (u *MsgUpsert) UpdateFromwxid() *MsgUpsert {
+	u.SetExcluded(msg.FieldFromwxid)
+	return u
+}
+
+// ClearFromwxid clears the value of the "fromwxid" field.
+func (u *MsgUpsert) ClearFromwxid() *MsgUpsert {
+	u.SetNull(msg.FieldFromwxid)
+	return u
+}
+
+// SetToid sets the "toid" field.
+func (u *MsgUpsert) SetToid(v string) *MsgUpsert {
+	u.Set(msg.FieldToid, v)
+	return u
+}
+
+// UpdateToid sets the "toid" field to the value that was provided on create.
+func (u *MsgUpsert) UpdateToid() *MsgUpsert {
+	u.SetExcluded(msg.FieldToid)
+	return u
+}
+
+// ClearToid clears the value of the "toid" field.
+func (u *MsgUpsert) ClearToid() *MsgUpsert {
+	u.SetNull(msg.FieldToid)
+	return u
+}
+
+// SetMsgtype sets the "msgtype" field.
+func (u *MsgUpsert) SetMsgtype(v int32) *MsgUpsert {
+	u.Set(msg.FieldMsgtype, v)
+	return u
+}
+
+// UpdateMsgtype sets the "msgtype" field to the value that was provided on create.
+func (u *MsgUpsert) UpdateMsgtype() *MsgUpsert {
+	u.SetExcluded(msg.FieldMsgtype)
+	return u
+}
+
+// AddMsgtype adds v to the "msgtype" field.
+func (u *MsgUpsert) AddMsgtype(v int32) *MsgUpsert {
+	u.Add(msg.FieldMsgtype, v)
+	return u
+}
+
+// ClearMsgtype clears the value of the "msgtype" field.
+func (u *MsgUpsert) ClearMsgtype() *MsgUpsert {
+	u.SetNull(msg.FieldMsgtype)
+	return u
+}
+
+// SetMsg sets the "msg" field.
+func (u *MsgUpsert) SetMsg(v string) *MsgUpsert {
+	u.Set(msg.FieldMsg, v)
+	return u
+}
+
+// UpdateMsg sets the "msg" field to the value that was provided on create.
+func (u *MsgUpsert) UpdateMsg() *MsgUpsert {
+	u.SetExcluded(msg.FieldMsg)
+	return u
+}
+
+// ClearMsg clears the value of the "msg" field.
+func (u *MsgUpsert) ClearMsg() *MsgUpsert {
+	u.SetNull(msg.FieldMsg)
+	return u
+}
+
+// SetBatchNo sets the "batch_no" field.
+func (u *MsgUpsert) SetBatchNo(v string) *MsgUpsert {
+	u.Set(msg.FieldBatchNo, v)
+	return u
+}
+
+// UpdateBatchNo sets the "batch_no" field to the value that was provided on create.
+func (u *MsgUpsert) UpdateBatchNo() *MsgUpsert {
+	u.SetExcluded(msg.FieldBatchNo)
+	return u
+}
+
+// ClearBatchNo clears the value of the "batch_no" field.
+func (u *MsgUpsert) ClearBatchNo() *MsgUpsert {
+	u.SetNull(msg.FieldBatchNo)
+	return u
+}
+
+// UpdateNewValues updates the mutable fields using the new values that were set on create except the ID field.
+// Using this option is equivalent to using:
+//
+//	client.Msg.Create().
+//		OnConflict(
+//			sql.ResolveWithNewValues(),
+//			sql.ResolveWith(func(u *sql.UpdateSet) {
+//				u.SetIgnore(msg.FieldID)
+//			}),
+//		).
+//		Exec(ctx)
+func (u *MsgUpsertOne) UpdateNewValues() *MsgUpsertOne {
+	u.create.conflict = append(u.create.conflict, sql.ResolveWithNewValues())
+	u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(s *sql.UpdateSet) {
+		if _, exists := u.create.mutation.ID(); exists {
+			s.SetIgnore(msg.FieldID)
+		}
+	}))
+	return u
+}
+
+// Ignore sets each column to itself in case of conflict.
+// Using this option is equivalent to using:
+//
+//	client.Msg.Create().
+//	    OnConflict(sql.ResolveWithIgnore()).
+//	    Exec(ctx)
+func (u *MsgUpsertOne) Ignore() *MsgUpsertOne {
+	u.create.conflict = append(u.create.conflict, sql.ResolveWithIgnore())
+	return u
+}
+
+// DoNothing configures the conflict_action to `DO NOTHING`.
+// Supported only by SQLite and PostgreSQL.
+func (u *MsgUpsertOne) DoNothing() *MsgUpsertOne {
+	u.create.conflict = append(u.create.conflict, sql.DoNothing())
+	return u
+}
+
+// Update allows overriding fields `UPDATE` values. See the MsgCreate.OnConflict
+// documentation for more info.
+func (u *MsgUpsertOne) Update(set func(*MsgUpsert)) *MsgUpsertOne {
+	u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(update *sql.UpdateSet) {
+		set(&MsgUpsert{UpdateSet: update})
+	}))
+	return u
+}
+
+// SetCreatedAt sets the "created_at" field.
+func (u *MsgUpsertOne) SetCreatedAt(v time.Time) *MsgUpsertOne {
+	return u.Update(func(s *MsgUpsert) {
+		s.SetCreatedAt(v)
+	})
+}
+
+// UpdateCreatedAt sets the "created_at" field to the value that was provided on create.
+func (u *MsgUpsertOne) UpdateCreatedAt() *MsgUpsertOne {
+	return u.Update(func(s *MsgUpsert) {
+		s.UpdateCreatedAt()
+	})
+}
+
+// SetUpdatedAt sets the "updated_at" field.
+func (u *MsgUpsertOne) SetUpdatedAt(v time.Time) *MsgUpsertOne {
+	return u.Update(func(s *MsgUpsert) {
+		s.SetUpdatedAt(v)
+	})
+}
+
+// UpdateUpdatedAt sets the "updated_at" field to the value that was provided on create.
+func (u *MsgUpsertOne) UpdateUpdatedAt() *MsgUpsertOne {
+	return u.Update(func(s *MsgUpsert) {
+		s.UpdateUpdatedAt()
+	})
+}
+
+// SetDeletedAt sets the "deleted_at" field.
+func (u *MsgUpsertOne) SetDeletedAt(v time.Time) *MsgUpsertOne {
+	return u.Update(func(s *MsgUpsert) {
+		s.SetDeletedAt(v)
+	})
+}
+
+// UpdateDeletedAt sets the "deleted_at" field to the value that was provided on create.
+func (u *MsgUpsertOne) UpdateDeletedAt() *MsgUpsertOne {
+	return u.Update(func(s *MsgUpsert) {
+		s.UpdateDeletedAt()
+	})
+}
+
+// ClearDeletedAt clears the value of the "deleted_at" field.
+func (u *MsgUpsertOne) ClearDeletedAt() *MsgUpsertOne {
+	return u.Update(func(s *MsgUpsert) {
+		s.ClearDeletedAt()
+	})
+}
+
+// SetStatus sets the "status" field.
+func (u *MsgUpsertOne) SetStatus(v uint8) *MsgUpsertOne {
+	return u.Update(func(s *MsgUpsert) {
+		s.SetStatus(v)
+	})
+}
+
+// AddStatus adds v to the "status" field.
+func (u *MsgUpsertOne) AddStatus(v uint8) *MsgUpsertOne {
+	return u.Update(func(s *MsgUpsert) {
+		s.AddStatus(v)
+	})
+}
+
+// UpdateStatus sets the "status" field to the value that was provided on create.
+func (u *MsgUpsertOne) UpdateStatus() *MsgUpsertOne {
+	return u.Update(func(s *MsgUpsert) {
+		s.UpdateStatus()
+	})
+}
+
+// ClearStatus clears the value of the "status" field.
+func (u *MsgUpsertOne) ClearStatus() *MsgUpsertOne {
+	return u.Update(func(s *MsgUpsert) {
+		s.ClearStatus()
+	})
+}
+
+// SetFromwxid sets the "fromwxid" field.
+func (u *MsgUpsertOne) SetFromwxid(v string) *MsgUpsertOne {
+	return u.Update(func(s *MsgUpsert) {
+		s.SetFromwxid(v)
+	})
+}
+
+// UpdateFromwxid sets the "fromwxid" field to the value that was provided on create.
+func (u *MsgUpsertOne) UpdateFromwxid() *MsgUpsertOne {
+	return u.Update(func(s *MsgUpsert) {
+		s.UpdateFromwxid()
+	})
+}
+
+// ClearFromwxid clears the value of the "fromwxid" field.
+func (u *MsgUpsertOne) ClearFromwxid() *MsgUpsertOne {
+	return u.Update(func(s *MsgUpsert) {
+		s.ClearFromwxid()
+	})
+}
+
+// SetToid sets the "toid" field.
+func (u *MsgUpsertOne) SetToid(v string) *MsgUpsertOne {
+	return u.Update(func(s *MsgUpsert) {
+		s.SetToid(v)
+	})
+}
+
+// UpdateToid sets the "toid" field to the value that was provided on create.
+func (u *MsgUpsertOne) UpdateToid() *MsgUpsertOne {
+	return u.Update(func(s *MsgUpsert) {
+		s.UpdateToid()
+	})
+}
+
+// ClearToid clears the value of the "toid" field.
+func (u *MsgUpsertOne) ClearToid() *MsgUpsertOne {
+	return u.Update(func(s *MsgUpsert) {
+		s.ClearToid()
+	})
+}
+
+// SetMsgtype sets the "msgtype" field.
+func (u *MsgUpsertOne) SetMsgtype(v int32) *MsgUpsertOne {
+	return u.Update(func(s *MsgUpsert) {
+		s.SetMsgtype(v)
+	})
+}
+
+// AddMsgtype adds v to the "msgtype" field.
+func (u *MsgUpsertOne) AddMsgtype(v int32) *MsgUpsertOne {
+	return u.Update(func(s *MsgUpsert) {
+		s.AddMsgtype(v)
+	})
+}
+
+// UpdateMsgtype sets the "msgtype" field to the value that was provided on create.
+func (u *MsgUpsertOne) UpdateMsgtype() *MsgUpsertOne {
+	return u.Update(func(s *MsgUpsert) {
+		s.UpdateMsgtype()
+	})
+}
+
+// ClearMsgtype clears the value of the "msgtype" field.
+func (u *MsgUpsertOne) ClearMsgtype() *MsgUpsertOne {
+	return u.Update(func(s *MsgUpsert) {
+		s.ClearMsgtype()
+	})
+}
+
+// SetMsg sets the "msg" field.
+func (u *MsgUpsertOne) SetMsg(v string) *MsgUpsertOne {
+	return u.Update(func(s *MsgUpsert) {
+		s.SetMsg(v)
+	})
+}
+
+// UpdateMsg sets the "msg" field to the value that was provided on create.
+func (u *MsgUpsertOne) UpdateMsg() *MsgUpsertOne {
+	return u.Update(func(s *MsgUpsert) {
+		s.UpdateMsg()
+	})
+}
+
+// ClearMsg clears the value of the "msg" field.
+func (u *MsgUpsertOne) ClearMsg() *MsgUpsertOne {
+	return u.Update(func(s *MsgUpsert) {
+		s.ClearMsg()
+	})
+}
+
+// SetBatchNo sets the "batch_no" field.
+func (u *MsgUpsertOne) SetBatchNo(v string) *MsgUpsertOne {
+	return u.Update(func(s *MsgUpsert) {
+		s.SetBatchNo(v)
+	})
+}
+
+// UpdateBatchNo sets the "batch_no" field to the value that was provided on create.
+func (u *MsgUpsertOne) UpdateBatchNo() *MsgUpsertOne {
+	return u.Update(func(s *MsgUpsert) {
+		s.UpdateBatchNo()
+	})
+}
+
+// ClearBatchNo clears the value of the "batch_no" field.
+func (u *MsgUpsertOne) ClearBatchNo() *MsgUpsertOne {
+	return u.Update(func(s *MsgUpsert) {
+		s.ClearBatchNo()
+	})
+}
+
+// Exec executes the query.
+func (u *MsgUpsertOne) Exec(ctx context.Context) error {
+	if len(u.create.conflict) == 0 {
+		return errors.New("ent: missing options for MsgCreate.OnConflict")
+	}
+	return u.create.Exec(ctx)
+}
+
+// ExecX is like Exec, but panics if an error occurs.
+func (u *MsgUpsertOne) ExecX(ctx context.Context) {
+	if err := u.create.Exec(ctx); err != nil {
+		panic(err)
+	}
+}
+
+// Exec executes the UPSERT query and returns the inserted/updated ID.
+func (u *MsgUpsertOne) ID(ctx context.Context) (id int, err error) {
+	node, err := u.create.Save(ctx)
+	if err != nil {
+		return id, err
+	}
+	return node.ID, nil
+}
+
+// IDX is like ID, but panics if an error occurs.
+func (u *MsgUpsertOne) IDX(ctx context.Context) int {
+	id, err := u.ID(ctx)
+	if err != nil {
+		panic(err)
+	}
+	return id
+}
+
+// MsgCreateBulk is the builder for creating many Msg entities in bulk.
+type MsgCreateBulk struct {
+	config
+	err      error
+	builders []*MsgCreate
+	conflict []sql.ConflictOption
+}
+
+// Save creates the Msg entities in the database.
+func (mcb *MsgCreateBulk) Save(ctx context.Context) ([]*Msg, error) {
+	if mcb.err != nil {
+		return nil, mcb.err
+	}
+	specs := make([]*sqlgraph.CreateSpec, len(mcb.builders))
+	nodes := make([]*Msg, len(mcb.builders))
+	mutators := make([]Mutator, len(mcb.builders))
+	for i := range mcb.builders {
+		func(i int, root context.Context) {
+			builder := mcb.builders[i]
+			var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {
+				mutation, ok := m.(*MsgMutation)
+				if !ok {
+					return nil, fmt.Errorf("unexpected mutation type %T", m)
+				}
+				if err := builder.check(); err != nil {
+					return nil, err
+				}
+				builder.mutation = mutation
+				var err error
+				nodes[i], specs[i] = builder.createSpec()
+				if i < len(mutators)-1 {
+					_, err = mutators[i+1].Mutate(root, mcb.builders[i+1].mutation)
+				} else {
+					spec := &sqlgraph.BatchCreateSpec{Nodes: specs}
+					spec.OnConflict = mcb.conflict
+					// Invoke the actual operation on the latest mutation in the chain.
+					if err = sqlgraph.BatchCreate(ctx, mcb.driver, spec); err != nil {
+						if sqlgraph.IsConstraintError(err) {
+							err = &ConstraintError{msg: err.Error(), wrap: err}
+						}
+					}
+				}
+				if err != nil {
+					return nil, err
+				}
+				mutation.id = &nodes[i].ID
+				if specs[i].ID.Value != nil && nodes[i].ID == 0 {
+					id := specs[i].ID.Value.(int64)
+					nodes[i].ID = int(id)
+				}
+				mutation.done = true
+				return nodes[i], nil
+			})
+			for i := len(builder.hooks) - 1; i >= 0; i-- {
+				mut = builder.hooks[i](mut)
+			}
+			mutators[i] = mut
+		}(i, ctx)
+	}
+	if len(mutators) > 0 {
+		if _, err := mutators[0].Mutate(ctx, mcb.builders[0].mutation); err != nil {
+			return nil, err
+		}
+	}
+	return nodes, nil
+}
+
+// SaveX is like Save, but panics if an error occurs.
+func (mcb *MsgCreateBulk) SaveX(ctx context.Context) []*Msg {
+	v, err := mcb.Save(ctx)
+	if err != nil {
+		panic(err)
+	}
+	return v
+}
+
+// Exec executes the query.
+func (mcb *MsgCreateBulk) Exec(ctx context.Context) error {
+	_, err := mcb.Save(ctx)
+	return err
+}
+
+// ExecX is like Exec, but panics if an error occurs.
+func (mcb *MsgCreateBulk) ExecX(ctx context.Context) {
+	if err := mcb.Exec(ctx); err != nil {
+		panic(err)
+	}
+}
+
+// OnConflict allows configuring the `ON CONFLICT` / `ON DUPLICATE KEY` clause
+// of the `INSERT` statement. For example:
+//
+//	client.Msg.CreateBulk(builders...).
+//		OnConflict(
+//			// Update the row with the new values
+//			// the was proposed for insertion.
+//			sql.ResolveWithNewValues(),
+//		).
+//		// Override some of the fields with custom
+//		// update values.
+//		Update(func(u *ent.MsgUpsert) {
+//			SetCreatedAt(v+v).
+//		}).
+//		Exec(ctx)
+func (mcb *MsgCreateBulk) OnConflict(opts ...sql.ConflictOption) *MsgUpsertBulk {
+	mcb.conflict = opts
+	return &MsgUpsertBulk{
+		create: mcb,
+	}
+}
+
+// OnConflictColumns calls `OnConflict` and configures the columns
+// as conflict target. Using this option is equivalent to using:
+//
+//	client.Msg.Create().
+//		OnConflict(sql.ConflictColumns(columns...)).
+//		Exec(ctx)
+func (mcb *MsgCreateBulk) OnConflictColumns(columns ...string) *MsgUpsertBulk {
+	mcb.conflict = append(mcb.conflict, sql.ConflictColumns(columns...))
+	return &MsgUpsertBulk{
+		create: mcb,
+	}
+}
+
+// MsgUpsertBulk is the builder for "upsert"-ing
+// a bulk of Msg nodes.
+type MsgUpsertBulk struct {
+	create *MsgCreateBulk
+}
+
+// UpdateNewValues updates the mutable fields using the new values that
+// were set on create. Using this option is equivalent to using:
+//
+//	client.Msg.Create().
+//		OnConflict(
+//			sql.ResolveWithNewValues(),
+//			sql.ResolveWith(func(u *sql.UpdateSet) {
+//				u.SetIgnore(msg.FieldID)
+//			}),
+//		).
+//		Exec(ctx)
+func (u *MsgUpsertBulk) UpdateNewValues() *MsgUpsertBulk {
+	u.create.conflict = append(u.create.conflict, sql.ResolveWithNewValues())
+	u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(s *sql.UpdateSet) {
+		for _, b := range u.create.builders {
+			if _, exists := b.mutation.ID(); exists {
+				s.SetIgnore(msg.FieldID)
+			}
+		}
+	}))
+	return u
+}
+
+// Ignore sets each column to itself in case of conflict.
+// Using this option is equivalent to using:
+//
+//	client.Msg.Create().
+//		OnConflict(sql.ResolveWithIgnore()).
+//		Exec(ctx)
+func (u *MsgUpsertBulk) Ignore() *MsgUpsertBulk {
+	u.create.conflict = append(u.create.conflict, sql.ResolveWithIgnore())
+	return u
+}
+
+// DoNothing configures the conflict_action to `DO NOTHING`.
+// Supported only by SQLite and PostgreSQL.
+func (u *MsgUpsertBulk) DoNothing() *MsgUpsertBulk {
+	u.create.conflict = append(u.create.conflict, sql.DoNothing())
+	return u
+}
+
+// Update allows overriding fields `UPDATE` values. See the MsgCreateBulk.OnConflict
+// documentation for more info.
+func (u *MsgUpsertBulk) Update(set func(*MsgUpsert)) *MsgUpsertBulk {
+	u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(update *sql.UpdateSet) {
+		set(&MsgUpsert{UpdateSet: update})
+	}))
+	return u
+}
+
+// SetCreatedAt sets the "created_at" field.
+func (u *MsgUpsertBulk) SetCreatedAt(v time.Time) *MsgUpsertBulk {
+	return u.Update(func(s *MsgUpsert) {
+		s.SetCreatedAt(v)
+	})
+}
+
+// UpdateCreatedAt sets the "created_at" field to the value that was provided on create.
+func (u *MsgUpsertBulk) UpdateCreatedAt() *MsgUpsertBulk {
+	return u.Update(func(s *MsgUpsert) {
+		s.UpdateCreatedAt()
+	})
+}
+
+// SetUpdatedAt sets the "updated_at" field.
+func (u *MsgUpsertBulk) SetUpdatedAt(v time.Time) *MsgUpsertBulk {
+	return u.Update(func(s *MsgUpsert) {
+		s.SetUpdatedAt(v)
+	})
+}
+
+// UpdateUpdatedAt sets the "updated_at" field to the value that was provided on create.
+func (u *MsgUpsertBulk) UpdateUpdatedAt() *MsgUpsertBulk {
+	return u.Update(func(s *MsgUpsert) {
+		s.UpdateUpdatedAt()
+	})
+}
+
+// SetDeletedAt sets the "deleted_at" field.
+func (u *MsgUpsertBulk) SetDeletedAt(v time.Time) *MsgUpsertBulk {
+	return u.Update(func(s *MsgUpsert) {
+		s.SetDeletedAt(v)
+	})
+}
+
+// UpdateDeletedAt sets the "deleted_at" field to the value that was provided on create.
+func (u *MsgUpsertBulk) UpdateDeletedAt() *MsgUpsertBulk {
+	return u.Update(func(s *MsgUpsert) {
+		s.UpdateDeletedAt()
+	})
+}
+
+// ClearDeletedAt clears the value of the "deleted_at" field.
+func (u *MsgUpsertBulk) ClearDeletedAt() *MsgUpsertBulk {
+	return u.Update(func(s *MsgUpsert) {
+		s.ClearDeletedAt()
+	})
+}
+
+// SetStatus sets the "status" field.
+func (u *MsgUpsertBulk) SetStatus(v uint8) *MsgUpsertBulk {
+	return u.Update(func(s *MsgUpsert) {
+		s.SetStatus(v)
+	})
+}
+
+// AddStatus adds v to the "status" field.
+func (u *MsgUpsertBulk) AddStatus(v uint8) *MsgUpsertBulk {
+	return u.Update(func(s *MsgUpsert) {
+		s.AddStatus(v)
+	})
+}
+
+// UpdateStatus sets the "status" field to the value that was provided on create.
+func (u *MsgUpsertBulk) UpdateStatus() *MsgUpsertBulk {
+	return u.Update(func(s *MsgUpsert) {
+		s.UpdateStatus()
+	})
+}
+
+// ClearStatus clears the value of the "status" field.
+func (u *MsgUpsertBulk) ClearStatus() *MsgUpsertBulk {
+	return u.Update(func(s *MsgUpsert) {
+		s.ClearStatus()
+	})
+}
+
+// SetFromwxid sets the "fromwxid" field.
+func (u *MsgUpsertBulk) SetFromwxid(v string) *MsgUpsertBulk {
+	return u.Update(func(s *MsgUpsert) {
+		s.SetFromwxid(v)
+	})
+}
+
+// UpdateFromwxid sets the "fromwxid" field to the value that was provided on create.
+func (u *MsgUpsertBulk) UpdateFromwxid() *MsgUpsertBulk {
+	return u.Update(func(s *MsgUpsert) {
+		s.UpdateFromwxid()
+	})
+}
+
+// ClearFromwxid clears the value of the "fromwxid" field.
+func (u *MsgUpsertBulk) ClearFromwxid() *MsgUpsertBulk {
+	return u.Update(func(s *MsgUpsert) {
+		s.ClearFromwxid()
+	})
+}
+
+// SetToid sets the "toid" field.
+func (u *MsgUpsertBulk) SetToid(v string) *MsgUpsertBulk {
+	return u.Update(func(s *MsgUpsert) {
+		s.SetToid(v)
+	})
+}
+
+// UpdateToid sets the "toid" field to the value that was provided on create.
+func (u *MsgUpsertBulk) UpdateToid() *MsgUpsertBulk {
+	return u.Update(func(s *MsgUpsert) {
+		s.UpdateToid()
+	})
+}
+
+// ClearToid clears the value of the "toid" field.
+func (u *MsgUpsertBulk) ClearToid() *MsgUpsertBulk {
+	return u.Update(func(s *MsgUpsert) {
+		s.ClearToid()
+	})
+}
+
+// SetMsgtype sets the "msgtype" field.
+func (u *MsgUpsertBulk) SetMsgtype(v int32) *MsgUpsertBulk {
+	return u.Update(func(s *MsgUpsert) {
+		s.SetMsgtype(v)
+	})
+}
+
+// AddMsgtype adds v to the "msgtype" field.
+func (u *MsgUpsertBulk) AddMsgtype(v int32) *MsgUpsertBulk {
+	return u.Update(func(s *MsgUpsert) {
+		s.AddMsgtype(v)
+	})
+}
+
+// UpdateMsgtype sets the "msgtype" field to the value that was provided on create.
+func (u *MsgUpsertBulk) UpdateMsgtype() *MsgUpsertBulk {
+	return u.Update(func(s *MsgUpsert) {
+		s.UpdateMsgtype()
+	})
+}
+
+// ClearMsgtype clears the value of the "msgtype" field.
+func (u *MsgUpsertBulk) ClearMsgtype() *MsgUpsertBulk {
+	return u.Update(func(s *MsgUpsert) {
+		s.ClearMsgtype()
+	})
+}
+
+// SetMsg sets the "msg" field.
+func (u *MsgUpsertBulk) SetMsg(v string) *MsgUpsertBulk {
+	return u.Update(func(s *MsgUpsert) {
+		s.SetMsg(v)
+	})
+}
+
+// UpdateMsg sets the "msg" field to the value that was provided on create.
+func (u *MsgUpsertBulk) UpdateMsg() *MsgUpsertBulk {
+	return u.Update(func(s *MsgUpsert) {
+		s.UpdateMsg()
+	})
+}
+
+// ClearMsg clears the value of the "msg" field.
+func (u *MsgUpsertBulk) ClearMsg() *MsgUpsertBulk {
+	return u.Update(func(s *MsgUpsert) {
+		s.ClearMsg()
+	})
+}
+
+// SetBatchNo sets the "batch_no" field.
+func (u *MsgUpsertBulk) SetBatchNo(v string) *MsgUpsertBulk {
+	return u.Update(func(s *MsgUpsert) {
+		s.SetBatchNo(v)
+	})
+}
+
+// UpdateBatchNo sets the "batch_no" field to the value that was provided on create.
+func (u *MsgUpsertBulk) UpdateBatchNo() *MsgUpsertBulk {
+	return u.Update(func(s *MsgUpsert) {
+		s.UpdateBatchNo()
+	})
+}
+
+// ClearBatchNo clears the value of the "batch_no" field.
+func (u *MsgUpsertBulk) ClearBatchNo() *MsgUpsertBulk {
+	return u.Update(func(s *MsgUpsert) {
+		s.ClearBatchNo()
+	})
+}
+
+// Exec executes the query.
+func (u *MsgUpsertBulk) Exec(ctx context.Context) error {
+	if u.create.err != nil {
+		return u.create.err
+	}
+	for i, b := range u.create.builders {
+		if len(b.conflict) != 0 {
+			return fmt.Errorf("ent: OnConflict was set for builder %d. Set it on the MsgCreateBulk instead", i)
+		}
+	}
+	if len(u.create.conflict) == 0 {
+		return errors.New("ent: missing options for MsgCreateBulk.OnConflict")
+	}
+	return u.create.Exec(ctx)
+}
+
+// ExecX is like Exec, but panics if an error occurs.
+func (u *MsgUpsertBulk) ExecX(ctx context.Context) {
+	if err := u.create.Exec(ctx); err != nil {
+		panic(err)
+	}
+}

+ 88 - 0
ent/msg_delete.go

@@ -0,0 +1,88 @@
+// Code generated by ent, DO NOT EDIT.
+
+package ent
+
+import (
+	"context"
+	"wechat-api/ent/msg"
+	"wechat-api/ent/predicate"
+
+	"entgo.io/ent/dialect/sql"
+	"entgo.io/ent/dialect/sql/sqlgraph"
+	"entgo.io/ent/schema/field"
+)
+
+// MsgDelete is the builder for deleting a Msg entity.
+type MsgDelete struct {
+	config
+	hooks    []Hook
+	mutation *MsgMutation
+}
+
+// Where appends a list predicates to the MsgDelete builder.
+func (md *MsgDelete) Where(ps ...predicate.Msg) *MsgDelete {
+	md.mutation.Where(ps...)
+	return md
+}
+
+// Exec executes the deletion query and returns how many vertices were deleted.
+func (md *MsgDelete) Exec(ctx context.Context) (int, error) {
+	return withHooks(ctx, md.sqlExec, md.mutation, md.hooks)
+}
+
+// ExecX is like Exec, but panics if an error occurs.
+func (md *MsgDelete) ExecX(ctx context.Context) int {
+	n, err := md.Exec(ctx)
+	if err != nil {
+		panic(err)
+	}
+	return n
+}
+
+func (md *MsgDelete) sqlExec(ctx context.Context) (int, error) {
+	_spec := sqlgraph.NewDeleteSpec(msg.Table, sqlgraph.NewFieldSpec(msg.FieldID, field.TypeInt))
+	if ps := md.mutation.predicates; len(ps) > 0 {
+		_spec.Predicate = func(selector *sql.Selector) {
+			for i := range ps {
+				ps[i](selector)
+			}
+		}
+	}
+	affected, err := sqlgraph.DeleteNodes(ctx, md.driver, _spec)
+	if err != nil && sqlgraph.IsConstraintError(err) {
+		err = &ConstraintError{msg: err.Error(), wrap: err}
+	}
+	md.mutation.done = true
+	return affected, err
+}
+
+// MsgDeleteOne is the builder for deleting a single Msg entity.
+type MsgDeleteOne struct {
+	md *MsgDelete
+}
+
+// Where appends a list predicates to the MsgDelete builder.
+func (mdo *MsgDeleteOne) Where(ps ...predicate.Msg) *MsgDeleteOne {
+	mdo.md.mutation.Where(ps...)
+	return mdo
+}
+
+// Exec executes the deletion query.
+func (mdo *MsgDeleteOne) Exec(ctx context.Context) error {
+	n, err := mdo.md.Exec(ctx)
+	switch {
+	case err != nil:
+		return err
+	case n == 0:
+		return &NotFoundError{msg.Label}
+	default:
+		return nil
+	}
+}
+
+// ExecX is like Exec, but panics if an error occurs.
+func (mdo *MsgDeleteOne) ExecX(ctx context.Context) {
+	if err := mdo.Exec(ctx); err != nil {
+		panic(err)
+	}
+}

+ 526 - 0
ent/msg_query.go

@@ -0,0 +1,526 @@
+// Code generated by ent, DO NOT EDIT.
+
+package ent
+
+import (
+	"context"
+	"fmt"
+	"math"
+	"wechat-api/ent/msg"
+	"wechat-api/ent/predicate"
+
+	"entgo.io/ent/dialect/sql"
+	"entgo.io/ent/dialect/sql/sqlgraph"
+	"entgo.io/ent/schema/field"
+)
+
+// MsgQuery is the builder for querying Msg entities.
+type MsgQuery struct {
+	config
+	ctx        *QueryContext
+	order      []msg.OrderOption
+	inters     []Interceptor
+	predicates []predicate.Msg
+	// intermediate query (i.e. traversal path).
+	sql  *sql.Selector
+	path func(context.Context) (*sql.Selector, error)
+}
+
+// Where adds a new predicate for the MsgQuery builder.
+func (mq *MsgQuery) Where(ps ...predicate.Msg) *MsgQuery {
+	mq.predicates = append(mq.predicates, ps...)
+	return mq
+}
+
+// Limit the number of records to be returned by this query.
+func (mq *MsgQuery) Limit(limit int) *MsgQuery {
+	mq.ctx.Limit = &limit
+	return mq
+}
+
+// Offset to start from.
+func (mq *MsgQuery) Offset(offset int) *MsgQuery {
+	mq.ctx.Offset = &offset
+	return mq
+}
+
+// Unique configures the query builder to filter duplicate records on query.
+// By default, unique is set to true, and can be disabled using this method.
+func (mq *MsgQuery) Unique(unique bool) *MsgQuery {
+	mq.ctx.Unique = &unique
+	return mq
+}
+
+// Order specifies how the records should be ordered.
+func (mq *MsgQuery) Order(o ...msg.OrderOption) *MsgQuery {
+	mq.order = append(mq.order, o...)
+	return mq
+}
+
+// First returns the first Msg entity from the query.
+// Returns a *NotFoundError when no Msg was found.
+func (mq *MsgQuery) First(ctx context.Context) (*Msg, error) {
+	nodes, err := mq.Limit(1).All(setContextOp(ctx, mq.ctx, "First"))
+	if err != nil {
+		return nil, err
+	}
+	if len(nodes) == 0 {
+		return nil, &NotFoundError{msg.Label}
+	}
+	return nodes[0], nil
+}
+
+// FirstX is like First, but panics if an error occurs.
+func (mq *MsgQuery) FirstX(ctx context.Context) *Msg {
+	node, err := mq.First(ctx)
+	if err != nil && !IsNotFound(err) {
+		panic(err)
+	}
+	return node
+}
+
+// FirstID returns the first Msg ID from the query.
+// Returns a *NotFoundError when no Msg ID was found.
+func (mq *MsgQuery) FirstID(ctx context.Context) (id int, err error) {
+	var ids []int
+	if ids, err = mq.Limit(1).IDs(setContextOp(ctx, mq.ctx, "FirstID")); err != nil {
+		return
+	}
+	if len(ids) == 0 {
+		err = &NotFoundError{msg.Label}
+		return
+	}
+	return ids[0], nil
+}
+
+// FirstIDX is like FirstID, but panics if an error occurs.
+func (mq *MsgQuery) FirstIDX(ctx context.Context) int {
+	id, err := mq.FirstID(ctx)
+	if err != nil && !IsNotFound(err) {
+		panic(err)
+	}
+	return id
+}
+
+// Only returns a single Msg entity found by the query, ensuring it only returns one.
+// Returns a *NotSingularError when more than one Msg entity is found.
+// Returns a *NotFoundError when no Msg entities are found.
+func (mq *MsgQuery) Only(ctx context.Context) (*Msg, error) {
+	nodes, err := mq.Limit(2).All(setContextOp(ctx, mq.ctx, "Only"))
+	if err != nil {
+		return nil, err
+	}
+	switch len(nodes) {
+	case 1:
+		return nodes[0], nil
+	case 0:
+		return nil, &NotFoundError{msg.Label}
+	default:
+		return nil, &NotSingularError{msg.Label}
+	}
+}
+
+// OnlyX is like Only, but panics if an error occurs.
+func (mq *MsgQuery) OnlyX(ctx context.Context) *Msg {
+	node, err := mq.Only(ctx)
+	if err != nil {
+		panic(err)
+	}
+	return node
+}
+
+// OnlyID is like Only, but returns the only Msg ID in the query.
+// Returns a *NotSingularError when more than one Msg ID is found.
+// Returns a *NotFoundError when no entities are found.
+func (mq *MsgQuery) OnlyID(ctx context.Context) (id int, err error) {
+	var ids []int
+	if ids, err = mq.Limit(2).IDs(setContextOp(ctx, mq.ctx, "OnlyID")); err != nil {
+		return
+	}
+	switch len(ids) {
+	case 1:
+		id = ids[0]
+	case 0:
+		err = &NotFoundError{msg.Label}
+	default:
+		err = &NotSingularError{msg.Label}
+	}
+	return
+}
+
+// OnlyIDX is like OnlyID, but panics if an error occurs.
+func (mq *MsgQuery) OnlyIDX(ctx context.Context) int {
+	id, err := mq.OnlyID(ctx)
+	if err != nil {
+		panic(err)
+	}
+	return id
+}
+
+// All executes the query and returns a list of Msgs.
+func (mq *MsgQuery) All(ctx context.Context) ([]*Msg, error) {
+	ctx = setContextOp(ctx, mq.ctx, "All")
+	if err := mq.prepareQuery(ctx); err != nil {
+		return nil, err
+	}
+	qr := querierAll[[]*Msg, *MsgQuery]()
+	return withInterceptors[[]*Msg](ctx, mq, qr, mq.inters)
+}
+
+// AllX is like All, but panics if an error occurs.
+func (mq *MsgQuery) AllX(ctx context.Context) []*Msg {
+	nodes, err := mq.All(ctx)
+	if err != nil {
+		panic(err)
+	}
+	return nodes
+}
+
+// IDs executes the query and returns a list of Msg IDs.
+func (mq *MsgQuery) IDs(ctx context.Context) (ids []int, err error) {
+	if mq.ctx.Unique == nil && mq.path != nil {
+		mq.Unique(true)
+	}
+	ctx = setContextOp(ctx, mq.ctx, "IDs")
+	if err = mq.Select(msg.FieldID).Scan(ctx, &ids); err != nil {
+		return nil, err
+	}
+	return ids, nil
+}
+
+// IDsX is like IDs, but panics if an error occurs.
+func (mq *MsgQuery) IDsX(ctx context.Context) []int {
+	ids, err := mq.IDs(ctx)
+	if err != nil {
+		panic(err)
+	}
+	return ids
+}
+
+// Count returns the count of the given query.
+func (mq *MsgQuery) Count(ctx context.Context) (int, error) {
+	ctx = setContextOp(ctx, mq.ctx, "Count")
+	if err := mq.prepareQuery(ctx); err != nil {
+		return 0, err
+	}
+	return withInterceptors[int](ctx, mq, querierCount[*MsgQuery](), mq.inters)
+}
+
+// CountX is like Count, but panics if an error occurs.
+func (mq *MsgQuery) CountX(ctx context.Context) int {
+	count, err := mq.Count(ctx)
+	if err != nil {
+		panic(err)
+	}
+	return count
+}
+
+// Exist returns true if the query has elements in the graph.
+func (mq *MsgQuery) Exist(ctx context.Context) (bool, error) {
+	ctx = setContextOp(ctx, mq.ctx, "Exist")
+	switch _, err := mq.FirstID(ctx); {
+	case IsNotFound(err):
+		return false, nil
+	case err != nil:
+		return false, fmt.Errorf("ent: check existence: %w", err)
+	default:
+		return true, nil
+	}
+}
+
+// ExistX is like Exist, but panics if an error occurs.
+func (mq *MsgQuery) ExistX(ctx context.Context) bool {
+	exist, err := mq.Exist(ctx)
+	if err != nil {
+		panic(err)
+	}
+	return exist
+}
+
+// Clone returns a duplicate of the MsgQuery builder, including all associated steps. It can be
+// used to prepare common query builders and use them differently after the clone is made.
+func (mq *MsgQuery) Clone() *MsgQuery {
+	if mq == nil {
+		return nil
+	}
+	return &MsgQuery{
+		config:     mq.config,
+		ctx:        mq.ctx.Clone(),
+		order:      append([]msg.OrderOption{}, mq.order...),
+		inters:     append([]Interceptor{}, mq.inters...),
+		predicates: append([]predicate.Msg{}, mq.predicates...),
+		// clone intermediate query.
+		sql:  mq.sql.Clone(),
+		path: mq.path,
+	}
+}
+
+// GroupBy is used to group vertices by one or more fields/columns.
+// It is often used with aggregate functions, like: count, max, mean, min, sum.
+//
+// Example:
+//
+//	var v []struct {
+//		CreatedAt time.Time `json:"created_at,omitempty"`
+//		Count int `json:"count,omitempty"`
+//	}
+//
+//	client.Msg.Query().
+//		GroupBy(msg.FieldCreatedAt).
+//		Aggregate(ent.Count()).
+//		Scan(ctx, &v)
+func (mq *MsgQuery) GroupBy(field string, fields ...string) *MsgGroupBy {
+	mq.ctx.Fields = append([]string{field}, fields...)
+	grbuild := &MsgGroupBy{build: mq}
+	grbuild.flds = &mq.ctx.Fields
+	grbuild.label = msg.Label
+	grbuild.scan = grbuild.Scan
+	return grbuild
+}
+
+// Select allows the selection one or more fields/columns for the given query,
+// instead of selecting all fields in the entity.
+//
+// Example:
+//
+//	var v []struct {
+//		CreatedAt time.Time `json:"created_at,omitempty"`
+//	}
+//
+//	client.Msg.Query().
+//		Select(msg.FieldCreatedAt).
+//		Scan(ctx, &v)
+func (mq *MsgQuery) Select(fields ...string) *MsgSelect {
+	mq.ctx.Fields = append(mq.ctx.Fields, fields...)
+	sbuild := &MsgSelect{MsgQuery: mq}
+	sbuild.label = msg.Label
+	sbuild.flds, sbuild.scan = &mq.ctx.Fields, sbuild.Scan
+	return sbuild
+}
+
+// Aggregate returns a MsgSelect configured with the given aggregations.
+func (mq *MsgQuery) Aggregate(fns ...AggregateFunc) *MsgSelect {
+	return mq.Select().Aggregate(fns...)
+}
+
+func (mq *MsgQuery) prepareQuery(ctx context.Context) error {
+	for _, inter := range mq.inters {
+		if inter == nil {
+			return fmt.Errorf("ent: uninitialized interceptor (forgotten import ent/runtime?)")
+		}
+		if trv, ok := inter.(Traverser); ok {
+			if err := trv.Traverse(ctx, mq); err != nil {
+				return err
+			}
+		}
+	}
+	for _, f := range mq.ctx.Fields {
+		if !msg.ValidColumn(f) {
+			return &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)}
+		}
+	}
+	if mq.path != nil {
+		prev, err := mq.path(ctx)
+		if err != nil {
+			return err
+		}
+		mq.sql = prev
+	}
+	return nil
+}
+
+func (mq *MsgQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*Msg, error) {
+	var (
+		nodes = []*Msg{}
+		_spec = mq.querySpec()
+	)
+	_spec.ScanValues = func(columns []string) ([]any, error) {
+		return (*Msg).scanValues(nil, columns)
+	}
+	_spec.Assign = func(columns []string, values []any) error {
+		node := &Msg{config: mq.config}
+		nodes = append(nodes, node)
+		return node.assignValues(columns, values)
+	}
+	for i := range hooks {
+		hooks[i](ctx, _spec)
+	}
+	if err := sqlgraph.QueryNodes(ctx, mq.driver, _spec); err != nil {
+		return nil, err
+	}
+	if len(nodes) == 0 {
+		return nodes, nil
+	}
+	return nodes, nil
+}
+
+func (mq *MsgQuery) sqlCount(ctx context.Context) (int, error) {
+	_spec := mq.querySpec()
+	_spec.Node.Columns = mq.ctx.Fields
+	if len(mq.ctx.Fields) > 0 {
+		_spec.Unique = mq.ctx.Unique != nil && *mq.ctx.Unique
+	}
+	return sqlgraph.CountNodes(ctx, mq.driver, _spec)
+}
+
+func (mq *MsgQuery) querySpec() *sqlgraph.QuerySpec {
+	_spec := sqlgraph.NewQuerySpec(msg.Table, msg.Columns, sqlgraph.NewFieldSpec(msg.FieldID, field.TypeInt))
+	_spec.From = mq.sql
+	if unique := mq.ctx.Unique; unique != nil {
+		_spec.Unique = *unique
+	} else if mq.path != nil {
+		_spec.Unique = true
+	}
+	if fields := mq.ctx.Fields; len(fields) > 0 {
+		_spec.Node.Columns = make([]string, 0, len(fields))
+		_spec.Node.Columns = append(_spec.Node.Columns, msg.FieldID)
+		for i := range fields {
+			if fields[i] != msg.FieldID {
+				_spec.Node.Columns = append(_spec.Node.Columns, fields[i])
+			}
+		}
+	}
+	if ps := mq.predicates; len(ps) > 0 {
+		_spec.Predicate = func(selector *sql.Selector) {
+			for i := range ps {
+				ps[i](selector)
+			}
+		}
+	}
+	if limit := mq.ctx.Limit; limit != nil {
+		_spec.Limit = *limit
+	}
+	if offset := mq.ctx.Offset; offset != nil {
+		_spec.Offset = *offset
+	}
+	if ps := mq.order; len(ps) > 0 {
+		_spec.Order = func(selector *sql.Selector) {
+			for i := range ps {
+				ps[i](selector)
+			}
+		}
+	}
+	return _spec
+}
+
+func (mq *MsgQuery) sqlQuery(ctx context.Context) *sql.Selector {
+	builder := sql.Dialect(mq.driver.Dialect())
+	t1 := builder.Table(msg.Table)
+	columns := mq.ctx.Fields
+	if len(columns) == 0 {
+		columns = msg.Columns
+	}
+	selector := builder.Select(t1.Columns(columns...)...).From(t1)
+	if mq.sql != nil {
+		selector = mq.sql
+		selector.Select(selector.Columns(columns...)...)
+	}
+	if mq.ctx.Unique != nil && *mq.ctx.Unique {
+		selector.Distinct()
+	}
+	for _, p := range mq.predicates {
+		p(selector)
+	}
+	for _, p := range mq.order {
+		p(selector)
+	}
+	if offset := mq.ctx.Offset; offset != nil {
+		// limit is mandatory for offset clause. We start
+		// with default value, and override it below if needed.
+		selector.Offset(*offset).Limit(math.MaxInt32)
+	}
+	if limit := mq.ctx.Limit; limit != nil {
+		selector.Limit(*limit)
+	}
+	return selector
+}
+
+// MsgGroupBy is the group-by builder for Msg entities.
+type MsgGroupBy struct {
+	selector
+	build *MsgQuery
+}
+
+// Aggregate adds the given aggregation functions to the group-by query.
+func (mgb *MsgGroupBy) Aggregate(fns ...AggregateFunc) *MsgGroupBy {
+	mgb.fns = append(mgb.fns, fns...)
+	return mgb
+}
+
+// Scan applies the selector query and scans the result into the given value.
+func (mgb *MsgGroupBy) Scan(ctx context.Context, v any) error {
+	ctx = setContextOp(ctx, mgb.build.ctx, "GroupBy")
+	if err := mgb.build.prepareQuery(ctx); err != nil {
+		return err
+	}
+	return scanWithInterceptors[*MsgQuery, *MsgGroupBy](ctx, mgb.build, mgb, mgb.build.inters, v)
+}
+
+func (mgb *MsgGroupBy) sqlScan(ctx context.Context, root *MsgQuery, v any) error {
+	selector := root.sqlQuery(ctx).Select()
+	aggregation := make([]string, 0, len(mgb.fns))
+	for _, fn := range mgb.fns {
+		aggregation = append(aggregation, fn(selector))
+	}
+	if len(selector.SelectedColumns()) == 0 {
+		columns := make([]string, 0, len(*mgb.flds)+len(mgb.fns))
+		for _, f := range *mgb.flds {
+			columns = append(columns, selector.C(f))
+		}
+		columns = append(columns, aggregation...)
+		selector.Select(columns...)
+	}
+	selector.GroupBy(selector.Columns(*mgb.flds...)...)
+	if err := selector.Err(); err != nil {
+		return err
+	}
+	rows := &sql.Rows{}
+	query, args := selector.Query()
+	if err := mgb.build.driver.Query(ctx, query, args, rows); err != nil {
+		return err
+	}
+	defer rows.Close()
+	return sql.ScanSlice(rows, v)
+}
+
+// MsgSelect is the builder for selecting fields of Msg entities.
+type MsgSelect struct {
+	*MsgQuery
+	selector
+}
+
+// Aggregate adds the given aggregation functions to the selector query.
+func (ms *MsgSelect) Aggregate(fns ...AggregateFunc) *MsgSelect {
+	ms.fns = append(ms.fns, fns...)
+	return ms
+}
+
+// Scan applies the selector query and scans the result into the given value.
+func (ms *MsgSelect) Scan(ctx context.Context, v any) error {
+	ctx = setContextOp(ctx, ms.ctx, "Select")
+	if err := ms.prepareQuery(ctx); err != nil {
+		return err
+	}
+	return scanWithInterceptors[*MsgQuery, *MsgSelect](ctx, ms.MsgQuery, ms, ms.inters, v)
+}
+
+func (ms *MsgSelect) sqlScan(ctx context.Context, root *MsgQuery, v any) error {
+	selector := root.sqlQuery(ctx)
+	aggregation := make([]string, 0, len(ms.fns))
+	for _, fn := range ms.fns {
+		aggregation = append(aggregation, fn(selector))
+	}
+	switch n := len(*ms.selector.flds); {
+	case n == 0 && len(aggregation) > 0:
+		selector.Select(aggregation...)
+	case n != 0 && len(aggregation) > 0:
+		selector.AppendSelect(aggregation...)
+	}
+	rows := &sql.Rows{}
+	query, args := selector.Query()
+	if err := ms.driver.Query(ctx, query, args, rows); err != nil {
+		return err
+	}
+	defer rows.Close()
+	return sql.ScanSlice(rows, v)
+}

+ 648 - 0
ent/msg_update.go

@@ -0,0 +1,648 @@
+// Code generated by ent, DO NOT EDIT.
+
+package ent
+
+import (
+	"context"
+	"errors"
+	"fmt"
+	"time"
+	"wechat-api/ent/msg"
+	"wechat-api/ent/predicate"
+
+	"entgo.io/ent/dialect/sql"
+	"entgo.io/ent/dialect/sql/sqlgraph"
+	"entgo.io/ent/schema/field"
+)
+
+// MsgUpdate is the builder for updating Msg entities.
+type MsgUpdate struct {
+	config
+	hooks    []Hook
+	mutation *MsgMutation
+}
+
+// Where appends a list predicates to the MsgUpdate builder.
+func (mu *MsgUpdate) Where(ps ...predicate.Msg) *MsgUpdate {
+	mu.mutation.Where(ps...)
+	return mu
+}
+
+// SetCreatedAt sets the "created_at" field.
+func (mu *MsgUpdate) SetCreatedAt(t time.Time) *MsgUpdate {
+	mu.mutation.SetCreatedAt(t)
+	return mu
+}
+
+// SetNillableCreatedAt sets the "created_at" field if the given value is not nil.
+func (mu *MsgUpdate) SetNillableCreatedAt(t *time.Time) *MsgUpdate {
+	if t != nil {
+		mu.SetCreatedAt(*t)
+	}
+	return mu
+}
+
+// SetUpdatedAt sets the "updated_at" field.
+func (mu *MsgUpdate) SetUpdatedAt(t time.Time) *MsgUpdate {
+	mu.mutation.SetUpdatedAt(t)
+	return mu
+}
+
+// SetNillableUpdatedAt sets the "updated_at" field if the given value is not nil.
+func (mu *MsgUpdate) SetNillableUpdatedAt(t *time.Time) *MsgUpdate {
+	if t != nil {
+		mu.SetUpdatedAt(*t)
+	}
+	return mu
+}
+
+// SetDeletedAt sets the "deleted_at" field.
+func (mu *MsgUpdate) SetDeletedAt(t time.Time) *MsgUpdate {
+	mu.mutation.SetDeletedAt(t)
+	return mu
+}
+
+// SetNillableDeletedAt sets the "deleted_at" field if the given value is not nil.
+func (mu *MsgUpdate) SetNillableDeletedAt(t *time.Time) *MsgUpdate {
+	if t != nil {
+		mu.SetDeletedAt(*t)
+	}
+	return mu
+}
+
+// ClearDeletedAt clears the value of the "deleted_at" field.
+func (mu *MsgUpdate) ClearDeletedAt() *MsgUpdate {
+	mu.mutation.ClearDeletedAt()
+	return mu
+}
+
+// SetStatus sets the "status" field.
+func (mu *MsgUpdate) SetStatus(u uint8) *MsgUpdate {
+	mu.mutation.ResetStatus()
+	mu.mutation.SetStatus(u)
+	return mu
+}
+
+// SetNillableStatus sets the "status" field if the given value is not nil.
+func (mu *MsgUpdate) SetNillableStatus(u *uint8) *MsgUpdate {
+	if u != nil {
+		mu.SetStatus(*u)
+	}
+	return mu
+}
+
+// AddStatus adds u to the "status" field.
+func (mu *MsgUpdate) AddStatus(u int8) *MsgUpdate {
+	mu.mutation.AddStatus(u)
+	return mu
+}
+
+// ClearStatus clears the value of the "status" field.
+func (mu *MsgUpdate) ClearStatus() *MsgUpdate {
+	mu.mutation.ClearStatus()
+	return mu
+}
+
+// SetFromwxid sets the "fromwxid" field.
+func (mu *MsgUpdate) SetFromwxid(s string) *MsgUpdate {
+	mu.mutation.SetFromwxid(s)
+	return mu
+}
+
+// SetNillableFromwxid sets the "fromwxid" field if the given value is not nil.
+func (mu *MsgUpdate) SetNillableFromwxid(s *string) *MsgUpdate {
+	if s != nil {
+		mu.SetFromwxid(*s)
+	}
+	return mu
+}
+
+// ClearFromwxid clears the value of the "fromwxid" field.
+func (mu *MsgUpdate) ClearFromwxid() *MsgUpdate {
+	mu.mutation.ClearFromwxid()
+	return mu
+}
+
+// SetToid sets the "toid" field.
+func (mu *MsgUpdate) SetToid(s string) *MsgUpdate {
+	mu.mutation.SetToid(s)
+	return mu
+}
+
+// SetNillableToid sets the "toid" field if the given value is not nil.
+func (mu *MsgUpdate) SetNillableToid(s *string) *MsgUpdate {
+	if s != nil {
+		mu.SetToid(*s)
+	}
+	return mu
+}
+
+// ClearToid clears the value of the "toid" field.
+func (mu *MsgUpdate) ClearToid() *MsgUpdate {
+	mu.mutation.ClearToid()
+	return mu
+}
+
+// SetMsgtype sets the "msgtype" field.
+func (mu *MsgUpdate) SetMsgtype(i int32) *MsgUpdate {
+	mu.mutation.ResetMsgtype()
+	mu.mutation.SetMsgtype(i)
+	return mu
+}
+
+// SetNillableMsgtype sets the "msgtype" field if the given value is not nil.
+func (mu *MsgUpdate) SetNillableMsgtype(i *int32) *MsgUpdate {
+	if i != nil {
+		mu.SetMsgtype(*i)
+	}
+	return mu
+}
+
+// AddMsgtype adds i to the "msgtype" field.
+func (mu *MsgUpdate) AddMsgtype(i int32) *MsgUpdate {
+	mu.mutation.AddMsgtype(i)
+	return mu
+}
+
+// ClearMsgtype clears the value of the "msgtype" field.
+func (mu *MsgUpdate) ClearMsgtype() *MsgUpdate {
+	mu.mutation.ClearMsgtype()
+	return mu
+}
+
+// SetMsg sets the "msg" field.
+func (mu *MsgUpdate) SetMsg(s string) *MsgUpdate {
+	mu.mutation.SetMsg(s)
+	return mu
+}
+
+// SetNillableMsg sets the "msg" field if the given value is not nil.
+func (mu *MsgUpdate) SetNillableMsg(s *string) *MsgUpdate {
+	if s != nil {
+		mu.SetMsg(*s)
+	}
+	return mu
+}
+
+// ClearMsg clears the value of the "msg" field.
+func (mu *MsgUpdate) ClearMsg() *MsgUpdate {
+	mu.mutation.ClearMsg()
+	return mu
+}
+
+// SetBatchNo sets the "batch_no" field.
+func (mu *MsgUpdate) SetBatchNo(s string) *MsgUpdate {
+	mu.mutation.SetBatchNo(s)
+	return mu
+}
+
+// SetNillableBatchNo sets the "batch_no" field if the given value is not nil.
+func (mu *MsgUpdate) SetNillableBatchNo(s *string) *MsgUpdate {
+	if s != nil {
+		mu.SetBatchNo(*s)
+	}
+	return mu
+}
+
+// ClearBatchNo clears the value of the "batch_no" field.
+func (mu *MsgUpdate) ClearBatchNo() *MsgUpdate {
+	mu.mutation.ClearBatchNo()
+	return mu
+}
+
+// Mutation returns the MsgMutation object of the builder.
+func (mu *MsgUpdate) Mutation() *MsgMutation {
+	return mu.mutation
+}
+
+// Save executes the query and returns the number of nodes affected by the update operation.
+func (mu *MsgUpdate) Save(ctx context.Context) (int, error) {
+	return withHooks(ctx, mu.sqlSave, mu.mutation, mu.hooks)
+}
+
+// SaveX is like Save, but panics if an error occurs.
+func (mu *MsgUpdate) SaveX(ctx context.Context) int {
+	affected, err := mu.Save(ctx)
+	if err != nil {
+		panic(err)
+	}
+	return affected
+}
+
+// Exec executes the query.
+func (mu *MsgUpdate) Exec(ctx context.Context) error {
+	_, err := mu.Save(ctx)
+	return err
+}
+
+// ExecX is like Exec, but panics if an error occurs.
+func (mu *MsgUpdate) ExecX(ctx context.Context) {
+	if err := mu.Exec(ctx); err != nil {
+		panic(err)
+	}
+}
+
+func (mu *MsgUpdate) sqlSave(ctx context.Context) (n int, err error) {
+	_spec := sqlgraph.NewUpdateSpec(msg.Table, msg.Columns, sqlgraph.NewFieldSpec(msg.FieldID, field.TypeInt))
+	if ps := mu.mutation.predicates; len(ps) > 0 {
+		_spec.Predicate = func(selector *sql.Selector) {
+			for i := range ps {
+				ps[i](selector)
+			}
+		}
+	}
+	if value, ok := mu.mutation.CreatedAt(); ok {
+		_spec.SetField(msg.FieldCreatedAt, field.TypeTime, value)
+	}
+	if value, ok := mu.mutation.UpdatedAt(); ok {
+		_spec.SetField(msg.FieldUpdatedAt, field.TypeTime, value)
+	}
+	if value, ok := mu.mutation.DeletedAt(); ok {
+		_spec.SetField(msg.FieldDeletedAt, field.TypeTime, value)
+	}
+	if mu.mutation.DeletedAtCleared() {
+		_spec.ClearField(msg.FieldDeletedAt, field.TypeTime)
+	}
+	if value, ok := mu.mutation.Status(); ok {
+		_spec.SetField(msg.FieldStatus, field.TypeUint8, value)
+	}
+	if value, ok := mu.mutation.AddedStatus(); ok {
+		_spec.AddField(msg.FieldStatus, field.TypeUint8, value)
+	}
+	if mu.mutation.StatusCleared() {
+		_spec.ClearField(msg.FieldStatus, field.TypeUint8)
+	}
+	if value, ok := mu.mutation.Fromwxid(); ok {
+		_spec.SetField(msg.FieldFromwxid, field.TypeString, value)
+	}
+	if mu.mutation.FromwxidCleared() {
+		_spec.ClearField(msg.FieldFromwxid, field.TypeString)
+	}
+	if value, ok := mu.mutation.Toid(); ok {
+		_spec.SetField(msg.FieldToid, field.TypeString, value)
+	}
+	if mu.mutation.ToidCleared() {
+		_spec.ClearField(msg.FieldToid, field.TypeString)
+	}
+	if value, ok := mu.mutation.Msgtype(); ok {
+		_spec.SetField(msg.FieldMsgtype, field.TypeInt32, value)
+	}
+	if value, ok := mu.mutation.AddedMsgtype(); ok {
+		_spec.AddField(msg.FieldMsgtype, field.TypeInt32, value)
+	}
+	if mu.mutation.MsgtypeCleared() {
+		_spec.ClearField(msg.FieldMsgtype, field.TypeInt32)
+	}
+	if value, ok := mu.mutation.Msg(); ok {
+		_spec.SetField(msg.FieldMsg, field.TypeString, value)
+	}
+	if mu.mutation.MsgCleared() {
+		_spec.ClearField(msg.FieldMsg, field.TypeString)
+	}
+	if value, ok := mu.mutation.BatchNo(); ok {
+		_spec.SetField(msg.FieldBatchNo, field.TypeString, value)
+	}
+	if mu.mutation.BatchNoCleared() {
+		_spec.ClearField(msg.FieldBatchNo, field.TypeString)
+	}
+	if n, err = sqlgraph.UpdateNodes(ctx, mu.driver, _spec); err != nil {
+		if _, ok := err.(*sqlgraph.NotFoundError); ok {
+			err = &NotFoundError{msg.Label}
+		} else if sqlgraph.IsConstraintError(err) {
+			err = &ConstraintError{msg: err.Error(), wrap: err}
+		}
+		return 0, err
+	}
+	mu.mutation.done = true
+	return n, nil
+}
+
+// MsgUpdateOne is the builder for updating a single Msg entity.
+type MsgUpdateOne struct {
+	config
+	fields   []string
+	hooks    []Hook
+	mutation *MsgMutation
+}
+
+// SetCreatedAt sets the "created_at" field.
+func (muo *MsgUpdateOne) SetCreatedAt(t time.Time) *MsgUpdateOne {
+	muo.mutation.SetCreatedAt(t)
+	return muo
+}
+
+// SetNillableCreatedAt sets the "created_at" field if the given value is not nil.
+func (muo *MsgUpdateOne) SetNillableCreatedAt(t *time.Time) *MsgUpdateOne {
+	if t != nil {
+		muo.SetCreatedAt(*t)
+	}
+	return muo
+}
+
+// SetUpdatedAt sets the "updated_at" field.
+func (muo *MsgUpdateOne) SetUpdatedAt(t time.Time) *MsgUpdateOne {
+	muo.mutation.SetUpdatedAt(t)
+	return muo
+}
+
+// SetNillableUpdatedAt sets the "updated_at" field if the given value is not nil.
+func (muo *MsgUpdateOne) SetNillableUpdatedAt(t *time.Time) *MsgUpdateOne {
+	if t != nil {
+		muo.SetUpdatedAt(*t)
+	}
+	return muo
+}
+
+// SetDeletedAt sets the "deleted_at" field.
+func (muo *MsgUpdateOne) SetDeletedAt(t time.Time) *MsgUpdateOne {
+	muo.mutation.SetDeletedAt(t)
+	return muo
+}
+
+// SetNillableDeletedAt sets the "deleted_at" field if the given value is not nil.
+func (muo *MsgUpdateOne) SetNillableDeletedAt(t *time.Time) *MsgUpdateOne {
+	if t != nil {
+		muo.SetDeletedAt(*t)
+	}
+	return muo
+}
+
+// ClearDeletedAt clears the value of the "deleted_at" field.
+func (muo *MsgUpdateOne) ClearDeletedAt() *MsgUpdateOne {
+	muo.mutation.ClearDeletedAt()
+	return muo
+}
+
+// SetStatus sets the "status" field.
+func (muo *MsgUpdateOne) SetStatus(u uint8) *MsgUpdateOne {
+	muo.mutation.ResetStatus()
+	muo.mutation.SetStatus(u)
+	return muo
+}
+
+// SetNillableStatus sets the "status" field if the given value is not nil.
+func (muo *MsgUpdateOne) SetNillableStatus(u *uint8) *MsgUpdateOne {
+	if u != nil {
+		muo.SetStatus(*u)
+	}
+	return muo
+}
+
+// AddStatus adds u to the "status" field.
+func (muo *MsgUpdateOne) AddStatus(u int8) *MsgUpdateOne {
+	muo.mutation.AddStatus(u)
+	return muo
+}
+
+// ClearStatus clears the value of the "status" field.
+func (muo *MsgUpdateOne) ClearStatus() *MsgUpdateOne {
+	muo.mutation.ClearStatus()
+	return muo
+}
+
+// SetFromwxid sets the "fromwxid" field.
+func (muo *MsgUpdateOne) SetFromwxid(s string) *MsgUpdateOne {
+	muo.mutation.SetFromwxid(s)
+	return muo
+}
+
+// SetNillableFromwxid sets the "fromwxid" field if the given value is not nil.
+func (muo *MsgUpdateOne) SetNillableFromwxid(s *string) *MsgUpdateOne {
+	if s != nil {
+		muo.SetFromwxid(*s)
+	}
+	return muo
+}
+
+// ClearFromwxid clears the value of the "fromwxid" field.
+func (muo *MsgUpdateOne) ClearFromwxid() *MsgUpdateOne {
+	muo.mutation.ClearFromwxid()
+	return muo
+}
+
+// SetToid sets the "toid" field.
+func (muo *MsgUpdateOne) SetToid(s string) *MsgUpdateOne {
+	muo.mutation.SetToid(s)
+	return muo
+}
+
+// SetNillableToid sets the "toid" field if the given value is not nil.
+func (muo *MsgUpdateOne) SetNillableToid(s *string) *MsgUpdateOne {
+	if s != nil {
+		muo.SetToid(*s)
+	}
+	return muo
+}
+
+// ClearToid clears the value of the "toid" field.
+func (muo *MsgUpdateOne) ClearToid() *MsgUpdateOne {
+	muo.mutation.ClearToid()
+	return muo
+}
+
+// SetMsgtype sets the "msgtype" field.
+func (muo *MsgUpdateOne) SetMsgtype(i int32) *MsgUpdateOne {
+	muo.mutation.ResetMsgtype()
+	muo.mutation.SetMsgtype(i)
+	return muo
+}
+
+// SetNillableMsgtype sets the "msgtype" field if the given value is not nil.
+func (muo *MsgUpdateOne) SetNillableMsgtype(i *int32) *MsgUpdateOne {
+	if i != nil {
+		muo.SetMsgtype(*i)
+	}
+	return muo
+}
+
+// AddMsgtype adds i to the "msgtype" field.
+func (muo *MsgUpdateOne) AddMsgtype(i int32) *MsgUpdateOne {
+	muo.mutation.AddMsgtype(i)
+	return muo
+}
+
+// ClearMsgtype clears the value of the "msgtype" field.
+func (muo *MsgUpdateOne) ClearMsgtype() *MsgUpdateOne {
+	muo.mutation.ClearMsgtype()
+	return muo
+}
+
+// SetMsg sets the "msg" field.
+func (muo *MsgUpdateOne) SetMsg(s string) *MsgUpdateOne {
+	muo.mutation.SetMsg(s)
+	return muo
+}
+
+// SetNillableMsg sets the "msg" field if the given value is not nil.
+func (muo *MsgUpdateOne) SetNillableMsg(s *string) *MsgUpdateOne {
+	if s != nil {
+		muo.SetMsg(*s)
+	}
+	return muo
+}
+
+// ClearMsg clears the value of the "msg" field.
+func (muo *MsgUpdateOne) ClearMsg() *MsgUpdateOne {
+	muo.mutation.ClearMsg()
+	return muo
+}
+
+// SetBatchNo sets the "batch_no" field.
+func (muo *MsgUpdateOne) SetBatchNo(s string) *MsgUpdateOne {
+	muo.mutation.SetBatchNo(s)
+	return muo
+}
+
+// SetNillableBatchNo sets the "batch_no" field if the given value is not nil.
+func (muo *MsgUpdateOne) SetNillableBatchNo(s *string) *MsgUpdateOne {
+	if s != nil {
+		muo.SetBatchNo(*s)
+	}
+	return muo
+}
+
+// ClearBatchNo clears the value of the "batch_no" field.
+func (muo *MsgUpdateOne) ClearBatchNo() *MsgUpdateOne {
+	muo.mutation.ClearBatchNo()
+	return muo
+}
+
+// Mutation returns the MsgMutation object of the builder.
+func (muo *MsgUpdateOne) Mutation() *MsgMutation {
+	return muo.mutation
+}
+
+// Where appends a list predicates to the MsgUpdate builder.
+func (muo *MsgUpdateOne) Where(ps ...predicate.Msg) *MsgUpdateOne {
+	muo.mutation.Where(ps...)
+	return muo
+}
+
+// Select allows selecting one or more fields (columns) of the returned entity.
+// The default is selecting all fields defined in the entity schema.
+func (muo *MsgUpdateOne) Select(field string, fields ...string) *MsgUpdateOne {
+	muo.fields = append([]string{field}, fields...)
+	return muo
+}
+
+// Save executes the query and returns the updated Msg entity.
+func (muo *MsgUpdateOne) Save(ctx context.Context) (*Msg, error) {
+	return withHooks(ctx, muo.sqlSave, muo.mutation, muo.hooks)
+}
+
+// SaveX is like Save, but panics if an error occurs.
+func (muo *MsgUpdateOne) SaveX(ctx context.Context) *Msg {
+	node, err := muo.Save(ctx)
+	if err != nil {
+		panic(err)
+	}
+	return node
+}
+
+// Exec executes the query on the entity.
+func (muo *MsgUpdateOne) Exec(ctx context.Context) error {
+	_, err := muo.Save(ctx)
+	return err
+}
+
+// ExecX is like Exec, but panics if an error occurs.
+func (muo *MsgUpdateOne) ExecX(ctx context.Context) {
+	if err := muo.Exec(ctx); err != nil {
+		panic(err)
+	}
+}
+
+func (muo *MsgUpdateOne) sqlSave(ctx context.Context) (_node *Msg, err error) {
+	_spec := sqlgraph.NewUpdateSpec(msg.Table, msg.Columns, sqlgraph.NewFieldSpec(msg.FieldID, field.TypeInt))
+	id, ok := muo.mutation.ID()
+	if !ok {
+		return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "Msg.id" for update`)}
+	}
+	_spec.Node.ID.Value = id
+	if fields := muo.fields; len(fields) > 0 {
+		_spec.Node.Columns = make([]string, 0, len(fields))
+		_spec.Node.Columns = append(_spec.Node.Columns, msg.FieldID)
+		for _, f := range fields {
+			if !msg.ValidColumn(f) {
+				return nil, &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)}
+			}
+			if f != msg.FieldID {
+				_spec.Node.Columns = append(_spec.Node.Columns, f)
+			}
+		}
+	}
+	if ps := muo.mutation.predicates; len(ps) > 0 {
+		_spec.Predicate = func(selector *sql.Selector) {
+			for i := range ps {
+				ps[i](selector)
+			}
+		}
+	}
+	if value, ok := muo.mutation.CreatedAt(); ok {
+		_spec.SetField(msg.FieldCreatedAt, field.TypeTime, value)
+	}
+	if value, ok := muo.mutation.UpdatedAt(); ok {
+		_spec.SetField(msg.FieldUpdatedAt, field.TypeTime, value)
+	}
+	if value, ok := muo.mutation.DeletedAt(); ok {
+		_spec.SetField(msg.FieldDeletedAt, field.TypeTime, value)
+	}
+	if muo.mutation.DeletedAtCleared() {
+		_spec.ClearField(msg.FieldDeletedAt, field.TypeTime)
+	}
+	if value, ok := muo.mutation.Status(); ok {
+		_spec.SetField(msg.FieldStatus, field.TypeUint8, value)
+	}
+	if value, ok := muo.mutation.AddedStatus(); ok {
+		_spec.AddField(msg.FieldStatus, field.TypeUint8, value)
+	}
+	if muo.mutation.StatusCleared() {
+		_spec.ClearField(msg.FieldStatus, field.TypeUint8)
+	}
+	if value, ok := muo.mutation.Fromwxid(); ok {
+		_spec.SetField(msg.FieldFromwxid, field.TypeString, value)
+	}
+	if muo.mutation.FromwxidCleared() {
+		_spec.ClearField(msg.FieldFromwxid, field.TypeString)
+	}
+	if value, ok := muo.mutation.Toid(); ok {
+		_spec.SetField(msg.FieldToid, field.TypeString, value)
+	}
+	if muo.mutation.ToidCleared() {
+		_spec.ClearField(msg.FieldToid, field.TypeString)
+	}
+	if value, ok := muo.mutation.Msgtype(); ok {
+		_spec.SetField(msg.FieldMsgtype, field.TypeInt32, value)
+	}
+	if value, ok := muo.mutation.AddedMsgtype(); ok {
+		_spec.AddField(msg.FieldMsgtype, field.TypeInt32, value)
+	}
+	if muo.mutation.MsgtypeCleared() {
+		_spec.ClearField(msg.FieldMsgtype, field.TypeInt32)
+	}
+	if value, ok := muo.mutation.Msg(); ok {
+		_spec.SetField(msg.FieldMsg, field.TypeString, value)
+	}
+	if muo.mutation.MsgCleared() {
+		_spec.ClearField(msg.FieldMsg, field.TypeString)
+	}
+	if value, ok := muo.mutation.BatchNo(); ok {
+		_spec.SetField(msg.FieldBatchNo, field.TypeString, value)
+	}
+	if muo.mutation.BatchNoCleared() {
+		_spec.ClearField(msg.FieldBatchNo, field.TypeString)
+	}
+	_node = &Msg{config: muo.config}
+	_spec.Assign = _node.assignValues
+	_spec.ScanValues = _node.scanValues
+	if err = sqlgraph.UpdateNode(ctx, muo.driver, _spec); err != nil {
+		if _, ok := err.(*sqlgraph.NotFoundError); ok {
+			err = &NotFoundError{msg.Label}
+		} else if sqlgraph.IsConstraintError(err) {
+			err = &ConstraintError{msg: err.Error(), wrap: err}
+		}
+		return nil, err
+	}
+	muo.mutation.done = true
+	return _node, nil
+}

+ 973 - 0
ent/mutation.go

@@ -15,6 +15,7 @@ import (
 	"wechat-api/ent/labelrelationship"
 	"wechat-api/ent/message"
 	"wechat-api/ent/messagerecords"
+	"wechat-api/ent/msg"
 	"wechat-api/ent/predicate"
 	"wechat-api/ent/server"
 	"wechat-api/ent/sopnode"
@@ -41,6 +42,7 @@ const (
 	TypeLabelRelationship = "LabelRelationship"
 	TypeMessage           = "Message"
 	TypeMessageRecords    = "MessageRecords"
+	TypeMsg               = "Msg"
 	TypeServer            = "Server"
 	TypeSopNode           = "SopNode"
 	TypeSopStage          = "SopStage"
@@ -7022,6 +7024,977 @@ func (m *MessageRecordsMutation) ResetEdge(name string) error {
 	return fmt.Errorf("unknown MessageRecords edge %s", name)
 }
 
+// MsgMutation represents an operation that mutates the Msg nodes in the graph.
+type MsgMutation struct {
+	config
+	op            Op
+	typ           string
+	id            *int
+	created_at    *time.Time
+	updated_at    *time.Time
+	deleted_at    *time.Time
+	status        *uint8
+	addstatus     *int8
+	fromwxid      *string
+	toid          *string
+	msgtype       *int32
+	addmsgtype    *int32
+	msg           *string
+	batch_no      *string
+	clearedFields map[string]struct{}
+	done          bool
+	oldValue      func(context.Context) (*Msg, error)
+	predicates    []predicate.Msg
+}
+
+var _ ent.Mutation = (*MsgMutation)(nil)
+
+// msgOption allows management of the mutation configuration using functional options.
+type msgOption func(*MsgMutation)
+
+// newMsgMutation creates new mutation for the Msg entity.
+func newMsgMutation(c config, op Op, opts ...msgOption) *MsgMutation {
+	m := &MsgMutation{
+		config:        c,
+		op:            op,
+		typ:           TypeMsg,
+		clearedFields: make(map[string]struct{}),
+	}
+	for _, opt := range opts {
+		opt(m)
+	}
+	return m
+}
+
+// withMsgID sets the ID field of the mutation.
+func withMsgID(id int) msgOption {
+	return func(m *MsgMutation) {
+		var (
+			err   error
+			once  sync.Once
+			value *Msg
+		)
+		m.oldValue = func(ctx context.Context) (*Msg, error) {
+			once.Do(func() {
+				if m.done {
+					err = errors.New("querying old values post mutation is not allowed")
+				} else {
+					value, err = m.Client().Msg.Get(ctx, id)
+				}
+			})
+			return value, err
+		}
+		m.id = &id
+	}
+}
+
+// withMsg sets the old Msg of the mutation.
+func withMsg(node *Msg) msgOption {
+	return func(m *MsgMutation) {
+		m.oldValue = func(context.Context) (*Msg, error) {
+			return node, nil
+		}
+		m.id = &node.ID
+	}
+}
+
+// Client returns a new `ent.Client` from the mutation. If the mutation was
+// executed in a transaction (ent.Tx), a transactional client is returned.
+func (m MsgMutation) Client() *Client {
+	client := &Client{config: m.config}
+	client.init()
+	return client
+}
+
+// Tx returns an `ent.Tx` for mutations that were executed in transactions;
+// it returns an error otherwise.
+func (m MsgMutation) Tx() (*Tx, error) {
+	if _, ok := m.driver.(*txDriver); !ok {
+		return nil, errors.New("ent: mutation is not running in a transaction")
+	}
+	tx := &Tx{config: m.config}
+	tx.init()
+	return tx, nil
+}
+
+// SetID sets the value of the id field. Note that this
+// operation is only accepted on creation of Msg entities.
+func (m *MsgMutation) SetID(id int) {
+	m.id = &id
+}
+
+// ID returns the ID value in the mutation. Note that the ID is only available
+// if it was provided to the builder or after it was returned from the database.
+func (m *MsgMutation) ID() (id int, exists bool) {
+	if m.id == nil {
+		return
+	}
+	return *m.id, true
+}
+
+// IDs queries the database and returns the entity ids that match the mutation's predicate.
+// That means, if the mutation is applied within a transaction with an isolation level such
+// as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
+// or updated by the mutation.
+func (m *MsgMutation) IDs(ctx context.Context) ([]int, error) {
+	switch {
+	case m.op.Is(OpUpdateOne | OpDeleteOne):
+		id, exists := m.ID()
+		if exists {
+			return []int{id}, nil
+		}
+		fallthrough
+	case m.op.Is(OpUpdate | OpDelete):
+		return m.Client().Msg.Query().Where(m.predicates...).IDs(ctx)
+	default:
+		return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
+	}
+}
+
+// SetCreatedAt sets the "created_at" field.
+func (m *MsgMutation) SetCreatedAt(t time.Time) {
+	m.created_at = &t
+}
+
+// CreatedAt returns the value of the "created_at" field in the mutation.
+func (m *MsgMutation) CreatedAt() (r time.Time, exists bool) {
+	v := m.created_at
+	if v == nil {
+		return
+	}
+	return *v, true
+}
+
+// OldCreatedAt returns the old "created_at" field's value of the Msg entity.
+// If the Msg object wasn't provided to the builder, the object is fetched from the database.
+// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
+func (m *MsgMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
+	if !m.op.Is(OpUpdateOne) {
+		return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
+	}
+	if m.id == nil || m.oldValue == nil {
+		return v, errors.New("OldCreatedAt requires an ID field in the mutation")
+	}
+	oldValue, err := m.oldValue(ctx)
+	if err != nil {
+		return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
+	}
+	return oldValue.CreatedAt, nil
+}
+
+// ResetCreatedAt resets all changes to the "created_at" field.
+func (m *MsgMutation) ResetCreatedAt() {
+	m.created_at = nil
+}
+
+// SetUpdatedAt sets the "updated_at" field.
+func (m *MsgMutation) SetUpdatedAt(t time.Time) {
+	m.updated_at = &t
+}
+
+// UpdatedAt returns the value of the "updated_at" field in the mutation.
+func (m *MsgMutation) UpdatedAt() (r time.Time, exists bool) {
+	v := m.updated_at
+	if v == nil {
+		return
+	}
+	return *v, true
+}
+
+// OldUpdatedAt returns the old "updated_at" field's value of the Msg entity.
+// If the Msg object wasn't provided to the builder, the object is fetched from the database.
+// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
+func (m *MsgMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
+	if !m.op.Is(OpUpdateOne) {
+		return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
+	}
+	if m.id == nil || m.oldValue == nil {
+		return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
+	}
+	oldValue, err := m.oldValue(ctx)
+	if err != nil {
+		return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
+	}
+	return oldValue.UpdatedAt, nil
+}
+
+// ResetUpdatedAt resets all changes to the "updated_at" field.
+func (m *MsgMutation) ResetUpdatedAt() {
+	m.updated_at = nil
+}
+
+// SetDeletedAt sets the "deleted_at" field.
+func (m *MsgMutation) SetDeletedAt(t time.Time) {
+	m.deleted_at = &t
+}
+
+// DeletedAt returns the value of the "deleted_at" field in the mutation.
+func (m *MsgMutation) DeletedAt() (r time.Time, exists bool) {
+	v := m.deleted_at
+	if v == nil {
+		return
+	}
+	return *v, true
+}
+
+// OldDeletedAt returns the old "deleted_at" field's value of the Msg entity.
+// If the Msg object wasn't provided to the builder, the object is fetched from the database.
+// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
+func (m *MsgMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
+	if !m.op.Is(OpUpdateOne) {
+		return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
+	}
+	if m.id == nil || m.oldValue == nil {
+		return v, errors.New("OldDeletedAt requires an ID field in the mutation")
+	}
+	oldValue, err := m.oldValue(ctx)
+	if err != nil {
+		return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
+	}
+	return oldValue.DeletedAt, nil
+}
+
+// ClearDeletedAt clears the value of the "deleted_at" field.
+func (m *MsgMutation) ClearDeletedAt() {
+	m.deleted_at = nil
+	m.clearedFields[msg.FieldDeletedAt] = struct{}{}
+}
+
+// DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
+func (m *MsgMutation) DeletedAtCleared() bool {
+	_, ok := m.clearedFields[msg.FieldDeletedAt]
+	return ok
+}
+
+// ResetDeletedAt resets all changes to the "deleted_at" field.
+func (m *MsgMutation) ResetDeletedAt() {
+	m.deleted_at = nil
+	delete(m.clearedFields, msg.FieldDeletedAt)
+}
+
+// SetStatus sets the "status" field.
+func (m *MsgMutation) SetStatus(u uint8) {
+	m.status = &u
+	m.addstatus = nil
+}
+
+// Status returns the value of the "status" field in the mutation.
+func (m *MsgMutation) Status() (r uint8, exists bool) {
+	v := m.status
+	if v == nil {
+		return
+	}
+	return *v, true
+}
+
+// OldStatus returns the old "status" field's value of the Msg entity.
+// If the Msg object wasn't provided to the builder, the object is fetched from the database.
+// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
+func (m *MsgMutation) OldStatus(ctx context.Context) (v uint8, err error) {
+	if !m.op.Is(OpUpdateOne) {
+		return v, errors.New("OldStatus is only allowed on UpdateOne operations")
+	}
+	if m.id == nil || m.oldValue == nil {
+		return v, errors.New("OldStatus requires an ID field in the mutation")
+	}
+	oldValue, err := m.oldValue(ctx)
+	if err != nil {
+		return v, fmt.Errorf("querying old value for OldStatus: %w", err)
+	}
+	return oldValue.Status, nil
+}
+
+// AddStatus adds u to the "status" field.
+func (m *MsgMutation) AddStatus(u int8) {
+	if m.addstatus != nil {
+		*m.addstatus += u
+	} else {
+		m.addstatus = &u
+	}
+}
+
+// AddedStatus returns the value that was added to the "status" field in this mutation.
+func (m *MsgMutation) AddedStatus() (r int8, exists bool) {
+	v := m.addstatus
+	if v == nil {
+		return
+	}
+	return *v, true
+}
+
+// ClearStatus clears the value of the "status" field.
+func (m *MsgMutation) ClearStatus() {
+	m.status = nil
+	m.addstatus = nil
+	m.clearedFields[msg.FieldStatus] = struct{}{}
+}
+
+// StatusCleared returns if the "status" field was cleared in this mutation.
+func (m *MsgMutation) StatusCleared() bool {
+	_, ok := m.clearedFields[msg.FieldStatus]
+	return ok
+}
+
+// ResetStatus resets all changes to the "status" field.
+func (m *MsgMutation) ResetStatus() {
+	m.status = nil
+	m.addstatus = nil
+	delete(m.clearedFields, msg.FieldStatus)
+}
+
+// SetFromwxid sets the "fromwxid" field.
+func (m *MsgMutation) SetFromwxid(s string) {
+	m.fromwxid = &s
+}
+
+// Fromwxid returns the value of the "fromwxid" field in the mutation.
+func (m *MsgMutation) Fromwxid() (r string, exists bool) {
+	v := m.fromwxid
+	if v == nil {
+		return
+	}
+	return *v, true
+}
+
+// OldFromwxid returns the old "fromwxid" field's value of the Msg entity.
+// If the Msg object wasn't provided to the builder, the object is fetched from the database.
+// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
+func (m *MsgMutation) OldFromwxid(ctx context.Context) (v string, err error) {
+	if !m.op.Is(OpUpdateOne) {
+		return v, errors.New("OldFromwxid is only allowed on UpdateOne operations")
+	}
+	if m.id == nil || m.oldValue == nil {
+		return v, errors.New("OldFromwxid requires an ID field in the mutation")
+	}
+	oldValue, err := m.oldValue(ctx)
+	if err != nil {
+		return v, fmt.Errorf("querying old value for OldFromwxid: %w", err)
+	}
+	return oldValue.Fromwxid, nil
+}
+
+// ClearFromwxid clears the value of the "fromwxid" field.
+func (m *MsgMutation) ClearFromwxid() {
+	m.fromwxid = nil
+	m.clearedFields[msg.FieldFromwxid] = struct{}{}
+}
+
+// FromwxidCleared returns if the "fromwxid" field was cleared in this mutation.
+func (m *MsgMutation) FromwxidCleared() bool {
+	_, ok := m.clearedFields[msg.FieldFromwxid]
+	return ok
+}
+
+// ResetFromwxid resets all changes to the "fromwxid" field.
+func (m *MsgMutation) ResetFromwxid() {
+	m.fromwxid = nil
+	delete(m.clearedFields, msg.FieldFromwxid)
+}
+
+// SetToid sets the "toid" field.
+func (m *MsgMutation) SetToid(s string) {
+	m.toid = &s
+}
+
+// Toid returns the value of the "toid" field in the mutation.
+func (m *MsgMutation) Toid() (r string, exists bool) {
+	v := m.toid
+	if v == nil {
+		return
+	}
+	return *v, true
+}
+
+// OldToid returns the old "toid" field's value of the Msg entity.
+// If the Msg object wasn't provided to the builder, the object is fetched from the database.
+// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
+func (m *MsgMutation) OldToid(ctx context.Context) (v string, err error) {
+	if !m.op.Is(OpUpdateOne) {
+		return v, errors.New("OldToid is only allowed on UpdateOne operations")
+	}
+	if m.id == nil || m.oldValue == nil {
+		return v, errors.New("OldToid requires an ID field in the mutation")
+	}
+	oldValue, err := m.oldValue(ctx)
+	if err != nil {
+		return v, fmt.Errorf("querying old value for OldToid: %w", err)
+	}
+	return oldValue.Toid, nil
+}
+
+// ClearToid clears the value of the "toid" field.
+func (m *MsgMutation) ClearToid() {
+	m.toid = nil
+	m.clearedFields[msg.FieldToid] = struct{}{}
+}
+
+// ToidCleared returns if the "toid" field was cleared in this mutation.
+func (m *MsgMutation) ToidCleared() bool {
+	_, ok := m.clearedFields[msg.FieldToid]
+	return ok
+}
+
+// ResetToid resets all changes to the "toid" field.
+func (m *MsgMutation) ResetToid() {
+	m.toid = nil
+	delete(m.clearedFields, msg.FieldToid)
+}
+
+// SetMsgtype sets the "msgtype" field.
+func (m *MsgMutation) SetMsgtype(i int32) {
+	m.msgtype = &i
+	m.addmsgtype = nil
+}
+
+// Msgtype returns the value of the "msgtype" field in the mutation.
+func (m *MsgMutation) Msgtype() (r int32, exists bool) {
+	v := m.msgtype
+	if v == nil {
+		return
+	}
+	return *v, true
+}
+
+// OldMsgtype returns the old "msgtype" field's value of the Msg entity.
+// If the Msg object wasn't provided to the builder, the object is fetched from the database.
+// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
+func (m *MsgMutation) OldMsgtype(ctx context.Context) (v int32, err error) {
+	if !m.op.Is(OpUpdateOne) {
+		return v, errors.New("OldMsgtype is only allowed on UpdateOne operations")
+	}
+	if m.id == nil || m.oldValue == nil {
+		return v, errors.New("OldMsgtype requires an ID field in the mutation")
+	}
+	oldValue, err := m.oldValue(ctx)
+	if err != nil {
+		return v, fmt.Errorf("querying old value for OldMsgtype: %w", err)
+	}
+	return oldValue.Msgtype, nil
+}
+
+// AddMsgtype adds i to the "msgtype" field.
+func (m *MsgMutation) AddMsgtype(i int32) {
+	if m.addmsgtype != nil {
+		*m.addmsgtype += i
+	} else {
+		m.addmsgtype = &i
+	}
+}
+
+// AddedMsgtype returns the value that was added to the "msgtype" field in this mutation.
+func (m *MsgMutation) AddedMsgtype() (r int32, exists bool) {
+	v := m.addmsgtype
+	if v == nil {
+		return
+	}
+	return *v, true
+}
+
+// ClearMsgtype clears the value of the "msgtype" field.
+func (m *MsgMutation) ClearMsgtype() {
+	m.msgtype = nil
+	m.addmsgtype = nil
+	m.clearedFields[msg.FieldMsgtype] = struct{}{}
+}
+
+// MsgtypeCleared returns if the "msgtype" field was cleared in this mutation.
+func (m *MsgMutation) MsgtypeCleared() bool {
+	_, ok := m.clearedFields[msg.FieldMsgtype]
+	return ok
+}
+
+// ResetMsgtype resets all changes to the "msgtype" field.
+func (m *MsgMutation) ResetMsgtype() {
+	m.msgtype = nil
+	m.addmsgtype = nil
+	delete(m.clearedFields, msg.FieldMsgtype)
+}
+
+// SetMsg sets the "msg" field.
+func (m *MsgMutation) SetMsg(s string) {
+	m.msg = &s
+}
+
+// Msg returns the value of the "msg" field in the mutation.
+func (m *MsgMutation) Msg() (r string, exists bool) {
+	v := m.msg
+	if v == nil {
+		return
+	}
+	return *v, true
+}
+
+// OldMsg returns the old "msg" field's value of the Msg entity.
+// If the Msg object wasn't provided to the builder, the object is fetched from the database.
+// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
+func (m *MsgMutation) OldMsg(ctx context.Context) (v string, err error) {
+	if !m.op.Is(OpUpdateOne) {
+		return v, errors.New("OldMsg is only allowed on UpdateOne operations")
+	}
+	if m.id == nil || m.oldValue == nil {
+		return v, errors.New("OldMsg requires an ID field in the mutation")
+	}
+	oldValue, err := m.oldValue(ctx)
+	if err != nil {
+		return v, fmt.Errorf("querying old value for OldMsg: %w", err)
+	}
+	return oldValue.Msg, nil
+}
+
+// ClearMsg clears the value of the "msg" field.
+func (m *MsgMutation) ClearMsg() {
+	m.msg = nil
+	m.clearedFields[msg.FieldMsg] = struct{}{}
+}
+
+// MsgCleared returns if the "msg" field was cleared in this mutation.
+func (m *MsgMutation) MsgCleared() bool {
+	_, ok := m.clearedFields[msg.FieldMsg]
+	return ok
+}
+
+// ResetMsg resets all changes to the "msg" field.
+func (m *MsgMutation) ResetMsg() {
+	m.msg = nil
+	delete(m.clearedFields, msg.FieldMsg)
+}
+
+// SetBatchNo sets the "batch_no" field.
+func (m *MsgMutation) SetBatchNo(s string) {
+	m.batch_no = &s
+}
+
+// BatchNo returns the value of the "batch_no" field in the mutation.
+func (m *MsgMutation) BatchNo() (r string, exists bool) {
+	v := m.batch_no
+	if v == nil {
+		return
+	}
+	return *v, true
+}
+
+// OldBatchNo returns the old "batch_no" field's value of the Msg entity.
+// If the Msg object wasn't provided to the builder, the object is fetched from the database.
+// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
+func (m *MsgMutation) OldBatchNo(ctx context.Context) (v string, err error) {
+	if !m.op.Is(OpUpdateOne) {
+		return v, errors.New("OldBatchNo is only allowed on UpdateOne operations")
+	}
+	if m.id == nil || m.oldValue == nil {
+		return v, errors.New("OldBatchNo requires an ID field in the mutation")
+	}
+	oldValue, err := m.oldValue(ctx)
+	if err != nil {
+		return v, fmt.Errorf("querying old value for OldBatchNo: %w", err)
+	}
+	return oldValue.BatchNo, nil
+}
+
+// ClearBatchNo clears the value of the "batch_no" field.
+func (m *MsgMutation) ClearBatchNo() {
+	m.batch_no = nil
+	m.clearedFields[msg.FieldBatchNo] = struct{}{}
+}
+
+// BatchNoCleared returns if the "batch_no" field was cleared in this mutation.
+func (m *MsgMutation) BatchNoCleared() bool {
+	_, ok := m.clearedFields[msg.FieldBatchNo]
+	return ok
+}
+
+// ResetBatchNo resets all changes to the "batch_no" field.
+func (m *MsgMutation) ResetBatchNo() {
+	m.batch_no = nil
+	delete(m.clearedFields, msg.FieldBatchNo)
+}
+
+// Where appends a list predicates to the MsgMutation builder.
+func (m *MsgMutation) Where(ps ...predicate.Msg) {
+	m.predicates = append(m.predicates, ps...)
+}
+
+// WhereP appends storage-level predicates to the MsgMutation builder. Using this method,
+// users can use type-assertion to append predicates that do not depend on any generated package.
+func (m *MsgMutation) WhereP(ps ...func(*sql.Selector)) {
+	p := make([]predicate.Msg, len(ps))
+	for i := range ps {
+		p[i] = ps[i]
+	}
+	m.Where(p...)
+}
+
+// Op returns the operation name.
+func (m *MsgMutation) Op() Op {
+	return m.op
+}
+
+// SetOp allows setting the mutation operation.
+func (m *MsgMutation) SetOp(op Op) {
+	m.op = op
+}
+
+// Type returns the node type of this mutation (Msg).
+func (m *MsgMutation) Type() string {
+	return m.typ
+}
+
+// Fields returns all fields that were changed during this mutation. Note that in
+// order to get all numeric fields that were incremented/decremented, call
+// AddedFields().
+func (m *MsgMutation) Fields() []string {
+	fields := make([]string, 0, 9)
+	if m.created_at != nil {
+		fields = append(fields, msg.FieldCreatedAt)
+	}
+	if m.updated_at != nil {
+		fields = append(fields, msg.FieldUpdatedAt)
+	}
+	if m.deleted_at != nil {
+		fields = append(fields, msg.FieldDeletedAt)
+	}
+	if m.status != nil {
+		fields = append(fields, msg.FieldStatus)
+	}
+	if m.fromwxid != nil {
+		fields = append(fields, msg.FieldFromwxid)
+	}
+	if m.toid != nil {
+		fields = append(fields, msg.FieldToid)
+	}
+	if m.msgtype != nil {
+		fields = append(fields, msg.FieldMsgtype)
+	}
+	if m.msg != nil {
+		fields = append(fields, msg.FieldMsg)
+	}
+	if m.batch_no != nil {
+		fields = append(fields, msg.FieldBatchNo)
+	}
+	return fields
+}
+
+// Field returns the value of a field with the given name. The second boolean
+// return value indicates that this field was not set, or was not defined in the
+// schema.
+func (m *MsgMutation) Field(name string) (ent.Value, bool) {
+	switch name {
+	case msg.FieldCreatedAt:
+		return m.CreatedAt()
+	case msg.FieldUpdatedAt:
+		return m.UpdatedAt()
+	case msg.FieldDeletedAt:
+		return m.DeletedAt()
+	case msg.FieldStatus:
+		return m.Status()
+	case msg.FieldFromwxid:
+		return m.Fromwxid()
+	case msg.FieldToid:
+		return m.Toid()
+	case msg.FieldMsgtype:
+		return m.Msgtype()
+	case msg.FieldMsg:
+		return m.Msg()
+	case msg.FieldBatchNo:
+		return m.BatchNo()
+	}
+	return nil, false
+}
+
+// OldField returns the old value of the field from the database. An error is
+// returned if the mutation operation is not UpdateOne, or the query to the
+// database failed.
+func (m *MsgMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
+	switch name {
+	case msg.FieldCreatedAt:
+		return m.OldCreatedAt(ctx)
+	case msg.FieldUpdatedAt:
+		return m.OldUpdatedAt(ctx)
+	case msg.FieldDeletedAt:
+		return m.OldDeletedAt(ctx)
+	case msg.FieldStatus:
+		return m.OldStatus(ctx)
+	case msg.FieldFromwxid:
+		return m.OldFromwxid(ctx)
+	case msg.FieldToid:
+		return m.OldToid(ctx)
+	case msg.FieldMsgtype:
+		return m.OldMsgtype(ctx)
+	case msg.FieldMsg:
+		return m.OldMsg(ctx)
+	case msg.FieldBatchNo:
+		return m.OldBatchNo(ctx)
+	}
+	return nil, fmt.Errorf("unknown Msg field %s", name)
+}
+
+// SetField sets the value of a field with the given name. It returns an error if
+// the field is not defined in the schema, or if the type mismatched the field
+// type.
+func (m *MsgMutation) SetField(name string, value ent.Value) error {
+	switch name {
+	case msg.FieldCreatedAt:
+		v, ok := value.(time.Time)
+		if !ok {
+			return fmt.Errorf("unexpected type %T for field %s", value, name)
+		}
+		m.SetCreatedAt(v)
+		return nil
+	case msg.FieldUpdatedAt:
+		v, ok := value.(time.Time)
+		if !ok {
+			return fmt.Errorf("unexpected type %T for field %s", value, name)
+		}
+		m.SetUpdatedAt(v)
+		return nil
+	case msg.FieldDeletedAt:
+		v, ok := value.(time.Time)
+		if !ok {
+			return fmt.Errorf("unexpected type %T for field %s", value, name)
+		}
+		m.SetDeletedAt(v)
+		return nil
+	case msg.FieldStatus:
+		v, ok := value.(uint8)
+		if !ok {
+			return fmt.Errorf("unexpected type %T for field %s", value, name)
+		}
+		m.SetStatus(v)
+		return nil
+	case msg.FieldFromwxid:
+		v, ok := value.(string)
+		if !ok {
+			return fmt.Errorf("unexpected type %T for field %s", value, name)
+		}
+		m.SetFromwxid(v)
+		return nil
+	case msg.FieldToid:
+		v, ok := value.(string)
+		if !ok {
+			return fmt.Errorf("unexpected type %T for field %s", value, name)
+		}
+		m.SetToid(v)
+		return nil
+	case msg.FieldMsgtype:
+		v, ok := value.(int32)
+		if !ok {
+			return fmt.Errorf("unexpected type %T for field %s", value, name)
+		}
+		m.SetMsgtype(v)
+		return nil
+	case msg.FieldMsg:
+		v, ok := value.(string)
+		if !ok {
+			return fmt.Errorf("unexpected type %T for field %s", value, name)
+		}
+		m.SetMsg(v)
+		return nil
+	case msg.FieldBatchNo:
+		v, ok := value.(string)
+		if !ok {
+			return fmt.Errorf("unexpected type %T for field %s", value, name)
+		}
+		m.SetBatchNo(v)
+		return nil
+	}
+	return fmt.Errorf("unknown Msg field %s", name)
+}
+
+// AddedFields returns all numeric fields that were incremented/decremented during
+// this mutation.
+func (m *MsgMutation) AddedFields() []string {
+	var fields []string
+	if m.addstatus != nil {
+		fields = append(fields, msg.FieldStatus)
+	}
+	if m.addmsgtype != nil {
+		fields = append(fields, msg.FieldMsgtype)
+	}
+	return fields
+}
+
+// AddedField returns the numeric value that was incremented/decremented on a field
+// with the given name. The second boolean return value indicates that this field
+// was not set, or was not defined in the schema.
+func (m *MsgMutation) AddedField(name string) (ent.Value, bool) {
+	switch name {
+	case msg.FieldStatus:
+		return m.AddedStatus()
+	case msg.FieldMsgtype:
+		return m.AddedMsgtype()
+	}
+	return nil, false
+}
+
+// AddField adds the value to the field with the given name. It returns an error if
+// the field is not defined in the schema, or if the type mismatched the field
+// type.
+func (m *MsgMutation) AddField(name string, value ent.Value) error {
+	switch name {
+	case msg.FieldStatus:
+		v, ok := value.(int8)
+		if !ok {
+			return fmt.Errorf("unexpected type %T for field %s", value, name)
+		}
+		m.AddStatus(v)
+		return nil
+	case msg.FieldMsgtype:
+		v, ok := value.(int32)
+		if !ok {
+			return fmt.Errorf("unexpected type %T for field %s", value, name)
+		}
+		m.AddMsgtype(v)
+		return nil
+	}
+	return fmt.Errorf("unknown Msg numeric field %s", name)
+}
+
+// ClearedFields returns all nullable fields that were cleared during this
+// mutation.
+func (m *MsgMutation) ClearedFields() []string {
+	var fields []string
+	if m.FieldCleared(msg.FieldDeletedAt) {
+		fields = append(fields, msg.FieldDeletedAt)
+	}
+	if m.FieldCleared(msg.FieldStatus) {
+		fields = append(fields, msg.FieldStatus)
+	}
+	if m.FieldCleared(msg.FieldFromwxid) {
+		fields = append(fields, msg.FieldFromwxid)
+	}
+	if m.FieldCleared(msg.FieldToid) {
+		fields = append(fields, msg.FieldToid)
+	}
+	if m.FieldCleared(msg.FieldMsgtype) {
+		fields = append(fields, msg.FieldMsgtype)
+	}
+	if m.FieldCleared(msg.FieldMsg) {
+		fields = append(fields, msg.FieldMsg)
+	}
+	if m.FieldCleared(msg.FieldBatchNo) {
+		fields = append(fields, msg.FieldBatchNo)
+	}
+	return fields
+}
+
+// FieldCleared returns a boolean indicating if a field with the given name was
+// cleared in this mutation.
+func (m *MsgMutation) FieldCleared(name string) bool {
+	_, ok := m.clearedFields[name]
+	return ok
+}
+
+// ClearField clears the value of the field with the given name. It returns an
+// error if the field is not defined in the schema.
+func (m *MsgMutation) ClearField(name string) error {
+	switch name {
+	case msg.FieldDeletedAt:
+		m.ClearDeletedAt()
+		return nil
+	case msg.FieldStatus:
+		m.ClearStatus()
+		return nil
+	case msg.FieldFromwxid:
+		m.ClearFromwxid()
+		return nil
+	case msg.FieldToid:
+		m.ClearToid()
+		return nil
+	case msg.FieldMsgtype:
+		m.ClearMsgtype()
+		return nil
+	case msg.FieldMsg:
+		m.ClearMsg()
+		return nil
+	case msg.FieldBatchNo:
+		m.ClearBatchNo()
+		return nil
+	}
+	return fmt.Errorf("unknown Msg nullable field %s", name)
+}
+
+// ResetField resets all changes in the mutation for the field with the given name.
+// It returns an error if the field is not defined in the schema.
+func (m *MsgMutation) ResetField(name string) error {
+	switch name {
+	case msg.FieldCreatedAt:
+		m.ResetCreatedAt()
+		return nil
+	case msg.FieldUpdatedAt:
+		m.ResetUpdatedAt()
+		return nil
+	case msg.FieldDeletedAt:
+		m.ResetDeletedAt()
+		return nil
+	case msg.FieldStatus:
+		m.ResetStatus()
+		return nil
+	case msg.FieldFromwxid:
+		m.ResetFromwxid()
+		return nil
+	case msg.FieldToid:
+		m.ResetToid()
+		return nil
+	case msg.FieldMsgtype:
+		m.ResetMsgtype()
+		return nil
+	case msg.FieldMsg:
+		m.ResetMsg()
+		return nil
+	case msg.FieldBatchNo:
+		m.ResetBatchNo()
+		return nil
+	}
+	return fmt.Errorf("unknown Msg field %s", name)
+}
+
+// AddedEdges returns all edge names that were set/added in this mutation.
+func (m *MsgMutation) AddedEdges() []string {
+	edges := make([]string, 0, 0)
+	return edges
+}
+
+// AddedIDs returns all IDs (to other nodes) that were added for the given edge
+// name in this mutation.
+func (m *MsgMutation) AddedIDs(name string) []ent.Value {
+	return nil
+}
+
+// RemovedEdges returns all edge names that were removed in this mutation.
+func (m *MsgMutation) RemovedEdges() []string {
+	edges := make([]string, 0, 0)
+	return edges
+}
+
+// RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
+// the given name in this mutation.
+func (m *MsgMutation) RemovedIDs(name string) []ent.Value {
+	return nil
+}
+
+// ClearedEdges returns all edge names that were cleared in this mutation.
+func (m *MsgMutation) ClearedEdges() []string {
+	edges := make([]string, 0, 0)
+	return edges
+}
+
+// EdgeCleared returns a boolean which indicates if the edge with the given name
+// was cleared in this mutation.
+func (m *MsgMutation) EdgeCleared(name string) bool {
+	return false
+}
+
+// ClearEdge clears the value of the edge with the given name. It returns an error
+// if that edge is not defined in the schema.
+func (m *MsgMutation) ClearEdge(name string) error {
+	return fmt.Errorf("unknown Msg unique edge %s", name)
+}
+
+// ResetEdge resets all changes to the edge with the given name in this mutation.
+// It returns an error if the edge is not defined in the schema.
+func (m *MsgMutation) ResetEdge(name string) error {
+	return fmt.Errorf("unknown Msg edge %s", name)
+}
+
 // ServerMutation represents an operation that mutates the Server nodes in the graph.
 type ServerMutation struct {
 	config

+ 82 - 0
ent/pagination.go

@@ -11,6 +11,7 @@ import (
 	"wechat-api/ent/labelrelationship"
 	"wechat-api/ent/message"
 	"wechat-api/ent/messagerecords"
+	"wechat-api/ent/msg"
 	"wechat-api/ent/server"
 	"wechat-api/ent/sopnode"
 	"wechat-api/ent/sopstage"
@@ -550,6 +551,87 @@ func (mr *MessageRecordsQuery) Page(
 	return ret, nil
 }
 
+type MsgPager struct {
+	Order  msg.OrderOption
+	Filter func(*MsgQuery) (*MsgQuery, error)
+}
+
+// MsgPaginateOption enables pagination customization.
+type MsgPaginateOption func(*MsgPager)
+
+// DefaultMsgOrder is the default ordering of Msg.
+var DefaultMsgOrder = Desc(msg.FieldID)
+
+func newMsgPager(opts []MsgPaginateOption) (*MsgPager, error) {
+	pager := &MsgPager{}
+	for _, opt := range opts {
+		opt(pager)
+	}
+	if pager.Order == nil {
+		pager.Order = DefaultMsgOrder
+	}
+	return pager, nil
+}
+
+func (p *MsgPager) ApplyFilter(query *MsgQuery) (*MsgQuery, error) {
+	if p.Filter != nil {
+		return p.Filter(query)
+	}
+	return query, nil
+}
+
+// MsgPageList is Msg PageList result.
+type MsgPageList struct {
+	List        []*Msg       `json:"list"`
+	PageDetails *PageDetails `json:"pageDetails"`
+}
+
+func (m *MsgQuery) Page(
+	ctx context.Context, pageNum uint64, pageSize uint64, opts ...MsgPaginateOption,
+) (*MsgPageList, error) {
+
+	pager, err := newMsgPager(opts)
+	if err != nil {
+		return nil, err
+	}
+
+	if m, err = pager.ApplyFilter(m); err != nil {
+		return nil, err
+	}
+
+	ret := &MsgPageList{}
+
+	ret.PageDetails = &PageDetails{
+		Page: pageNum,
+		Size: pageSize,
+	}
+
+	query := m.Clone()
+	query.ctx.Fields = nil
+	count, err := query.Count(ctx)
+
+	if err != nil {
+		return nil, err
+	}
+
+	ret.PageDetails.Total = uint64(count)
+
+	if pager.Order != nil {
+		m = m.Order(pager.Order)
+	} else {
+		m = m.Order(DefaultMsgOrder)
+	}
+
+	m = m.Offset(int((pageNum - 1) * pageSize)).Limit(int(pageSize))
+	list, err := m.All(ctx)
+	if err != nil {
+		return nil, err
+	}
+	ret.List = list
+
+	return ret, nil
+}
+
 type ServerPager struct {
 	Order  server.OrderOption
 	Filter func(*ServerQuery) (*ServerQuery, error)

+ 3 - 0
ent/predicate/predicate.go

@@ -24,6 +24,9 @@ type Message func(*sql.Selector)
 // MessageRecords is the predicate function for messagerecords builders.
 type MessageRecords func(*sql.Selector)
 
+// Msg is the predicate function for msg builders.
+type Msg func(*sql.Selector)
+
 // Server is the predicate function for server builders.
 type Server func(*sql.Selector)
 

+ 44 - 0
ent/schema/msg.go

@@ -0,0 +1,44 @@
+package schema
+
+import (
+	"entgo.io/ent"
+	"entgo.io/ent/dialect/entsql"
+	"entgo.io/ent/schema"
+	"entgo.io/ent/schema/field"
+	"entgo.io/ent/schema/index"
+)
+
+type Msg struct {
+	ent.Schema
+}
+
+func (Msg) Fields() []ent.Field {
+	return []ent.Field{
+		field.Int("id"),
+		field.Time("created_at").Comment("Create Time | 创建日期"),
+		field.Time("updated_at").Comment("Update Time | 修改日期"),
+		field.Time("deleted_at").Optional().Comment("Delete Time | 删除日期"),
+		field.Uint8("status").Optional().Comment("Status 1: normal 2: ban | 状态 1 正常 2 禁用"),
+		field.String("fromwxid").Optional().Comment("发送方微信ID"),
+		field.String("toid").Optional().Comment("接收人微信ID/群ID"),
+		field.Int32("msgtype").Optional().Comment("消息类型"),
+		field.String("msg").Optional().Comment("消息"),
+		field.String("batch_no").Optional().Comment("批次号")}
+}
+func (Msg) Edges() []ent.Edge {
+	return nil
+}
+
+func (Msg) Indexes() []ent.Index {
+	return []ent.Index{
+		index.Fields("batch_no"),
+		index.Fields("id"),
+		index.Fields("status")}
+}
+
+func (Msg) Annotations() []schema.Annotation {
+	return []schema.Annotation{
+		entsql.WithComments(true),
+		entsql.Annotation{Table: "msg"},
+	}
+}

+ 216 - 0
ent/set_not_nil.go

@@ -1472,6 +1472,222 @@ func (mr *MessageRecordsCreate) SetNotNilSubSourceID(value *uint64) *MessageReco
 }
 
 // set field if value's pointer is not nil.
+func (m *MsgUpdate) SetNotNilCreatedAt(value *time.Time) *MsgUpdate {
+	if value != nil {
+		return m.SetCreatedAt(*value)
+	}
+	return m
+}
+
+// set field if value's pointer is not nil.
+func (m *MsgUpdateOne) SetNotNilCreatedAt(value *time.Time) *MsgUpdateOne {
+	if value != nil {
+		return m.SetCreatedAt(*value)
+	}
+	return m
+}
+
+// set field if value's pointer is not nil.
+func (m *MsgCreate) SetNotNilCreatedAt(value *time.Time) *MsgCreate {
+	if value != nil {
+		return m.SetCreatedAt(*value)
+	}
+	return m
+}
+
+// set field if value's pointer is not nil.
+func (m *MsgUpdate) SetNotNilUpdatedAt(value *time.Time) *MsgUpdate {
+	if value != nil {
+		return m.SetUpdatedAt(*value)
+	}
+	return m
+}
+
+// set field if value's pointer is not nil.
+func (m *MsgUpdateOne) SetNotNilUpdatedAt(value *time.Time) *MsgUpdateOne {
+	if value != nil {
+		return m.SetUpdatedAt(*value)
+	}
+	return m
+}
+
+// set field if value's pointer is not nil.
+func (m *MsgCreate) SetNotNilUpdatedAt(value *time.Time) *MsgCreate {
+	if value != nil {
+		return m.SetUpdatedAt(*value)
+	}
+	return m
+}
+
+// set field if value's pointer is not nil.
+func (m *MsgUpdate) SetNotNilDeletedAt(value *time.Time) *MsgUpdate {
+	if value != nil {
+		return m.SetDeletedAt(*value)
+	}
+	return m
+}
+
+// set field if value's pointer is not nil.
+func (m *MsgUpdateOne) SetNotNilDeletedAt(value *time.Time) *MsgUpdateOne {
+	if value != nil {
+		return m.SetDeletedAt(*value)
+	}
+	return m
+}
+
+// set field if value's pointer is not nil.
+func (m *MsgCreate) SetNotNilDeletedAt(value *time.Time) *MsgCreate {
+	if value != nil {
+		return m.SetDeletedAt(*value)
+	}
+	return m
+}
+
+// set field if value's pointer is not nil.
+func (m *MsgUpdate) SetNotNilStatus(value *uint8) *MsgUpdate {
+	if value != nil {
+		return m.SetStatus(*value)
+	}
+	return m
+}
+
+// set field if value's pointer is not nil.
+func (m *MsgUpdateOne) SetNotNilStatus(value *uint8) *MsgUpdateOne {
+	if value != nil {
+		return m.SetStatus(*value)
+	}
+	return m
+}
+
+// set field if value's pointer is not nil.
+func (m *MsgCreate) SetNotNilStatus(value *uint8) *MsgCreate {
+	if value != nil {
+		return m.SetStatus(*value)
+	}
+	return m
+}
+
+// set field if value's pointer is not nil.
+func (m *MsgUpdate) SetNotNilFromwxid(value *string) *MsgUpdate {
+	if value != nil {
+		return m.SetFromwxid(*value)
+	}
+	return m
+}
+
+// set field if value's pointer is not nil.
+func (m *MsgUpdateOne) SetNotNilFromwxid(value *string) *MsgUpdateOne {
+	if value != nil {
+		return m.SetFromwxid(*value)
+	}
+	return m
+}
+
+// set field if value's pointer is not nil.
+func (m *MsgCreate) SetNotNilFromwxid(value *string) *MsgCreate {
+	if value != nil {
+		return m.SetFromwxid(*value)
+	}
+	return m
+}
+
+// set field if value's pointer is not nil.
+func (m *MsgUpdate) SetNotNilToid(value *string) *MsgUpdate {
+	if value != nil {
+		return m.SetToid(*value)
+	}
+	return m
+}
+
+// set field if value's pointer is not nil.
+func (m *MsgUpdateOne) SetNotNilToid(value *string) *MsgUpdateOne {
+	if value != nil {
+		return m.SetToid(*value)
+	}
+	return m
+}
+
+// set field if value's pointer is not nil.
+func (m *MsgCreate) SetNotNilToid(value *string) *MsgCreate {
+	if value != nil {
+		return m.SetToid(*value)
+	}
+	return m
+}
+
+// set field if value's pointer is not nil.
+func (m *MsgUpdate) SetNotNilMsgtype(value *int32) *MsgUpdate {
+	if value != nil {
+		return m.SetMsgtype(*value)
+	}
+	return m
+}
+
+// set field if value's pointer is not nil.
+func (m *MsgUpdateOne) SetNotNilMsgtype(value *int32) *MsgUpdateOne {
+	if value != nil {
+		return m.SetMsgtype(*value)
+	}
+	return m
+}
+
+// set field if value's pointer is not nil.
+func (m *MsgCreate) SetNotNilMsgtype(value *int32) *MsgCreate {
+	if value != nil {
+		return m.SetMsgtype(*value)
+	}
+	return m
+}
+
+// set field if value's pointer is not nil.
+func (m *MsgUpdate) SetNotNilMsg(value *string) *MsgUpdate {
+	if value != nil {
+		return m.SetMsg(*value)
+	}
+	return m
+}
+
+// set field if value's pointer is not nil.
+func (m *MsgUpdateOne) SetNotNilMsg(value *string) *MsgUpdateOne {
+	if value != nil {
+		return m.SetMsg(*value)
+	}
+	return m
+}
+
+// set field if value's pointer is not nil.
+func (m *MsgCreate) SetNotNilMsg(value *string) *MsgCreate {
+	if value != nil {
+		return m.SetMsg(*value)
+	}
+	return m
+}
+
+// set field if value's pointer is not nil.
+func (m *MsgUpdate) SetNotNilBatchNo(value *string) *MsgUpdate {
+	if value != nil {
+		return m.SetBatchNo(*value)
+	}
+	return m
+}
+
+// set field if value's pointer is not nil.
+func (m *MsgUpdateOne) SetNotNilBatchNo(value *string) *MsgUpdateOne {
+	if value != nil {
+		return m.SetBatchNo(*value)
+	}
+	return m
+}
+
+// set field if value's pointer is not nil.
+func (m *MsgCreate) SetNotNilBatchNo(value *string) *MsgCreate {
+	if value != nil {
+		return m.SetBatchNo(*value)
+	}
+	return m
+}
+
+// set field if value's pointer is not nil.
 func (s *ServerUpdate) SetNotNilUpdatedAt(value *time.Time) *ServerUpdate {
 	if value != nil {
 		return s.SetUpdatedAt(*value)

+ 3 - 0
ent/tx.go

@@ -26,6 +26,8 @@ type Tx struct {
 	Message *MessageClient
 	// MessageRecords is the client for interacting with the MessageRecords builders.
 	MessageRecords *MessageRecordsClient
+	// Msg is the client for interacting with the Msg builders.
+	Msg *MsgClient
 	// Server is the client for interacting with the Server builders.
 	Server *ServerClient
 	// SopNode is the client for interacting with the SopNode builders.
@@ -173,6 +175,7 @@ func (tx *Tx) init() {
 	tx.LabelRelationship = NewLabelRelationshipClient(tx.config)
 	tx.Message = NewMessageClient(tx.config)
 	tx.MessageRecords = NewMessageRecordsClient(tx.config)
+	tx.Msg = NewMsgClient(tx.config)
 	tx.Server = NewServerClient(tx.config)
 	tx.SopNode = NewSopNodeClient(tx.config)
 	tx.SopStage = NewSopStageClient(tx.config)