|
@@ -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)
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+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)
|
|
|
+
|
|
|
+
|
|
|
+type msgOption func(*MsgMutation)
|
|
|
+
|
|
|
+
|
|
|
+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
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+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
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+func withMsg(node *Msg) msgOption {
|
|
|
+ return func(m *MsgMutation) {
|
|
|
+ m.oldValue = func(context.Context) (*Msg, error) {
|
|
|
+ return node, nil
|
|
|
+ }
|
|
|
+ m.id = &node.ID
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+func (m MsgMutation) Client() *Client {
|
|
|
+ client := &Client{config: m.config}
|
|
|
+ client.init()
|
|
|
+ return client
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+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
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+func (m *MsgMutation) SetID(id int) {
|
|
|
+ m.id = &id
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+func (m *MsgMutation) ID() (id int, exists bool) {
|
|
|
+ if m.id == nil {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ return *m.id, true
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+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)
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+func (m *MsgMutation) SetCreatedAt(t time.Time) {
|
|
|
+ m.created_at = &t
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+func (m *MsgMutation) CreatedAt() (r time.Time, exists bool) {
|
|
|
+ v := m.created_at
|
|
|
+ if v == nil {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ return *v, true
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+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
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+func (m *MsgMutation) ResetCreatedAt() {
|
|
|
+ m.created_at = nil
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+func (m *MsgMutation) SetUpdatedAt(t time.Time) {
|
|
|
+ m.updated_at = &t
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+func (m *MsgMutation) UpdatedAt() (r time.Time, exists bool) {
|
|
|
+ v := m.updated_at
|
|
|
+ if v == nil {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ return *v, true
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+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
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+func (m *MsgMutation) ResetUpdatedAt() {
|
|
|
+ m.updated_at = nil
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+func (m *MsgMutation) SetDeletedAt(t time.Time) {
|
|
|
+ m.deleted_at = &t
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+func (m *MsgMutation) DeletedAt() (r time.Time, exists bool) {
|
|
|
+ v := m.deleted_at
|
|
|
+ if v == nil {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ return *v, true
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+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
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+func (m *MsgMutation) ClearDeletedAt() {
|
|
|
+ m.deleted_at = nil
|
|
|
+ m.clearedFields[msg.FieldDeletedAt] = struct{}{}
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+func (m *MsgMutation) DeletedAtCleared() bool {
|
|
|
+ _, ok := m.clearedFields[msg.FieldDeletedAt]
|
|
|
+ return ok
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+func (m *MsgMutation) ResetDeletedAt() {
|
|
|
+ m.deleted_at = nil
|
|
|
+ delete(m.clearedFields, msg.FieldDeletedAt)
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+func (m *MsgMutation) SetStatus(u uint8) {
|
|
|
+ m.status = &u
|
|
|
+ m.addstatus = nil
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+func (m *MsgMutation) Status() (r uint8, exists bool) {
|
|
|
+ v := m.status
|
|
|
+ if v == nil {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ return *v, true
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+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
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+func (m *MsgMutation) AddStatus(u int8) {
|
|
|
+ if m.addstatus != nil {
|
|
|
+ *m.addstatus += u
|
|
|
+ } else {
|
|
|
+ m.addstatus = &u
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+func (m *MsgMutation) AddedStatus() (r int8, exists bool) {
|
|
|
+ v := m.addstatus
|
|
|
+ if v == nil {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ return *v, true
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+func (m *MsgMutation) ClearStatus() {
|
|
|
+ m.status = nil
|
|
|
+ m.addstatus = nil
|
|
|
+ m.clearedFields[msg.FieldStatus] = struct{}{}
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+func (m *MsgMutation) StatusCleared() bool {
|
|
|
+ _, ok := m.clearedFields[msg.FieldStatus]
|
|
|
+ return ok
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+func (m *MsgMutation) ResetStatus() {
|
|
|
+ m.status = nil
|
|
|
+ m.addstatus = nil
|
|
|
+ delete(m.clearedFields, msg.FieldStatus)
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+func (m *MsgMutation) SetFromwxid(s string) {
|
|
|
+ m.fromwxid = &s
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+func (m *MsgMutation) Fromwxid() (r string, exists bool) {
|
|
|
+ v := m.fromwxid
|
|
|
+ if v == nil {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ return *v, true
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+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
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+func (m *MsgMutation) ClearFromwxid() {
|
|
|
+ m.fromwxid = nil
|
|
|
+ m.clearedFields[msg.FieldFromwxid] = struct{}{}
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+func (m *MsgMutation) FromwxidCleared() bool {
|
|
|
+ _, ok := m.clearedFields[msg.FieldFromwxid]
|
|
|
+ return ok
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+func (m *MsgMutation) ResetFromwxid() {
|
|
|
+ m.fromwxid = nil
|
|
|
+ delete(m.clearedFields, msg.FieldFromwxid)
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+func (m *MsgMutation) SetToid(s string) {
|
|
|
+ m.toid = &s
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+func (m *MsgMutation) Toid() (r string, exists bool) {
|
|
|
+ v := m.toid
|
|
|
+ if v == nil {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ return *v, true
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+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
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+func (m *MsgMutation) ClearToid() {
|
|
|
+ m.toid = nil
|
|
|
+ m.clearedFields[msg.FieldToid] = struct{}{}
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+func (m *MsgMutation) ToidCleared() bool {
|
|
|
+ _, ok := m.clearedFields[msg.FieldToid]
|
|
|
+ return ok
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+func (m *MsgMutation) ResetToid() {
|
|
|
+ m.toid = nil
|
|
|
+ delete(m.clearedFields, msg.FieldToid)
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+func (m *MsgMutation) SetMsgtype(i int32) {
|
|
|
+ m.msgtype = &i
|
|
|
+ m.addmsgtype = nil
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+func (m *MsgMutation) Msgtype() (r int32, exists bool) {
|
|
|
+ v := m.msgtype
|
|
|
+ if v == nil {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ return *v, true
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+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
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+func (m *MsgMutation) AddMsgtype(i int32) {
|
|
|
+ if m.addmsgtype != nil {
|
|
|
+ *m.addmsgtype += i
|
|
|
+ } else {
|
|
|
+ m.addmsgtype = &i
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+func (m *MsgMutation) AddedMsgtype() (r int32, exists bool) {
|
|
|
+ v := m.addmsgtype
|
|
|
+ if v == nil {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ return *v, true
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+func (m *MsgMutation) ClearMsgtype() {
|
|
|
+ m.msgtype = nil
|
|
|
+ m.addmsgtype = nil
|
|
|
+ m.clearedFields[msg.FieldMsgtype] = struct{}{}
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+func (m *MsgMutation) MsgtypeCleared() bool {
|
|
|
+ _, ok := m.clearedFields[msg.FieldMsgtype]
|
|
|
+ return ok
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+func (m *MsgMutation) ResetMsgtype() {
|
|
|
+ m.msgtype = nil
|
|
|
+ m.addmsgtype = nil
|
|
|
+ delete(m.clearedFields, msg.FieldMsgtype)
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+func (m *MsgMutation) SetMsg(s string) {
|
|
|
+ m.msg = &s
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+func (m *MsgMutation) Msg() (r string, exists bool) {
|
|
|
+ v := m.msg
|
|
|
+ if v == nil {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ return *v, true
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+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
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+func (m *MsgMutation) ClearMsg() {
|
|
|
+ m.msg = nil
|
|
|
+ m.clearedFields[msg.FieldMsg] = struct{}{}
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+func (m *MsgMutation) MsgCleared() bool {
|
|
|
+ _, ok := m.clearedFields[msg.FieldMsg]
|
|
|
+ return ok
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+func (m *MsgMutation) ResetMsg() {
|
|
|
+ m.msg = nil
|
|
|
+ delete(m.clearedFields, msg.FieldMsg)
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+func (m *MsgMutation) SetBatchNo(s string) {
|
|
|
+ m.batch_no = &s
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+func (m *MsgMutation) BatchNo() (r string, exists bool) {
|
|
|
+ v := m.batch_no
|
|
|
+ if v == nil {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ return *v, true
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+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
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+func (m *MsgMutation) ClearBatchNo() {
|
|
|
+ m.batch_no = nil
|
|
|
+ m.clearedFields[msg.FieldBatchNo] = struct{}{}
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+func (m *MsgMutation) BatchNoCleared() bool {
|
|
|
+ _, ok := m.clearedFields[msg.FieldBatchNo]
|
|
|
+ return ok
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+func (m *MsgMutation) ResetBatchNo() {
|
|
|
+ m.batch_no = nil
|
|
|
+ delete(m.clearedFields, msg.FieldBatchNo)
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+func (m *MsgMutation) Where(ps ...predicate.Msg) {
|
|
|
+ m.predicates = append(m.predicates, ps...)
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+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...)
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+func (m *MsgMutation) Op() Op {
|
|
|
+ return m.op
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+func (m *MsgMutation) SetOp(op Op) {
|
|
|
+ m.op = op
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+func (m *MsgMutation) Type() string {
|
|
|
+ return m.typ
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+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
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+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
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+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)
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+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)
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+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
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+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
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+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)
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+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
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+func (m *MsgMutation) FieldCleared(name string) bool {
|
|
|
+ _, ok := m.clearedFields[name]
|
|
|
+ return ok
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+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)
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+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)
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+func (m *MsgMutation) AddedEdges() []string {
|
|
|
+ edges := make([]string, 0, 0)
|
|
|
+ return edges
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+func (m *MsgMutation) AddedIDs(name string) []ent.Value {
|
|
|
+ return nil
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+func (m *MsgMutation) RemovedEdges() []string {
|
|
|
+ edges := make([]string, 0, 0)
|
|
|
+ return edges
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+func (m *MsgMutation) RemovedIDs(name string) []ent.Value {
|
|
|
+ return nil
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+func (m *MsgMutation) ClearedEdges() []string {
|
|
|
+ edges := make([]string, 0, 0)
|
|
|
+ return edges
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+func (m *MsgMutation) EdgeCleared(name string) bool {
|
|
|
+ return false
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+func (m *MsgMutation) ClearEdge(name string) error {
|
|
|
+ return fmt.Errorf("unknown Msg unique edge %s", name)
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+func (m *MsgMutation) ResetEdge(name string) error {
|
|
|
+ return fmt.Errorf("unknown Msg edge %s", name)
|
|
|
+}
|
|
|
+
|
|
|
|
|
|
type ServerMutation struct {
|
|
|
config
|