浏览代码

修复msg的model

DESKTOP-53URE31\USER 10 月之前
父节点
当前提交
d19c059fd8
共有 13 个文件被更改,包括 170 次插入161 次删除
  1. 8 6
      ent/client.go
  2. 1 1
      ent/migrate/schema.go
  3. 2 2
      ent/msg.go
  4. 19 0
      ent/msg/msg.go
  5. 9 9
      ent/msg/where.go
  6. 52 47
      ent/msg_create.go
  7. 1 1
      ent/msg_delete.go
  8. 9 9
      ent/msg_query.go
  9. 32 52
      ent/msg_update.go
  10. 6 6
      ent/mutation.go
  11. 20 0
      ent/runtime/runtime.go
  12. 11 4
      ent/schema/msg.go
  13. 0 24
      ent/set_not_nil.go

+ 8 - 6
ent/client.go

@@ -1295,7 +1295,7 @@ func (c *MsgClient) UpdateOne(m *Msg) *MsgUpdateOne {
 }
 
 // UpdateOneID returns an update builder for the given id.
-func (c *MsgClient) UpdateOneID(id int) *MsgUpdateOne {
+func (c *MsgClient) UpdateOneID(id uint64) *MsgUpdateOne {
 	mutation := newMsgMutation(c.config, OpUpdateOne, withMsgID(id))
 	return &MsgUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
 }
@@ -1312,7 +1312,7 @@ func (c *MsgClient) DeleteOne(m *Msg) *MsgDeleteOne {
 }
 
 // DeleteOneID returns a builder for deleting the given entity by its id.
-func (c *MsgClient) DeleteOneID(id int) *MsgDeleteOne {
+func (c *MsgClient) DeleteOneID(id uint64) *MsgDeleteOne {
 	builder := c.Delete().Where(msg.ID(id))
 	builder.mutation.id = &id
 	builder.mutation.op = OpDeleteOne
@@ -1329,12 +1329,12 @@ func (c *MsgClient) Query() *MsgQuery {
 }
 
 // Get returns a Msg entity by its id.
-func (c *MsgClient) Get(ctx context.Context, id int) (*Msg, error) {
+func (c *MsgClient) Get(ctx context.Context, id uint64) (*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 {
+func (c *MsgClient) GetX(ctx context.Context, id uint64) *Msg {
 	obj, err := c.Get(ctx, id)
 	if err != nil {
 		panic(err)
@@ -1344,12 +1344,14 @@ func (c *MsgClient) GetX(ctx context.Context, id int) *Msg {
 
 // Hooks returns the client hooks.
 func (c *MsgClient) Hooks() []Hook {
-	return c.hooks.Msg
+	hooks := c.hooks.Msg
+	return append(hooks[:len(hooks):len(hooks)], msg.Hooks[:]...)
 }
 
 // Interceptors returns the client interceptors.
 func (c *MsgClient) Interceptors() []Interceptor {
-	return c.inters.Msg
+	inters := c.inters.Msg
+	return append(inters[:len(inters):len(inters)], msg.Interceptors[:]...)
 }
 
 func (c *MsgClient) mutate(ctx context.Context, m *MsgMutation) (Value, error) {

+ 1 - 1
ent/migrate/schema.go

@@ -226,7 +226,7 @@ var (
 	}
 	// MsgColumns holds the columns for the "msg" table.
 	MsgColumns = []*schema.Column{
-		{Name: "id", Type: field.TypeInt, Increment: true},
+		{Name: "id", Type: field.TypeUint64, 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 | 删除日期"},

+ 2 - 2
ent/msg.go

@@ -16,7 +16,7 @@ import (
 type Msg struct {
 	config `json:"-"`
 	// ID of the ent.
-	ID int `json:"id,omitempty"`
+	ID uint64 `json:"id,omitempty"`
 	// Create Time | 创建日期
 	CreatedAt time.Time `json:"created_at,omitempty"`
 	// Update Time | 修改日期
@@ -69,7 +69,7 @@ func (m *Msg) assignValues(columns []string, values []any) error {
 			if !ok {
 				return fmt.Errorf("unexpected type %T for field id", value)
 			}
-			m.ID = int(value.Int64)
+			m.ID = uint64(value.Int64)
 		case msg.FieldCreatedAt:
 			if value, ok := values[i].(*sql.NullTime); !ok {
 				return fmt.Errorf("unexpected type %T for field created_at", values[i])

+ 19 - 0
ent/msg/msg.go

@@ -3,6 +3,9 @@
 package msg
 
 import (
+	"time"
+
+	"entgo.io/ent"
 	"entgo.io/ent/dialect/sql"
 )
 
@@ -57,6 +60,22 @@ func ValidColumn(column string) bool {
 	return false
 }
 
+// Note that the variables below are initialized by the runtime
+// package on the initialization of the application. Therefore,
+// it should be imported in the main as follows:
+//
+//	import _ "wechat-api/ent/runtime"
+var (
+	Hooks        [1]ent.Hook
+	Interceptors [1]ent.Interceptor
+	// DefaultCreatedAt holds the default value on creation for the "created_at" field.
+	DefaultCreatedAt func() time.Time
+	// DefaultUpdatedAt holds the default value on creation for the "updated_at" field.
+	DefaultUpdatedAt func() time.Time
+	// UpdateDefaultUpdatedAt holds the default value on update for the "updated_at" field.
+	UpdateDefaultUpdatedAt func() time.Time
+)
+
 // OrderOption defines the ordering options for the Msg queries.
 type OrderOption func(*sql.Selector)
 

+ 9 - 9
ent/msg/where.go

@@ -10,47 +10,47 @@ import (
 )
 
 // ID filters vertices based on their ID field.
-func ID(id int) predicate.Msg {
+func ID(id uint64) predicate.Msg {
 	return predicate.Msg(sql.FieldEQ(FieldID, id))
 }
 
 // IDEQ applies the EQ predicate on the ID field.
-func IDEQ(id int) predicate.Msg {
+func IDEQ(id uint64) predicate.Msg {
 	return predicate.Msg(sql.FieldEQ(FieldID, id))
 }
 
 // IDNEQ applies the NEQ predicate on the ID field.
-func IDNEQ(id int) predicate.Msg {
+func IDNEQ(id uint64) predicate.Msg {
 	return predicate.Msg(sql.FieldNEQ(FieldID, id))
 }
 
 // IDIn applies the In predicate on the ID field.
-func IDIn(ids ...int) predicate.Msg {
+func IDIn(ids ...uint64) predicate.Msg {
 	return predicate.Msg(sql.FieldIn(FieldID, ids...))
 }
 
 // IDNotIn applies the NotIn predicate on the ID field.
-func IDNotIn(ids ...int) predicate.Msg {
+func IDNotIn(ids ...uint64) predicate.Msg {
 	return predicate.Msg(sql.FieldNotIn(FieldID, ids...))
 }
 
 // IDGT applies the GT predicate on the ID field.
-func IDGT(id int) predicate.Msg {
+func IDGT(id uint64) predicate.Msg {
 	return predicate.Msg(sql.FieldGT(FieldID, id))
 }
 
 // IDGTE applies the GTE predicate on the ID field.
-func IDGTE(id int) predicate.Msg {
+func IDGTE(id uint64) predicate.Msg {
 	return predicate.Msg(sql.FieldGTE(FieldID, id))
 }
 
 // IDLT applies the LT predicate on the ID field.
-func IDLT(id int) predicate.Msg {
+func IDLT(id uint64) predicate.Msg {
 	return predicate.Msg(sql.FieldLT(FieldID, id))
 }
 
 // IDLTE applies the LTE predicate on the ID field.
-func IDLTE(id int) predicate.Msg {
+func IDLTE(id uint64) predicate.Msg {
 	return predicate.Msg(sql.FieldLTE(FieldID, id))
 }
 

+ 52 - 47
ent/msg_create.go

@@ -28,12 +28,28 @@ func (mc *MsgCreate) SetCreatedAt(t time.Time) *MsgCreate {
 	return mc
 }
 
+// SetNillableCreatedAt sets the "created_at" field if the given value is not nil.
+func (mc *MsgCreate) SetNillableCreatedAt(t *time.Time) *MsgCreate {
+	if t != nil {
+		mc.SetCreatedAt(*t)
+	}
+	return mc
+}
+
 // SetUpdatedAt sets the "updated_at" field.
 func (mc *MsgCreate) SetUpdatedAt(t time.Time) *MsgCreate {
 	mc.mutation.SetUpdatedAt(t)
 	return mc
 }
 
+// SetNillableUpdatedAt sets the "updated_at" field if the given value is not nil.
+func (mc *MsgCreate) SetNillableUpdatedAt(t *time.Time) *MsgCreate {
+	if t != nil {
+		mc.SetUpdatedAt(*t)
+	}
+	return mc
+}
+
 // SetDeletedAt sets the "deleted_at" field.
 func (mc *MsgCreate) SetDeletedAt(t time.Time) *MsgCreate {
 	mc.mutation.SetDeletedAt(t)
@@ -133,8 +149,8 @@ func (mc *MsgCreate) SetNillableBatchNo(s *string) *MsgCreate {
 }
 
 // SetID sets the "id" field.
-func (mc *MsgCreate) SetID(i int) *MsgCreate {
-	mc.mutation.SetID(i)
+func (mc *MsgCreate) SetID(u uint64) *MsgCreate {
+	mc.mutation.SetID(u)
 	return mc
 }
 
@@ -145,6 +161,9 @@ func (mc *MsgCreate) Mutation() *MsgMutation {
 
 // Save creates the Msg in the database.
 func (mc *MsgCreate) Save(ctx context.Context) (*Msg, error) {
+	if err := mc.defaults(); err != nil {
+		return nil, err
+	}
 	return withHooks(ctx, mc.sqlSave, mc.mutation, mc.hooks)
 }
 
@@ -170,6 +189,25 @@ func (mc *MsgCreate) ExecX(ctx context.Context) {
 	}
 }
 
+// defaults sets the default values of the builder before save.
+func (mc *MsgCreate) defaults() error {
+	if _, ok := mc.mutation.CreatedAt(); !ok {
+		if msg.DefaultCreatedAt == nil {
+			return fmt.Errorf("ent: uninitialized msg.DefaultCreatedAt (forgotten import ent/runtime?)")
+		}
+		v := msg.DefaultCreatedAt()
+		mc.mutation.SetCreatedAt(v)
+	}
+	if _, ok := mc.mutation.UpdatedAt(); !ok {
+		if msg.DefaultUpdatedAt == nil {
+			return fmt.Errorf("ent: uninitialized msg.DefaultUpdatedAt (forgotten import ent/runtime?)")
+		}
+		v := msg.DefaultUpdatedAt()
+		mc.mutation.SetUpdatedAt(v)
+	}
+	return nil
+}
+
 // check runs all checks and user-defined validators on the builder.
 func (mc *MsgCreate) check() error {
 	if _, ok := mc.mutation.CreatedAt(); !ok {
@@ -194,7 +232,7 @@ func (mc *MsgCreate) sqlSave(ctx context.Context) (*Msg, error) {
 	}
 	if _spec.ID.Value != _node.ID {
 		id := _spec.ID.Value.(int64)
-		_node.ID = int(id)
+		_node.ID = uint64(id)
 	}
 	mc.mutation.id = &_node.ID
 	mc.mutation.done = true
@@ -204,7 +242,7 @@ func (mc *MsgCreate) sqlSave(ctx context.Context) (*Msg, error) {
 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 = sqlgraph.NewCreateSpec(msg.Table, sqlgraph.NewFieldSpec(msg.FieldID, field.TypeUint64))
 	)
 	_spec.OnConflict = mc.conflict
 	if id, ok := mc.mutation.ID(); ok {
@@ -299,18 +337,6 @@ type (
 	}
 )
 
-// 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)
@@ -478,6 +504,9 @@ func (u *MsgUpsertOne) UpdateNewValues() *MsgUpsertOne {
 		if _, exists := u.create.mutation.ID(); exists {
 			s.SetIgnore(msg.FieldID)
 		}
+		if _, exists := u.create.mutation.CreatedAt(); exists {
+			s.SetIgnore(msg.FieldCreatedAt)
+		}
 	}))
 	return u
 }
@@ -509,20 +538,6 @@ func (u *MsgUpsertOne) Update(set func(*MsgUpsert)) *MsgUpsertOne {
 	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) {
@@ -714,7 +729,7 @@ func (u *MsgUpsertOne) ExecX(ctx context.Context) {
 }
 
 // Exec executes the UPSERT query and returns the inserted/updated ID.
-func (u *MsgUpsertOne) ID(ctx context.Context) (id int, err error) {
+func (u *MsgUpsertOne) ID(ctx context.Context) (id uint64, err error) {
 	node, err := u.create.Save(ctx)
 	if err != nil {
 		return id, err
@@ -723,7 +738,7 @@ func (u *MsgUpsertOne) ID(ctx context.Context) (id int, err error) {
 }
 
 // IDX is like ID, but panics if an error occurs.
-func (u *MsgUpsertOne) IDX(ctx context.Context) int {
+func (u *MsgUpsertOne) IDX(ctx context.Context) uint64 {
 	id, err := u.ID(ctx)
 	if err != nil {
 		panic(err)
@@ -750,6 +765,7 @@ func (mcb *MsgCreateBulk) Save(ctx context.Context) ([]*Msg, error) {
 	for i := range mcb.builders {
 		func(i int, root context.Context) {
 			builder := mcb.builders[i]
+			builder.defaults()
 			var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {
 				mutation, ok := m.(*MsgMutation)
 				if !ok {
@@ -779,7 +795,7 @@ func (mcb *MsgCreateBulk) Save(ctx context.Context) ([]*Msg, error) {
 				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)
+					nodes[i].ID = uint64(id)
 				}
 				mutation.done = true
 				return nodes[i], nil
@@ -879,6 +895,9 @@ func (u *MsgUpsertBulk) UpdateNewValues() *MsgUpsertBulk {
 			if _, exists := b.mutation.ID(); exists {
 				s.SetIgnore(msg.FieldID)
 			}
+			if _, exists := b.mutation.CreatedAt(); exists {
+				s.SetIgnore(msg.FieldCreatedAt)
+			}
 		}
 	}))
 	return u
@@ -911,20 +930,6 @@ func (u *MsgUpsertBulk) Update(set func(*MsgUpsert)) *MsgUpsertBulk {
 	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) {

+ 1 - 1
ent/msg_delete.go

@@ -40,7 +40,7 @@ func (md *MsgDelete) ExecX(ctx context.Context) int {
 }
 
 func (md *MsgDelete) sqlExec(ctx context.Context) (int, error) {
-	_spec := sqlgraph.NewDeleteSpec(msg.Table, sqlgraph.NewFieldSpec(msg.FieldID, field.TypeInt))
+	_spec := sqlgraph.NewDeleteSpec(msg.Table, sqlgraph.NewFieldSpec(msg.FieldID, field.TypeUint64))
 	if ps := md.mutation.predicates; len(ps) > 0 {
 		_spec.Predicate = func(selector *sql.Selector) {
 			for i := range ps {

+ 9 - 9
ent/msg_query.go

@@ -81,8 +81,8 @@ func (mq *MsgQuery) FirstX(ctx context.Context) *Msg {
 
 // 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
+func (mq *MsgQuery) FirstID(ctx context.Context) (id uint64, err error) {
+	var ids []uint64
 	if ids, err = mq.Limit(1).IDs(setContextOp(ctx, mq.ctx, "FirstID")); err != nil {
 		return
 	}
@@ -94,7 +94,7 @@ func (mq *MsgQuery) FirstID(ctx context.Context) (id int, err error) {
 }
 
 // FirstIDX is like FirstID, but panics if an error occurs.
-func (mq *MsgQuery) FirstIDX(ctx context.Context) int {
+func (mq *MsgQuery) FirstIDX(ctx context.Context) uint64 {
 	id, err := mq.FirstID(ctx)
 	if err != nil && !IsNotFound(err) {
 		panic(err)
@@ -132,8 +132,8 @@ func (mq *MsgQuery) OnlyX(ctx context.Context) *Msg {
 // 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
+func (mq *MsgQuery) OnlyID(ctx context.Context) (id uint64, err error) {
+	var ids []uint64
 	if ids, err = mq.Limit(2).IDs(setContextOp(ctx, mq.ctx, "OnlyID")); err != nil {
 		return
 	}
@@ -149,7 +149,7 @@ func (mq *MsgQuery) OnlyID(ctx context.Context) (id int, err error) {
 }
 
 // OnlyIDX is like OnlyID, but panics if an error occurs.
-func (mq *MsgQuery) OnlyIDX(ctx context.Context) int {
+func (mq *MsgQuery) OnlyIDX(ctx context.Context) uint64 {
 	id, err := mq.OnlyID(ctx)
 	if err != nil {
 		panic(err)
@@ -177,7 +177,7 @@ func (mq *MsgQuery) AllX(ctx context.Context) []*Msg {
 }
 
 // IDs executes the query and returns a list of Msg IDs.
-func (mq *MsgQuery) IDs(ctx context.Context) (ids []int, err error) {
+func (mq *MsgQuery) IDs(ctx context.Context) (ids []uint64, err error) {
 	if mq.ctx.Unique == nil && mq.path != nil {
 		mq.Unique(true)
 	}
@@ -189,7 +189,7 @@ func (mq *MsgQuery) IDs(ctx context.Context) (ids []int, err error) {
 }
 
 // IDsX is like IDs, but panics if an error occurs.
-func (mq *MsgQuery) IDsX(ctx context.Context) []int {
+func (mq *MsgQuery) IDsX(ctx context.Context) []uint64 {
 	ids, err := mq.IDs(ctx)
 	if err != nil {
 		panic(err)
@@ -364,7 +364,7 @@ func (mq *MsgQuery) sqlCount(ctx context.Context) (int, error) {
 }
 
 func (mq *MsgQuery) querySpec() *sqlgraph.QuerySpec {
-	_spec := sqlgraph.NewQuerySpec(msg.Table, msg.Columns, sqlgraph.NewFieldSpec(msg.FieldID, field.TypeInt))
+	_spec := sqlgraph.NewQuerySpec(msg.Table, msg.Columns, sqlgraph.NewFieldSpec(msg.FieldID, field.TypeUint64))
 	_spec.From = mq.sql
 	if unique := mq.ctx.Unique; unique != nil {
 		_spec.Unique = *unique

+ 32 - 52
ent/msg_update.go

@@ -28,34 +28,12 @@ func (mu *MsgUpdate) Where(ps ...predicate.Msg) *MsgUpdate {
 	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)
@@ -217,6 +195,9 @@ func (mu *MsgUpdate) Mutation() *MsgMutation {
 
 // Save executes the query and returns the number of nodes affected by the update operation.
 func (mu *MsgUpdate) Save(ctx context.Context) (int, error) {
+	if err := mu.defaults(); err != nil {
+		return 0, err
+	}
 	return withHooks(ctx, mu.sqlSave, mu.mutation, mu.hooks)
 }
 
@@ -242,8 +223,20 @@ func (mu *MsgUpdate) ExecX(ctx context.Context) {
 	}
 }
 
+// defaults sets the default values of the builder before save.
+func (mu *MsgUpdate) defaults() error {
+	if _, ok := mu.mutation.UpdatedAt(); !ok {
+		if msg.UpdateDefaultUpdatedAt == nil {
+			return fmt.Errorf("ent: uninitialized msg.UpdateDefaultUpdatedAt (forgotten import ent/runtime?)")
+		}
+		v := msg.UpdateDefaultUpdatedAt()
+		mu.mutation.SetUpdatedAt(v)
+	}
+	return nil
+}
+
 func (mu *MsgUpdate) sqlSave(ctx context.Context) (n int, err error) {
-	_spec := sqlgraph.NewUpdateSpec(msg.Table, msg.Columns, sqlgraph.NewFieldSpec(msg.FieldID, field.TypeInt))
+	_spec := sqlgraph.NewUpdateSpec(msg.Table, msg.Columns, sqlgraph.NewFieldSpec(msg.FieldID, field.TypeUint64))
 	if ps := mu.mutation.predicates; len(ps) > 0 {
 		_spec.Predicate = func(selector *sql.Selector) {
 			for i := range ps {
@@ -251,9 +244,6 @@ func (mu *MsgUpdate) sqlSave(ctx context.Context) (n int, err error) {
 			}
 		}
 	}
-	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)
 	}
@@ -325,34 +315,12 @@ type MsgUpdateOne struct {
 	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)
@@ -527,6 +495,9 @@ func (muo *MsgUpdateOne) Select(field string, fields ...string) *MsgUpdateOne {
 
 // Save executes the query and returns the updated Msg entity.
 func (muo *MsgUpdateOne) Save(ctx context.Context) (*Msg, error) {
+	if err := muo.defaults(); err != nil {
+		return nil, err
+	}
 	return withHooks(ctx, muo.sqlSave, muo.mutation, muo.hooks)
 }
 
@@ -552,8 +523,20 @@ func (muo *MsgUpdateOne) ExecX(ctx context.Context) {
 	}
 }
 
+// defaults sets the default values of the builder before save.
+func (muo *MsgUpdateOne) defaults() error {
+	if _, ok := muo.mutation.UpdatedAt(); !ok {
+		if msg.UpdateDefaultUpdatedAt == nil {
+			return fmt.Errorf("ent: uninitialized msg.UpdateDefaultUpdatedAt (forgotten import ent/runtime?)")
+		}
+		v := msg.UpdateDefaultUpdatedAt()
+		muo.mutation.SetUpdatedAt(v)
+	}
+	return nil
+}
+
 func (muo *MsgUpdateOne) sqlSave(ctx context.Context) (_node *Msg, err error) {
-	_spec := sqlgraph.NewUpdateSpec(msg.Table, msg.Columns, sqlgraph.NewFieldSpec(msg.FieldID, field.TypeInt))
+	_spec := sqlgraph.NewUpdateSpec(msg.Table, msg.Columns, sqlgraph.NewFieldSpec(msg.FieldID, field.TypeUint64))
 	id, ok := muo.mutation.ID()
 	if !ok {
 		return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "Msg.id" for update`)}
@@ -578,9 +561,6 @@ func (muo *MsgUpdateOne) sqlSave(ctx context.Context) (_node *Msg, err error) {
 			}
 		}
 	}
-	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)
 	}

+ 6 - 6
ent/mutation.go

@@ -7029,7 +7029,7 @@ type MsgMutation struct {
 	config
 	op            Op
 	typ           string
-	id            *int
+	id            *uint64
 	created_at    *time.Time
 	updated_at    *time.Time
 	deleted_at    *time.Time
@@ -7067,7 +7067,7 @@ func newMsgMutation(c config, op Op, opts ...msgOption) *MsgMutation {
 }
 
 // withMsgID sets the ID field of the mutation.
-func withMsgID(id int) msgOption {
+func withMsgID(id uint64) msgOption {
 	return func(m *MsgMutation) {
 		var (
 			err   error
@@ -7119,13 +7119,13 @@ func (m MsgMutation) Tx() (*Tx, error) {
 
 // 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) {
+func (m *MsgMutation) SetID(id uint64) {
 	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) {
+func (m *MsgMutation) ID() (id uint64, exists bool) {
 	if m.id == nil {
 		return
 	}
@@ -7136,12 +7136,12 @@ func (m *MsgMutation) ID() (id int, exists bool) {
 // 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) {
+func (m *MsgMutation) IDs(ctx context.Context) ([]uint64, error) {
 	switch {
 	case m.op.Is(OpUpdateOne | OpDeleteOne):
 		id, exists := m.ID()
 		if exists {
-			return []int{id}, nil
+			return []uint64{id}, nil
 		}
 		fallthrough
 	case m.op.Is(OpUpdate | OpDelete):

+ 20 - 0
ent/runtime/runtime.go

@@ -10,6 +10,7 @@ import (
 	"wechat-api/ent/labelrelationship"
 	"wechat-api/ent/message"
 	"wechat-api/ent/messagerecords"
+	"wechat-api/ent/msg"
 	"wechat-api/ent/schema"
 	"wechat-api/ent/server"
 	"wechat-api/ent/sopnode"
@@ -275,6 +276,25 @@ func init() {
 	messagerecordsDescSubSourceID := messagerecordsFields[11].Descriptor()
 	// messagerecords.DefaultSubSourceID holds the default value on creation for the sub_source_id field.
 	messagerecords.DefaultSubSourceID = messagerecordsDescSubSourceID.Default.(uint64)
+	msgMixin := schema.Msg{}.Mixin()
+	msgMixinHooks1 := msgMixin[1].Hooks()
+	msg.Hooks[0] = msgMixinHooks1[0]
+	msgMixinInters1 := msgMixin[1].Interceptors()
+	msg.Interceptors[0] = msgMixinInters1[0]
+	msgMixinFields0 := msgMixin[0].Fields()
+	_ = msgMixinFields0
+	msgFields := schema.Msg{}.Fields()
+	_ = msgFields
+	// msgDescCreatedAt is the schema descriptor for created_at field.
+	msgDescCreatedAt := msgMixinFields0[1].Descriptor()
+	// msg.DefaultCreatedAt holds the default value on creation for the created_at field.
+	msg.DefaultCreatedAt = msgDescCreatedAt.Default.(func() time.Time)
+	// msgDescUpdatedAt is the schema descriptor for updated_at field.
+	msgDescUpdatedAt := msgMixinFields0[2].Descriptor()
+	// msg.DefaultUpdatedAt holds the default value on creation for the updated_at field.
+	msg.DefaultUpdatedAt = msgDescUpdatedAt.Default.(func() time.Time)
+	// msg.UpdateDefaultUpdatedAt holds the default value on update for the updated_at field.
+	msg.UpdateDefaultUpdatedAt = msgDescUpdatedAt.UpdateDefault.(func() time.Time)
 	serverMixin := schema.Server{}.Mixin()
 	serverMixinHooks2 := serverMixin[2].Hooks()
 	server.Hooks[0] = serverMixinHooks2[0]

+ 11 - 4
ent/schema/msg.go

@@ -1,11 +1,14 @@
 package schema
 
 import (
+	"wechat-api/ent/schema/localmixin"
+
 	"entgo.io/ent"
 	"entgo.io/ent/dialect/entsql"
 	"entgo.io/ent/schema"
 	"entgo.io/ent/schema/field"
 	"entgo.io/ent/schema/index"
+	"github.com/suyuan32/simple-admin-common/orm/ent/mixins"
 )
 
 type Msg struct {
@@ -14,10 +17,6 @@ type Msg struct {
 
 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"),
@@ -25,6 +24,14 @@ func (Msg) Fields() []ent.Field {
 		field.String("msg").Optional().Comment("消息"),
 		field.String("batch_no").Optional().Comment("批次号")}
 }
+
+func (Msg) Mixin() []ent.Mixin {
+	return []ent.Mixin{
+		mixins.IDMixin{},
+		localmixin.SoftDeleteMixin{},
+	}
+}
+
 func (Msg) Edges() []ent.Edge {
 	return nil
 }

+ 0 - 24
ent/set_not_nil.go

@@ -1472,30 +1472,6 @@ 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)