From a179d6787351b6a63eb3328064aeaea44cd1d736 Mon Sep 17 00:00:00 2001 From: it512 Date: Fri, 20 Dec 2024 16:19:08 +0800 Subject: [PATCH] x --- member/cmd/member/main.go | 11 + member/mq/mq.go | 39 +++- member/orm/ent/client.go | 9 +- member/orm/ent/entql.go | 56 ++--- member/orm/ent/member.go | 68 +++--- member/orm/ent/member/member.go | 49 +++-- member/orm/ent/member/where.go | 250 +++++++++++++--------- member/orm/ent/member_create.go | 345 ++++++++++++++++--------------- member/orm/ent/member_delete.go | 2 +- member/orm/ent/member_query.go | 19 +- member/orm/ent/member_update.go | 206 ++++++++++-------- member/orm/ent/migrate/schema.go | 9 +- member/orm/ent/mutation.go | 341 +++++++++++++++++------------- member/orm/ent/runtime.go | 43 ++-- member/orm/schema/member.go | 17 +- wechat/go.mod | 3 + wechat/go.sum | 8 + 17 files changed, 844 insertions(+), 631 deletions(-) diff --git a/member/cmd/member/main.go b/member/cmd/member/main.go index 1dcf884..2d454b2 100644 --- a/member/cmd/member/main.go +++ b/member/cmd/member/main.go @@ -2,15 +2,26 @@ package main import ( "context" + "fmt" "log" "net/http" "github.com/go-chi/chi/v5" "github.com/go-chi/chi/v5/middleware" + "github.com/twiglab/crm/member/orm" "github.com/twiglab/crm/member/rpc/gql" ) +const DATABASE_URL = "user=crm password=crm0okm_PL< host=it9i.com port=15432 database=crm sslmode=disable" + func main() { + db, err := orm.FromURL(context.Background(), DATABASE_URL) + if err != nil { + log.Fatal(err) + } + + fmt.Println(db.Ping()) + mux := chi.NewMux() mux.Use(middleware.Logger, middleware.Recoverer) mux.Mount("/rpc", gql.New(context.Background())) diff --git a/member/mq/mq.go b/member/mq/mq.go index 6b5f8b5..bc991e1 100644 --- a/member/mq/mq.go +++ b/member/mq/mq.go @@ -17,6 +17,13 @@ type RecieverHandler interface { } type MemberAuthReciverHandle struct { + RabbitMQ + BindKey string + QueueName string +} + +func NewMemberAuthReciverHandle() *MemberAuthReciverHandle { + return &MemberAuthReciverHandle{} } func (h *MemberAuthReciverHandle) RecieveDelivery(ctx context.Context, delivery amqp.Delivery) { @@ -31,14 +38,9 @@ func (h *MemberAuthReciverHandle) RecieveDelivery(ctx context.Context, delivery } type RabbitMQ struct { - Conn *amqp.Connection - channel *amqp.Channel - //队列名称 - QueueName string - //交换机名称 + Conn *amqp.Connection + channel *amqp.Channel Exchange string - //bind Key 名称 - Key string } // 话题模式接受消息 @@ -121,3 +123,26 @@ func (r *RabbitMQ) Recieve(ctx context.Context, h RecieverHandler) (chan struct{ return forever, nil } + +func (r RabbitMQ) Create() error { + var err error + if r.channel, err = r.Conn.Channel(); err != nil { + return err + } + //1.试探性创建交换机 + err = r.channel.ExchangeDeclare( + r.Exchange, + //交换机类型 + amqp.ExchangeTopic, + true, + true, + false, + false, + nil, + ) + if err != nil { + return err + } + + return nil +} diff --git a/member/orm/ent/client.go b/member/orm/ent/client.go index 1c93e92..63a69bc 100644 --- a/member/orm/ent/client.go +++ b/member/orm/ent/client.go @@ -9,7 +9,6 @@ import ( "log" "reflect" - "github.com/google/uuid" "github.com/twiglab/crm/member/orm/ent/migrate" "entgo.io/ent" @@ -260,7 +259,7 @@ func (c *MemberClient) UpdateOne(m *Member) *MemberUpdateOne { } // UpdateOneID returns an update builder for the given id. -func (c *MemberClient) UpdateOneID(id uuid.UUID) *MemberUpdateOne { +func (c *MemberClient) UpdateOneID(id int) *MemberUpdateOne { mutation := newMemberMutation(c.config, OpUpdateOne, withMemberID(id)) return &MemberUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} } @@ -277,7 +276,7 @@ func (c *MemberClient) DeleteOne(m *Member) *MemberDeleteOne { } // DeleteOneID returns a builder for deleting the given entity by its id. -func (c *MemberClient) DeleteOneID(id uuid.UUID) *MemberDeleteOne { +func (c *MemberClient) DeleteOneID(id int) *MemberDeleteOne { builder := c.Delete().Where(member.ID(id)) builder.mutation.id = &id builder.mutation.op = OpDeleteOne @@ -294,12 +293,12 @@ func (c *MemberClient) Query() *MemberQuery { } // Get returns a Member entity by its id. -func (c *MemberClient) Get(ctx context.Context, id uuid.UUID) (*Member, error) { +func (c *MemberClient) Get(ctx context.Context, id int) (*Member, error) { return c.Query().Where(member.ID(id)).Only(ctx) } // GetX is like Get, but panics if an error occurs. -func (c *MemberClient) GetX(ctx context.Context, id uuid.UUID) *Member { +func (c *MemberClient) GetX(ctx context.Context, id int) *Member { obj, err := c.Get(ctx, id) if err != nil { panic(err) diff --git a/member/orm/ent/entql.go b/member/orm/ent/entql.go index a2c8b28..1f7d493 100644 --- a/member/orm/ent/entql.go +++ b/member/orm/ent/entql.go @@ -19,26 +19,27 @@ var schemaGraph = func() *sqlgraph.Schema { Table: member.Table, Columns: member.Columns, ID: &sqlgraph.FieldSpec{ - Type: field.TypeUUID, + Type: field.TypeInt, Column: member.FieldID, }, }, Type: "Member", Fields: map[string]*sqlgraph.FieldSpec{ - member.FieldCreateTime: {Type: field.TypeTime, Column: member.FieldCreateTime}, - member.FieldUpdateTime: {Type: field.TypeTime, Column: member.FieldUpdateTime}, - member.FieldCode: {Type: field.TypeString, Column: member.FieldCode}, - member.FieldPhone: {Type: field.TypeString, Column: member.FieldPhone}, - member.FieldNickname: {Type: field.TypeString, Column: member.FieldNickname}, - member.FieldWxOpenID: {Type: field.TypeString, Column: member.FieldWxOpenID}, - member.FieldWxUID: {Type: field.TypeString, Column: member.FieldWxUID}, - member.FieldBcmbCode: {Type: field.TypeString, Column: member.FieldBcmbCode}, - member.FieldBcmbRegTime: {Type: field.TypeTime, Column: member.FieldBcmbRegTime}, - member.FieldBcmbWxMsgID: {Type: field.TypeString, Column: member.FieldBcmbWxMsgID}, - member.FieldBcmbType: {Type: field.TypeInt, Column: member.FieldBcmbType}, - member.FieldLevel: {Type: field.TypeInt, Column: member.FieldLevel}, - member.FieldStatus: {Type: field.TypeInt, Column: member.FieldStatus}, - member.FieldSource: {Type: field.TypeInt, Column: member.FieldSource}, + member.FieldCreateTime: {Type: field.TypeTime, Column: member.FieldCreateTime}, + member.FieldUpdateTime: {Type: field.TypeTime, Column: member.FieldUpdateTime}, + member.FieldCode: {Type: field.TypeString, Column: member.FieldCode}, + member.FieldPhone: {Type: field.TypeString, Column: member.FieldPhone}, + member.FieldNickname: {Type: field.TypeString, Column: member.FieldNickname}, + member.FieldWxOpenID: {Type: field.TypeString, Column: member.FieldWxOpenID}, + member.FieldWxUID: {Type: field.TypeString, Column: member.FieldWxUID}, + member.FieldBcmbCode: {Type: field.TypeString, Column: member.FieldBcmbCode}, + member.FieldBcmbRegTime: {Type: field.TypeTime, Column: member.FieldBcmbRegTime}, + member.FieldBcmbRegMsgID: {Type: field.TypeString, Column: member.FieldBcmbRegMsgID}, + member.FieldBcmbType: {Type: field.TypeInt, Column: member.FieldBcmbType}, + member.FieldLevel: {Type: field.TypeInt, Column: member.FieldLevel}, + member.FieldSource: {Type: field.TypeInt, Column: member.FieldSource}, + member.FieldLastTime: {Type: field.TypeTime, Column: member.FieldLastTime}, + member.FieldStatus: {Type: field.TypeInt, Column: member.FieldStatus}, }, } return graph @@ -85,8 +86,8 @@ func (f *MemberFilter) Where(p entql.P) { }) } -// WhereID applies the entql [16]byte predicate on the id field. -func (f *MemberFilter) WhereID(p entql.ValueP) { +// WhereID applies the entql int predicate on the id field. +func (f *MemberFilter) WhereID(p entql.IntP) { f.Where(p.Field(member.FieldID)) } @@ -135,9 +136,9 @@ func (f *MemberFilter) WhereBcmbRegTime(p entql.TimeP) { f.Where(p.Field(member.FieldBcmbRegTime)) } -// WhereBcmbWxMsgID applies the entql string predicate on the bcmb_wx_msg_id field. -func (f *MemberFilter) WhereBcmbWxMsgID(p entql.StringP) { - f.Where(p.Field(member.FieldBcmbWxMsgID)) +// WhereBcmbRegMsgID applies the entql string predicate on the bcmb_reg_msg_id field. +func (f *MemberFilter) WhereBcmbRegMsgID(p entql.StringP) { + f.Where(p.Field(member.FieldBcmbRegMsgID)) } // WhereBcmbType applies the entql int predicate on the bcmb_type field. @@ -150,12 +151,17 @@ func (f *MemberFilter) WhereLevel(p entql.IntP) { f.Where(p.Field(member.FieldLevel)) } -// WhereStatus applies the entql int predicate on the status field. -func (f *MemberFilter) WhereStatus(p entql.IntP) { - f.Where(p.Field(member.FieldStatus)) -} - // WhereSource applies the entql int predicate on the source field. func (f *MemberFilter) WhereSource(p entql.IntP) { f.Where(p.Field(member.FieldSource)) } + +// WhereLastTime applies the entql time.Time predicate on the last_time field. +func (f *MemberFilter) WhereLastTime(p entql.TimeP) { + f.Where(p.Field(member.FieldLastTime)) +} + +// WhereStatus applies the entql int predicate on the status field. +func (f *MemberFilter) WhereStatus(p entql.IntP) { + f.Where(p.Field(member.FieldStatus)) +} diff --git a/member/orm/ent/member.go b/member/orm/ent/member.go index 5d2fe7e..fc2b4e3 100644 --- a/member/orm/ent/member.go +++ b/member/orm/ent/member.go @@ -9,7 +9,6 @@ import ( "entgo.io/ent" "entgo.io/ent/dialect/sql" - "github.com/google/uuid" "github.com/twiglab/crm/member/orm/ent/member" ) @@ -17,7 +16,7 @@ import ( type Member struct { config `json:"-"` // ID of the ent. - ID uuid.UUID `json:"id,omitempty"` + ID int `json:"id,omitempty"` // CreateTime holds the value of the "create_time" field. CreateTime time.Time `json:"create_time,omitempty"` // UpdateTime holds the value of the "update_time" field. @@ -36,16 +35,18 @@ type Member struct { BcmbCode string `json:"bcmb_code,omitempty"` // BcmbRegTime holds the value of the "bcmb_reg_time" field. BcmbRegTime *time.Time `json:"bcmb_reg_time,omitempty"` - // BcmbWxMsgID holds the value of the "bcmb_wx_msg_id" field. - BcmbWxMsgID string `json:"bcmb_wx_msg_id,omitempty"` + // BcmbRegMsgID holds the value of the "bcmb_reg_msg_id" field. + BcmbRegMsgID string `json:"bcmb_reg_msg_id,omitempty"` // BcmbType holds the value of the "bcmb_type" field. BcmbType int `json:"bcmb_type,omitempty"` // Level holds the value of the "level" field. Level int `json:"level,omitempty"` - // Status holds the value of the "status" field. - Status int `json:"status,omitempty"` // Source holds the value of the "source" field. - Source int `json:"source,omitempty"` + Source int `json:"source,omitempty"` + // LastTime holds the value of the "last_time" field. + LastTime time.Time `json:"last_time,omitempty"` + // Status holds the value of the "status" field. + Status int `json:"status,omitempty"` selectValues sql.SelectValues } @@ -54,14 +55,12 @@ func (*Member) scanValues(columns []string) ([]any, error) { values := make([]any, len(columns)) for i := range columns { switch columns[i] { - case member.FieldBcmbType, member.FieldLevel, member.FieldStatus, member.FieldSource: + case member.FieldID, member.FieldBcmbType, member.FieldLevel, member.FieldSource, member.FieldStatus: values[i] = new(sql.NullInt64) - case member.FieldCode, member.FieldPhone, member.FieldNickname, member.FieldWxOpenID, member.FieldWxUID, member.FieldBcmbCode, member.FieldBcmbWxMsgID: + case member.FieldCode, member.FieldPhone, member.FieldNickname, member.FieldWxOpenID, member.FieldWxUID, member.FieldBcmbCode, member.FieldBcmbRegMsgID: values[i] = new(sql.NullString) - case member.FieldCreateTime, member.FieldUpdateTime, member.FieldBcmbRegTime: + case member.FieldCreateTime, member.FieldUpdateTime, member.FieldBcmbRegTime, member.FieldLastTime: values[i] = new(sql.NullTime) - case member.FieldID: - values[i] = new(uuid.UUID) default: values[i] = new(sql.UnknownType) } @@ -78,11 +77,11 @@ func (m *Member) assignValues(columns []string, values []any) error { for i := range columns { switch columns[i] { case member.FieldID: - if value, ok := values[i].(*uuid.UUID); !ok { - return fmt.Errorf("unexpected type %T for field id", values[i]) - } else if value != nil { - m.ID = *value + value, ok := values[i].(*sql.NullInt64) + if !ok { + return fmt.Errorf("unexpected type %T for field id", value) } + m.ID = int(value.Int64) case member.FieldCreateTime: if value, ok := values[i].(*sql.NullTime); !ok { return fmt.Errorf("unexpected type %T for field create_time", values[i]) @@ -138,11 +137,11 @@ func (m *Member) assignValues(columns []string, values []any) error { m.BcmbRegTime = new(time.Time) *m.BcmbRegTime = value.Time } - case member.FieldBcmbWxMsgID: + case member.FieldBcmbRegMsgID: if value, ok := values[i].(*sql.NullString); !ok { - return fmt.Errorf("unexpected type %T for field bcmb_wx_msg_id", values[i]) + return fmt.Errorf("unexpected type %T for field bcmb_reg_msg_id", values[i]) } else if value.Valid { - m.BcmbWxMsgID = value.String + m.BcmbRegMsgID = value.String } case member.FieldBcmbType: if value, ok := values[i].(*sql.NullInt64); !ok { @@ -156,18 +155,24 @@ func (m *Member) assignValues(columns []string, values []any) error { } else if value.Valid { m.Level = int(value.Int64) } - case member.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 = int(value.Int64) - } case member.FieldSource: if value, ok := values[i].(*sql.NullInt64); !ok { return fmt.Errorf("unexpected type %T for field source", values[i]) } else if value.Valid { m.Source = int(value.Int64) } + case member.FieldLastTime: + if value, ok := values[i].(*sql.NullTime); !ok { + return fmt.Errorf("unexpected type %T for field last_time", values[i]) + } else if value.Valid { + m.LastTime = value.Time + } + case member.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 = int(value.Int64) + } default: m.selectValues.Set(columns[i], values[i]) } @@ -233,8 +238,8 @@ func (m *Member) String() string { builder.WriteString(v.Format(time.ANSIC)) } builder.WriteString(", ") - builder.WriteString("bcmb_wx_msg_id=") - builder.WriteString(m.BcmbWxMsgID) + builder.WriteString("bcmb_reg_msg_id=") + builder.WriteString(m.BcmbRegMsgID) builder.WriteString(", ") builder.WriteString("bcmb_type=") builder.WriteString(fmt.Sprintf("%v", m.BcmbType)) @@ -242,11 +247,14 @@ func (m *Member) String() string { builder.WriteString("level=") builder.WriteString(fmt.Sprintf("%v", m.Level)) builder.WriteString(", ") - builder.WriteString("status=") - builder.WriteString(fmt.Sprintf("%v", m.Status)) - builder.WriteString(", ") builder.WriteString("source=") builder.WriteString(fmt.Sprintf("%v", m.Source)) + builder.WriteString(", ") + builder.WriteString("last_time=") + builder.WriteString(m.LastTime.Format(time.ANSIC)) + builder.WriteString(", ") + builder.WriteString("status=") + builder.WriteString(fmt.Sprintf("%v", m.Status)) builder.WriteByte(')') return builder.String() } diff --git a/member/orm/ent/member/member.go b/member/orm/ent/member/member.go index 30b0e83..fbd57c1 100644 --- a/member/orm/ent/member/member.go +++ b/member/orm/ent/member/member.go @@ -6,7 +6,6 @@ import ( "time" "entgo.io/ent/dialect/sql" - "github.com/google/uuid" ) const ( @@ -32,16 +31,18 @@ const ( FieldBcmbCode = "bcmb_code" // FieldBcmbRegTime holds the string denoting the bcmb_reg_time field in the database. FieldBcmbRegTime = "bcmb_reg_time" - // FieldBcmbWxMsgID holds the string denoting the bcmb_wx_msg_id field in the database. - FieldBcmbWxMsgID = "bcmb_wx_msg_id" + // FieldBcmbRegMsgID holds the string denoting the bcmb_reg_msg_id field in the database. + FieldBcmbRegMsgID = "bcmb_reg_msg_id" // FieldBcmbType holds the string denoting the bcmb_type field in the database. FieldBcmbType = "bcmb_type" // FieldLevel holds the string denoting the level field in the database. FieldLevel = "level" - // FieldStatus holds the string denoting the status field in the database. - FieldStatus = "status" // FieldSource holds the string denoting the source field in the database. FieldSource = "source" + // FieldLastTime holds the string denoting the last_time field in the database. + FieldLastTime = "last_time" + // FieldStatus holds the string denoting the status field in the database. + FieldStatus = "status" // Table holds the table name of the member in the database. Table = "t_member" ) @@ -58,11 +59,12 @@ var Columns = []string{ FieldWxUID, FieldBcmbCode, FieldBcmbRegTime, - FieldBcmbWxMsgID, + FieldBcmbRegMsgID, FieldBcmbType, FieldLevel, - FieldStatus, FieldSource, + FieldLastTime, + FieldStatus, } // ValidColumn reports if the column name is valid (part of the table columns). @@ -96,18 +98,18 @@ var ( WxUIDValidator func(string) error // BcmbCodeValidator is a validator for the "bcmb_code" field. It is called by the builders before save. BcmbCodeValidator func(string) error - // BcmbWxMsgIDValidator is a validator for the "bcmb_wx_msg_id" field. It is called by the builders before save. - BcmbWxMsgIDValidator func(string) error + // BcmbRegMsgIDValidator is a validator for the "bcmb_reg_msg_id" field. It is called by the builders before save. + BcmbRegMsgIDValidator func(string) error // DefaultBcmbType holds the default value on creation for the "bcmb_type" field. DefaultBcmbType int // DefaultLevel holds the default value on creation for the "level" field. DefaultLevel int - // DefaultStatus holds the default value on creation for the "status" field. - DefaultStatus int // DefaultSource holds the default value on creation for the "source" field. DefaultSource int - // DefaultID holds the default value on creation for the "id" field. - DefaultID func() uuid.UUID + // DefaultLastTime holds the default value on creation for the "last_time" field. + DefaultLastTime func() time.Time + // DefaultStatus holds the default value on creation for the "status" field. + DefaultStatus int ) // OrderOption defines the ordering options for the Member queries. @@ -163,9 +165,9 @@ func ByBcmbRegTime(opts ...sql.OrderTermOption) OrderOption { return sql.OrderByField(FieldBcmbRegTime, opts...).ToFunc() } -// ByBcmbWxMsgID orders the results by the bcmb_wx_msg_id field. -func ByBcmbWxMsgID(opts ...sql.OrderTermOption) OrderOption { - return sql.OrderByField(FieldBcmbWxMsgID, opts...).ToFunc() +// ByBcmbRegMsgID orders the results by the bcmb_reg_msg_id field. +func ByBcmbRegMsgID(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldBcmbRegMsgID, opts...).ToFunc() } // ByBcmbType orders the results by the bcmb_type field. @@ -178,12 +180,17 @@ func ByLevel(opts ...sql.OrderTermOption) OrderOption { return sql.OrderByField(FieldLevel, opts...).ToFunc() } -// ByStatus orders the results by the status field. -func ByStatus(opts ...sql.OrderTermOption) OrderOption { - return sql.OrderByField(FieldStatus, opts...).ToFunc() -} - // BySource orders the results by the source field. func BySource(opts ...sql.OrderTermOption) OrderOption { return sql.OrderByField(FieldSource, opts...).ToFunc() } + +// ByLastTime orders the results by the last_time field. +func ByLastTime(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldLastTime, opts...).ToFunc() +} + +// ByStatus orders the results by the status field. +func ByStatus(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldStatus, opts...).ToFunc() +} diff --git a/member/orm/ent/member/where.go b/member/orm/ent/member/where.go index 73bb96b..209d8fb 100644 --- a/member/orm/ent/member/where.go +++ b/member/orm/ent/member/where.go @@ -6,52 +6,51 @@ import ( "time" "entgo.io/ent/dialect/sql" - "github.com/google/uuid" "github.com/twiglab/crm/member/orm/ent/predicate" ) // ID filters vertices based on their ID field. -func ID(id uuid.UUID) predicate.Member { +func ID(id int) predicate.Member { return predicate.Member(sql.FieldEQ(FieldID, id)) } // IDEQ applies the EQ predicate on the ID field. -func IDEQ(id uuid.UUID) predicate.Member { +func IDEQ(id int) predicate.Member { return predicate.Member(sql.FieldEQ(FieldID, id)) } // IDNEQ applies the NEQ predicate on the ID field. -func IDNEQ(id uuid.UUID) predicate.Member { +func IDNEQ(id int) predicate.Member { return predicate.Member(sql.FieldNEQ(FieldID, id)) } // IDIn applies the In predicate on the ID field. -func IDIn(ids ...uuid.UUID) predicate.Member { +func IDIn(ids ...int) predicate.Member { return predicate.Member(sql.FieldIn(FieldID, ids...)) } // IDNotIn applies the NotIn predicate on the ID field. -func IDNotIn(ids ...uuid.UUID) predicate.Member { +func IDNotIn(ids ...int) predicate.Member { return predicate.Member(sql.FieldNotIn(FieldID, ids...)) } // IDGT applies the GT predicate on the ID field. -func IDGT(id uuid.UUID) predicate.Member { +func IDGT(id int) predicate.Member { return predicate.Member(sql.FieldGT(FieldID, id)) } // IDGTE applies the GTE predicate on the ID field. -func IDGTE(id uuid.UUID) predicate.Member { +func IDGTE(id int) predicate.Member { return predicate.Member(sql.FieldGTE(FieldID, id)) } // IDLT applies the LT predicate on the ID field. -func IDLT(id uuid.UUID) predicate.Member { +func IDLT(id int) predicate.Member { return predicate.Member(sql.FieldLT(FieldID, id)) } // IDLTE applies the LTE predicate on the ID field. -func IDLTE(id uuid.UUID) predicate.Member { +func IDLTE(id int) predicate.Member { return predicate.Member(sql.FieldLTE(FieldID, id)) } @@ -100,9 +99,9 @@ func BcmbRegTime(v time.Time) predicate.Member { return predicate.Member(sql.FieldEQ(FieldBcmbRegTime, v)) } -// BcmbWxMsgID applies equality check predicate on the "bcmb_wx_msg_id" field. It's identical to BcmbWxMsgIDEQ. -func BcmbWxMsgID(v string) predicate.Member { - return predicate.Member(sql.FieldEQ(FieldBcmbWxMsgID, v)) +// BcmbRegMsgID applies equality check predicate on the "bcmb_reg_msg_id" field. It's identical to BcmbRegMsgIDEQ. +func BcmbRegMsgID(v string) predicate.Member { + return predicate.Member(sql.FieldEQ(FieldBcmbRegMsgID, v)) } // BcmbType applies equality check predicate on the "bcmb_type" field. It's identical to BcmbTypeEQ. @@ -115,16 +114,21 @@ func Level(v int) predicate.Member { return predicate.Member(sql.FieldEQ(FieldLevel, v)) } -// Status applies equality check predicate on the "status" field. It's identical to StatusEQ. -func Status(v int) predicate.Member { - return predicate.Member(sql.FieldEQ(FieldStatus, v)) -} - // Source applies equality check predicate on the "source" field. It's identical to SourceEQ. func Source(v int) predicate.Member { return predicate.Member(sql.FieldEQ(FieldSource, v)) } +// LastTime applies equality check predicate on the "last_time" field. It's identical to LastTimeEQ. +func LastTime(v time.Time) predicate.Member { + return predicate.Member(sql.FieldEQ(FieldLastTime, v)) +} + +// Status applies equality check predicate on the "status" field. It's identical to StatusEQ. +func Status(v int) predicate.Member { + return predicate.Member(sql.FieldEQ(FieldStatus, v)) +} + // CreateTimeEQ applies the EQ predicate on the "create_time" field. func CreateTimeEQ(v time.Time) predicate.Member { return predicate.Member(sql.FieldEQ(FieldCreateTime, v)) @@ -675,79 +679,79 @@ func BcmbRegTimeNotNil() predicate.Member { return predicate.Member(sql.FieldNotNull(FieldBcmbRegTime)) } -// BcmbWxMsgIDEQ applies the EQ predicate on the "bcmb_wx_msg_id" field. -func BcmbWxMsgIDEQ(v string) predicate.Member { - return predicate.Member(sql.FieldEQ(FieldBcmbWxMsgID, v)) +// BcmbRegMsgIDEQ applies the EQ predicate on the "bcmb_reg_msg_id" field. +func BcmbRegMsgIDEQ(v string) predicate.Member { + return predicate.Member(sql.FieldEQ(FieldBcmbRegMsgID, v)) } -// BcmbWxMsgIDNEQ applies the NEQ predicate on the "bcmb_wx_msg_id" field. -func BcmbWxMsgIDNEQ(v string) predicate.Member { - return predicate.Member(sql.FieldNEQ(FieldBcmbWxMsgID, v)) +// BcmbRegMsgIDNEQ applies the NEQ predicate on the "bcmb_reg_msg_id" field. +func BcmbRegMsgIDNEQ(v string) predicate.Member { + return predicate.Member(sql.FieldNEQ(FieldBcmbRegMsgID, v)) } -// BcmbWxMsgIDIn applies the In predicate on the "bcmb_wx_msg_id" field. -func BcmbWxMsgIDIn(vs ...string) predicate.Member { - return predicate.Member(sql.FieldIn(FieldBcmbWxMsgID, vs...)) +// BcmbRegMsgIDIn applies the In predicate on the "bcmb_reg_msg_id" field. +func BcmbRegMsgIDIn(vs ...string) predicate.Member { + return predicate.Member(sql.FieldIn(FieldBcmbRegMsgID, vs...)) } -// BcmbWxMsgIDNotIn applies the NotIn predicate on the "bcmb_wx_msg_id" field. -func BcmbWxMsgIDNotIn(vs ...string) predicate.Member { - return predicate.Member(sql.FieldNotIn(FieldBcmbWxMsgID, vs...)) +// BcmbRegMsgIDNotIn applies the NotIn predicate on the "bcmb_reg_msg_id" field. +func BcmbRegMsgIDNotIn(vs ...string) predicate.Member { + return predicate.Member(sql.FieldNotIn(FieldBcmbRegMsgID, vs...)) } -// BcmbWxMsgIDGT applies the GT predicate on the "bcmb_wx_msg_id" field. -func BcmbWxMsgIDGT(v string) predicate.Member { - return predicate.Member(sql.FieldGT(FieldBcmbWxMsgID, v)) +// BcmbRegMsgIDGT applies the GT predicate on the "bcmb_reg_msg_id" field. +func BcmbRegMsgIDGT(v string) predicate.Member { + return predicate.Member(sql.FieldGT(FieldBcmbRegMsgID, v)) } -// BcmbWxMsgIDGTE applies the GTE predicate on the "bcmb_wx_msg_id" field. -func BcmbWxMsgIDGTE(v string) predicate.Member { - return predicate.Member(sql.FieldGTE(FieldBcmbWxMsgID, v)) +// BcmbRegMsgIDGTE applies the GTE predicate on the "bcmb_reg_msg_id" field. +func BcmbRegMsgIDGTE(v string) predicate.Member { + return predicate.Member(sql.FieldGTE(FieldBcmbRegMsgID, v)) } -// BcmbWxMsgIDLT applies the LT predicate on the "bcmb_wx_msg_id" field. -func BcmbWxMsgIDLT(v string) predicate.Member { - return predicate.Member(sql.FieldLT(FieldBcmbWxMsgID, v)) +// BcmbRegMsgIDLT applies the LT predicate on the "bcmb_reg_msg_id" field. +func BcmbRegMsgIDLT(v string) predicate.Member { + return predicate.Member(sql.FieldLT(FieldBcmbRegMsgID, v)) } -// BcmbWxMsgIDLTE applies the LTE predicate on the "bcmb_wx_msg_id" field. -func BcmbWxMsgIDLTE(v string) predicate.Member { - return predicate.Member(sql.FieldLTE(FieldBcmbWxMsgID, v)) +// BcmbRegMsgIDLTE applies the LTE predicate on the "bcmb_reg_msg_id" field. +func BcmbRegMsgIDLTE(v string) predicate.Member { + return predicate.Member(sql.FieldLTE(FieldBcmbRegMsgID, v)) } -// BcmbWxMsgIDContains applies the Contains predicate on the "bcmb_wx_msg_id" field. -func BcmbWxMsgIDContains(v string) predicate.Member { - return predicate.Member(sql.FieldContains(FieldBcmbWxMsgID, v)) +// BcmbRegMsgIDContains applies the Contains predicate on the "bcmb_reg_msg_id" field. +func BcmbRegMsgIDContains(v string) predicate.Member { + return predicate.Member(sql.FieldContains(FieldBcmbRegMsgID, v)) } -// BcmbWxMsgIDHasPrefix applies the HasPrefix predicate on the "bcmb_wx_msg_id" field. -func BcmbWxMsgIDHasPrefix(v string) predicate.Member { - return predicate.Member(sql.FieldHasPrefix(FieldBcmbWxMsgID, v)) +// BcmbRegMsgIDHasPrefix applies the HasPrefix predicate on the "bcmb_reg_msg_id" field. +func BcmbRegMsgIDHasPrefix(v string) predicate.Member { + return predicate.Member(sql.FieldHasPrefix(FieldBcmbRegMsgID, v)) } -// BcmbWxMsgIDHasSuffix applies the HasSuffix predicate on the "bcmb_wx_msg_id" field. -func BcmbWxMsgIDHasSuffix(v string) predicate.Member { - return predicate.Member(sql.FieldHasSuffix(FieldBcmbWxMsgID, v)) +// BcmbRegMsgIDHasSuffix applies the HasSuffix predicate on the "bcmb_reg_msg_id" field. +func BcmbRegMsgIDHasSuffix(v string) predicate.Member { + return predicate.Member(sql.FieldHasSuffix(FieldBcmbRegMsgID, v)) } -// BcmbWxMsgIDIsNil applies the IsNil predicate on the "bcmb_wx_msg_id" field. -func BcmbWxMsgIDIsNil() predicate.Member { - return predicate.Member(sql.FieldIsNull(FieldBcmbWxMsgID)) +// BcmbRegMsgIDIsNil applies the IsNil predicate on the "bcmb_reg_msg_id" field. +func BcmbRegMsgIDIsNil() predicate.Member { + return predicate.Member(sql.FieldIsNull(FieldBcmbRegMsgID)) } -// BcmbWxMsgIDNotNil applies the NotNil predicate on the "bcmb_wx_msg_id" field. -func BcmbWxMsgIDNotNil() predicate.Member { - return predicate.Member(sql.FieldNotNull(FieldBcmbWxMsgID)) +// BcmbRegMsgIDNotNil applies the NotNil predicate on the "bcmb_reg_msg_id" field. +func BcmbRegMsgIDNotNil() predicate.Member { + return predicate.Member(sql.FieldNotNull(FieldBcmbRegMsgID)) } -// BcmbWxMsgIDEqualFold applies the EqualFold predicate on the "bcmb_wx_msg_id" field. -func BcmbWxMsgIDEqualFold(v string) predicate.Member { - return predicate.Member(sql.FieldEqualFold(FieldBcmbWxMsgID, v)) +// BcmbRegMsgIDEqualFold applies the EqualFold predicate on the "bcmb_reg_msg_id" field. +func BcmbRegMsgIDEqualFold(v string) predicate.Member { + return predicate.Member(sql.FieldEqualFold(FieldBcmbRegMsgID, v)) } -// BcmbWxMsgIDContainsFold applies the ContainsFold predicate on the "bcmb_wx_msg_id" field. -func BcmbWxMsgIDContainsFold(v string) predicate.Member { - return predicate.Member(sql.FieldContainsFold(FieldBcmbWxMsgID, v)) +// BcmbRegMsgIDContainsFold applies the ContainsFold predicate on the "bcmb_reg_msg_id" field. +func BcmbRegMsgIDContainsFold(v string) predicate.Member { + return predicate.Member(sql.FieldContainsFold(FieldBcmbRegMsgID, v)) } // BcmbTypeEQ applies the EQ predicate on the "bcmb_type" field. @@ -830,46 +834,6 @@ func LevelLTE(v int) predicate.Member { return predicate.Member(sql.FieldLTE(FieldLevel, v)) } -// StatusEQ applies the EQ predicate on the "status" field. -func StatusEQ(v int) predicate.Member { - return predicate.Member(sql.FieldEQ(FieldStatus, v)) -} - -// StatusNEQ applies the NEQ predicate on the "status" field. -func StatusNEQ(v int) predicate.Member { - return predicate.Member(sql.FieldNEQ(FieldStatus, v)) -} - -// StatusIn applies the In predicate on the "status" field. -func StatusIn(vs ...int) predicate.Member { - return predicate.Member(sql.FieldIn(FieldStatus, vs...)) -} - -// StatusNotIn applies the NotIn predicate on the "status" field. -func StatusNotIn(vs ...int) predicate.Member { - return predicate.Member(sql.FieldNotIn(FieldStatus, vs...)) -} - -// StatusGT applies the GT predicate on the "status" field. -func StatusGT(v int) predicate.Member { - return predicate.Member(sql.FieldGT(FieldStatus, v)) -} - -// StatusGTE applies the GTE predicate on the "status" field. -func StatusGTE(v int) predicate.Member { - return predicate.Member(sql.FieldGTE(FieldStatus, v)) -} - -// StatusLT applies the LT predicate on the "status" field. -func StatusLT(v int) predicate.Member { - return predicate.Member(sql.FieldLT(FieldStatus, v)) -} - -// StatusLTE applies the LTE predicate on the "status" field. -func StatusLTE(v int) predicate.Member { - return predicate.Member(sql.FieldLTE(FieldStatus, v)) -} - // SourceEQ applies the EQ predicate on the "source" field. func SourceEQ(v int) predicate.Member { return predicate.Member(sql.FieldEQ(FieldSource, v)) @@ -910,6 +874,86 @@ func SourceLTE(v int) predicate.Member { return predicate.Member(sql.FieldLTE(FieldSource, v)) } +// LastTimeEQ applies the EQ predicate on the "last_time" field. +func LastTimeEQ(v time.Time) predicate.Member { + return predicate.Member(sql.FieldEQ(FieldLastTime, v)) +} + +// LastTimeNEQ applies the NEQ predicate on the "last_time" field. +func LastTimeNEQ(v time.Time) predicate.Member { + return predicate.Member(sql.FieldNEQ(FieldLastTime, v)) +} + +// LastTimeIn applies the In predicate on the "last_time" field. +func LastTimeIn(vs ...time.Time) predicate.Member { + return predicate.Member(sql.FieldIn(FieldLastTime, vs...)) +} + +// LastTimeNotIn applies the NotIn predicate on the "last_time" field. +func LastTimeNotIn(vs ...time.Time) predicate.Member { + return predicate.Member(sql.FieldNotIn(FieldLastTime, vs...)) +} + +// LastTimeGT applies the GT predicate on the "last_time" field. +func LastTimeGT(v time.Time) predicate.Member { + return predicate.Member(sql.FieldGT(FieldLastTime, v)) +} + +// LastTimeGTE applies the GTE predicate on the "last_time" field. +func LastTimeGTE(v time.Time) predicate.Member { + return predicate.Member(sql.FieldGTE(FieldLastTime, v)) +} + +// LastTimeLT applies the LT predicate on the "last_time" field. +func LastTimeLT(v time.Time) predicate.Member { + return predicate.Member(sql.FieldLT(FieldLastTime, v)) +} + +// LastTimeLTE applies the LTE predicate on the "last_time" field. +func LastTimeLTE(v time.Time) predicate.Member { + return predicate.Member(sql.FieldLTE(FieldLastTime, v)) +} + +// StatusEQ applies the EQ predicate on the "status" field. +func StatusEQ(v int) predicate.Member { + return predicate.Member(sql.FieldEQ(FieldStatus, v)) +} + +// StatusNEQ applies the NEQ predicate on the "status" field. +func StatusNEQ(v int) predicate.Member { + return predicate.Member(sql.FieldNEQ(FieldStatus, v)) +} + +// StatusIn applies the In predicate on the "status" field. +func StatusIn(vs ...int) predicate.Member { + return predicate.Member(sql.FieldIn(FieldStatus, vs...)) +} + +// StatusNotIn applies the NotIn predicate on the "status" field. +func StatusNotIn(vs ...int) predicate.Member { + return predicate.Member(sql.FieldNotIn(FieldStatus, vs...)) +} + +// StatusGT applies the GT predicate on the "status" field. +func StatusGT(v int) predicate.Member { + return predicate.Member(sql.FieldGT(FieldStatus, v)) +} + +// StatusGTE applies the GTE predicate on the "status" field. +func StatusGTE(v int) predicate.Member { + return predicate.Member(sql.FieldGTE(FieldStatus, v)) +} + +// StatusLT applies the LT predicate on the "status" field. +func StatusLT(v int) predicate.Member { + return predicate.Member(sql.FieldLT(FieldStatus, v)) +} + +// StatusLTE applies the LTE predicate on the "status" field. +func StatusLTE(v int) predicate.Member { + return predicate.Member(sql.FieldLTE(FieldStatus, v)) +} + // And groups predicates with the AND operator between them. func And(predicates ...predicate.Member) predicate.Member { return predicate.Member(sql.AndPredicates(predicates...)) diff --git a/member/orm/ent/member_create.go b/member/orm/ent/member_create.go index 3f0d26b..008c807 100644 --- a/member/orm/ent/member_create.go +++ b/member/orm/ent/member_create.go @@ -8,11 +8,9 @@ import ( "fmt" "time" - "entgo.io/ent/dialect" "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/sqlgraph" "entgo.io/ent/schema/field" - "github.com/google/uuid" "github.com/twiglab/crm/member/orm/ent/member" ) @@ -134,16 +132,16 @@ func (mc *MemberCreate) SetNillableBcmbRegTime(t *time.Time) *MemberCreate { return mc } -// SetBcmbWxMsgID sets the "bcmb_wx_msg_id" field. -func (mc *MemberCreate) SetBcmbWxMsgID(s string) *MemberCreate { - mc.mutation.SetBcmbWxMsgID(s) +// SetBcmbRegMsgID sets the "bcmb_reg_msg_id" field. +func (mc *MemberCreate) SetBcmbRegMsgID(s string) *MemberCreate { + mc.mutation.SetBcmbRegMsgID(s) return mc } -// SetNillableBcmbWxMsgID sets the "bcmb_wx_msg_id" field if the given value is not nil. -func (mc *MemberCreate) SetNillableBcmbWxMsgID(s *string) *MemberCreate { +// SetNillableBcmbRegMsgID sets the "bcmb_reg_msg_id" field if the given value is not nil. +func (mc *MemberCreate) SetNillableBcmbRegMsgID(s *string) *MemberCreate { if s != nil { - mc.SetBcmbWxMsgID(*s) + mc.SetBcmbRegMsgID(*s) } return mc } @@ -176,44 +174,44 @@ func (mc *MemberCreate) SetNillableLevel(i *int) *MemberCreate { return mc } -// SetStatus sets the "status" field. -func (mc *MemberCreate) SetStatus(i int) *MemberCreate { - mc.mutation.SetStatus(i) +// SetSource sets the "source" field. +func (mc *MemberCreate) SetSource(i int) *MemberCreate { + mc.mutation.SetSource(i) return mc } -// SetNillableStatus sets the "status" field if the given value is not nil. -func (mc *MemberCreate) SetNillableStatus(i *int) *MemberCreate { +// SetNillableSource sets the "source" field if the given value is not nil. +func (mc *MemberCreate) SetNillableSource(i *int) *MemberCreate { if i != nil { - mc.SetStatus(*i) + mc.SetSource(*i) } return mc } -// SetSource sets the "source" field. -func (mc *MemberCreate) SetSource(i int) *MemberCreate { - mc.mutation.SetSource(i) +// SetLastTime sets the "last_time" field. +func (mc *MemberCreate) SetLastTime(t time.Time) *MemberCreate { + mc.mutation.SetLastTime(t) return mc } -// SetNillableSource sets the "source" field if the given value is not nil. -func (mc *MemberCreate) SetNillableSource(i *int) *MemberCreate { - if i != nil { - mc.SetSource(*i) +// SetNillableLastTime sets the "last_time" field if the given value is not nil. +func (mc *MemberCreate) SetNillableLastTime(t *time.Time) *MemberCreate { + if t != nil { + mc.SetLastTime(*t) } return mc } -// SetID sets the "id" field. -func (mc *MemberCreate) SetID(u uuid.UUID) *MemberCreate { - mc.mutation.SetID(u) +// SetStatus sets the "status" field. +func (mc *MemberCreate) SetStatus(i int) *MemberCreate { + mc.mutation.SetStatus(i) return mc } -// SetNillableID sets the "id" field if the given value is not nil. -func (mc *MemberCreate) SetNillableID(u *uuid.UUID) *MemberCreate { - if u != nil { - mc.SetID(*u) +// SetNillableStatus sets the "status" field if the given value is not nil. +func (mc *MemberCreate) SetNillableStatus(i *int) *MemberCreate { + if i != nil { + mc.SetStatus(*i) } return mc } @@ -273,17 +271,17 @@ func (mc *MemberCreate) defaults() { v := member.DefaultLevel mc.mutation.SetLevel(v) } - if _, ok := mc.mutation.Status(); !ok { - v := member.DefaultStatus - mc.mutation.SetStatus(v) - } if _, ok := mc.mutation.Source(); !ok { v := member.DefaultSource mc.mutation.SetSource(v) } - if _, ok := mc.mutation.ID(); !ok { - v := member.DefaultID() - mc.mutation.SetID(v) + if _, ok := mc.mutation.LastTime(); !ok { + v := member.DefaultLastTime() + mc.mutation.SetLastTime(v) + } + if _, ok := mc.mutation.Status(); !ok { + v := member.DefaultStatus + mc.mutation.SetStatus(v) } } @@ -334,9 +332,9 @@ func (mc *MemberCreate) check() error { return &ValidationError{Name: "bcmb_code", err: fmt.Errorf(`ent: validator failed for field "Member.bcmb_code": %w`, err)} } } - if v, ok := mc.mutation.BcmbWxMsgID(); ok { - if err := member.BcmbWxMsgIDValidator(v); err != nil { - return &ValidationError{Name: "bcmb_wx_msg_id", err: fmt.Errorf(`ent: validator failed for field "Member.bcmb_wx_msg_id": %w`, err)} + if v, ok := mc.mutation.BcmbRegMsgID(); ok { + if err := member.BcmbRegMsgIDValidator(v); err != nil { + return &ValidationError{Name: "bcmb_reg_msg_id", err: fmt.Errorf(`ent: validator failed for field "Member.bcmb_reg_msg_id": %w`, err)} } } if _, ok := mc.mutation.BcmbType(); !ok { @@ -345,12 +343,15 @@ func (mc *MemberCreate) check() error { if _, ok := mc.mutation.Level(); !ok { return &ValidationError{Name: "level", err: errors.New(`ent: missing required field "Member.level"`)} } - if _, ok := mc.mutation.Status(); !ok { - return &ValidationError{Name: "status", err: errors.New(`ent: missing required field "Member.status"`)} - } if _, ok := mc.mutation.Source(); !ok { return &ValidationError{Name: "source", err: errors.New(`ent: missing required field "Member.source"`)} } + if _, ok := mc.mutation.LastTime(); !ok { + return &ValidationError{Name: "last_time", err: errors.New(`ent: missing required field "Member.last_time"`)} + } + if _, ok := mc.mutation.Status(); !ok { + return &ValidationError{Name: "status", err: errors.New(`ent: missing required field "Member.status"`)} + } return nil } @@ -365,13 +366,8 @@ func (mc *MemberCreate) sqlSave(ctx context.Context) (*Member, error) { } return nil, err } - if _spec.ID.Value != nil { - if id, ok := _spec.ID.Value.(*uuid.UUID); ok { - _node.ID = *id - } else if err := _node.ID.Scan(_spec.ID.Value); err != nil { - return nil, err - } - } + id := _spec.ID.Value.(int64) + _node.ID = int(id) mc.mutation.id = &_node.ID mc.mutation.done = true return _node, nil @@ -380,13 +376,9 @@ func (mc *MemberCreate) sqlSave(ctx context.Context) (*Member, error) { func (mc *MemberCreate) createSpec() (*Member, *sqlgraph.CreateSpec) { var ( _node = &Member{config: mc.config} - _spec = sqlgraph.NewCreateSpec(member.Table, sqlgraph.NewFieldSpec(member.FieldID, field.TypeUUID)) + _spec = sqlgraph.NewCreateSpec(member.Table, sqlgraph.NewFieldSpec(member.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.CreateTime(); ok { _spec.SetField(member.FieldCreateTime, field.TypeTime, value) _node.CreateTime = value @@ -423,9 +415,9 @@ func (mc *MemberCreate) createSpec() (*Member, *sqlgraph.CreateSpec) { _spec.SetField(member.FieldBcmbRegTime, field.TypeTime, value) _node.BcmbRegTime = &value } - if value, ok := mc.mutation.BcmbWxMsgID(); ok { - _spec.SetField(member.FieldBcmbWxMsgID, field.TypeString, value) - _node.BcmbWxMsgID = value + if value, ok := mc.mutation.BcmbRegMsgID(); ok { + _spec.SetField(member.FieldBcmbRegMsgID, field.TypeString, value) + _node.BcmbRegMsgID = value } if value, ok := mc.mutation.BcmbType(); ok { _spec.SetField(member.FieldBcmbType, field.TypeInt, value) @@ -435,14 +427,18 @@ func (mc *MemberCreate) createSpec() (*Member, *sqlgraph.CreateSpec) { _spec.SetField(member.FieldLevel, field.TypeInt, value) _node.Level = value } - if value, ok := mc.mutation.Status(); ok { - _spec.SetField(member.FieldStatus, field.TypeInt, value) - _node.Status = value - } if value, ok := mc.mutation.Source(); ok { _spec.SetField(member.FieldSource, field.TypeInt, value) _node.Source = value } + if value, ok := mc.mutation.LastTime(); ok { + _spec.SetField(member.FieldLastTime, field.TypeTime, value) + _node.LastTime = value + } + if value, ok := mc.mutation.Status(); ok { + _spec.SetField(member.FieldStatus, field.TypeInt, value) + _node.Status = value + } return _node, _spec } @@ -585,21 +581,21 @@ func (u *MemberUpsert) ClearBcmbCode() *MemberUpsert { return u } -// SetBcmbWxMsgID sets the "bcmb_wx_msg_id" field. -func (u *MemberUpsert) SetBcmbWxMsgID(v string) *MemberUpsert { - u.Set(member.FieldBcmbWxMsgID, v) +// SetBcmbRegMsgID sets the "bcmb_reg_msg_id" field. +func (u *MemberUpsert) SetBcmbRegMsgID(v string) *MemberUpsert { + u.Set(member.FieldBcmbRegMsgID, v) return u } -// UpdateBcmbWxMsgID sets the "bcmb_wx_msg_id" field to the value that was provided on create. -func (u *MemberUpsert) UpdateBcmbWxMsgID() *MemberUpsert { - u.SetExcluded(member.FieldBcmbWxMsgID) +// UpdateBcmbRegMsgID sets the "bcmb_reg_msg_id" field to the value that was provided on create. +func (u *MemberUpsert) UpdateBcmbRegMsgID() *MemberUpsert { + u.SetExcluded(member.FieldBcmbRegMsgID) return u } -// ClearBcmbWxMsgID clears the value of the "bcmb_wx_msg_id" field. -func (u *MemberUpsert) ClearBcmbWxMsgID() *MemberUpsert { - u.SetNull(member.FieldBcmbWxMsgID) +// ClearBcmbRegMsgID clears the value of the "bcmb_reg_msg_id" field. +func (u *MemberUpsert) ClearBcmbRegMsgID() *MemberUpsert { + u.SetNull(member.FieldBcmbRegMsgID) return u } @@ -639,24 +635,6 @@ func (u *MemberUpsert) AddLevel(v int) *MemberUpsert { return u } -// SetStatus sets the "status" field. -func (u *MemberUpsert) SetStatus(v int) *MemberUpsert { - u.Set(member.FieldStatus, v) - return u -} - -// UpdateStatus sets the "status" field to the value that was provided on create. -func (u *MemberUpsert) UpdateStatus() *MemberUpsert { - u.SetExcluded(member.FieldStatus) - return u -} - -// AddStatus adds v to the "status" field. -func (u *MemberUpsert) AddStatus(v int) *MemberUpsert { - u.Add(member.FieldStatus, v) - return u -} - // SetSource sets the "source" field. func (u *MemberUpsert) SetSource(v int) *MemberUpsert { u.Set(member.FieldSource, v) @@ -675,23 +653,47 @@ func (u *MemberUpsert) AddSource(v int) *MemberUpsert { return u } -// UpdateNewValues updates the mutable fields using the new values that were set on create except the ID field. +// SetLastTime sets the "last_time" field. +func (u *MemberUpsert) SetLastTime(v time.Time) *MemberUpsert { + u.Set(member.FieldLastTime, v) + return u +} + +// UpdateLastTime sets the "last_time" field to the value that was provided on create. +func (u *MemberUpsert) UpdateLastTime() *MemberUpsert { + u.SetExcluded(member.FieldLastTime) + return u +} + +// SetStatus sets the "status" field. +func (u *MemberUpsert) SetStatus(v int) *MemberUpsert { + u.Set(member.FieldStatus, v) + return u +} + +// UpdateStatus sets the "status" field to the value that was provided on create. +func (u *MemberUpsert) UpdateStatus() *MemberUpsert { + u.SetExcluded(member.FieldStatus) + return u +} + +// AddStatus adds v to the "status" field. +func (u *MemberUpsert) AddStatus(v int) *MemberUpsert { + u.Add(member.FieldStatus, v) + return u +} + +// UpdateNewValues updates the mutable fields using the new values that were set on create. // Using this option is equivalent to using: // // client.Member.Create(). // OnConflict( // sql.ResolveWithNewValues(), -// sql.ResolveWith(func(u *sql.UpdateSet) { -// u.SetIgnore(member.FieldID) -// }), // ). // Exec(ctx) func (u *MemberUpsertOne) UpdateNewValues() *MemberUpsertOne { 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(member.FieldID) - } if _, exists := u.create.mutation.CreateTime(); exists { s.SetIgnore(member.FieldCreateTime) } @@ -837,24 +839,24 @@ func (u *MemberUpsertOne) ClearBcmbCode() *MemberUpsertOne { }) } -// SetBcmbWxMsgID sets the "bcmb_wx_msg_id" field. -func (u *MemberUpsertOne) SetBcmbWxMsgID(v string) *MemberUpsertOne { +// SetBcmbRegMsgID sets the "bcmb_reg_msg_id" field. +func (u *MemberUpsertOne) SetBcmbRegMsgID(v string) *MemberUpsertOne { return u.Update(func(s *MemberUpsert) { - s.SetBcmbWxMsgID(v) + s.SetBcmbRegMsgID(v) }) } -// UpdateBcmbWxMsgID sets the "bcmb_wx_msg_id" field to the value that was provided on create. -func (u *MemberUpsertOne) UpdateBcmbWxMsgID() *MemberUpsertOne { +// UpdateBcmbRegMsgID sets the "bcmb_reg_msg_id" field to the value that was provided on create. +func (u *MemberUpsertOne) UpdateBcmbRegMsgID() *MemberUpsertOne { return u.Update(func(s *MemberUpsert) { - s.UpdateBcmbWxMsgID() + s.UpdateBcmbRegMsgID() }) } -// ClearBcmbWxMsgID clears the value of the "bcmb_wx_msg_id" field. -func (u *MemberUpsertOne) ClearBcmbWxMsgID() *MemberUpsertOne { +// ClearBcmbRegMsgID clears the value of the "bcmb_reg_msg_id" field. +func (u *MemberUpsertOne) ClearBcmbRegMsgID() *MemberUpsertOne { return u.Update(func(s *MemberUpsert) { - s.ClearBcmbWxMsgID() + s.ClearBcmbRegMsgID() }) } @@ -900,45 +902,59 @@ func (u *MemberUpsertOne) UpdateLevel() *MemberUpsertOne { }) } -// SetStatus sets the "status" field. -func (u *MemberUpsertOne) SetStatus(v int) *MemberUpsertOne { +// SetSource sets the "source" field. +func (u *MemberUpsertOne) SetSource(v int) *MemberUpsertOne { return u.Update(func(s *MemberUpsert) { - s.SetStatus(v) + s.SetSource(v) }) } -// AddStatus adds v to the "status" field. -func (u *MemberUpsertOne) AddStatus(v int) *MemberUpsertOne { +// AddSource adds v to the "source" field. +func (u *MemberUpsertOne) AddSource(v int) *MemberUpsertOne { return u.Update(func(s *MemberUpsert) { - s.AddStatus(v) + s.AddSource(v) }) } -// UpdateStatus sets the "status" field to the value that was provided on create. -func (u *MemberUpsertOne) UpdateStatus() *MemberUpsertOne { +// UpdateSource sets the "source" field to the value that was provided on create. +func (u *MemberUpsertOne) UpdateSource() *MemberUpsertOne { return u.Update(func(s *MemberUpsert) { - s.UpdateStatus() + s.UpdateSource() }) } -// SetSource sets the "source" field. -func (u *MemberUpsertOne) SetSource(v int) *MemberUpsertOne { +// SetLastTime sets the "last_time" field. +func (u *MemberUpsertOne) SetLastTime(v time.Time) *MemberUpsertOne { return u.Update(func(s *MemberUpsert) { - s.SetSource(v) + s.SetLastTime(v) }) } -// AddSource adds v to the "source" field. -func (u *MemberUpsertOne) AddSource(v int) *MemberUpsertOne { +// UpdateLastTime sets the "last_time" field to the value that was provided on create. +func (u *MemberUpsertOne) UpdateLastTime() *MemberUpsertOne { return u.Update(func(s *MemberUpsert) { - s.AddSource(v) + s.UpdateLastTime() }) } -// UpdateSource sets the "source" field to the value that was provided on create. -func (u *MemberUpsertOne) UpdateSource() *MemberUpsertOne { +// SetStatus sets the "status" field. +func (u *MemberUpsertOne) SetStatus(v int) *MemberUpsertOne { return u.Update(func(s *MemberUpsert) { - s.UpdateSource() + s.SetStatus(v) + }) +} + +// AddStatus adds v to the "status" field. +func (u *MemberUpsertOne) AddStatus(v int) *MemberUpsertOne { + return u.Update(func(s *MemberUpsert) { + s.AddStatus(v) + }) +} + +// UpdateStatus sets the "status" field to the value that was provided on create. +func (u *MemberUpsertOne) UpdateStatus() *MemberUpsertOne { + return u.Update(func(s *MemberUpsert) { + s.UpdateStatus() }) } @@ -958,12 +974,7 @@ func (u *MemberUpsertOne) ExecX(ctx context.Context) { } // Exec executes the UPSERT query and returns the inserted/updated ID. -func (u *MemberUpsertOne) ID(ctx context.Context) (id uuid.UUID, err error) { - if u.create.driver.Dialect() == dialect.MySQL { - // In case of "ON CONFLICT", there is no way to get back non-numeric ID - // fields from the database since MySQL does not support the RETURNING clause. - return id, errors.New("ent: MemberUpsertOne.ID is not supported by MySQL driver. Use MemberUpsertOne.Exec instead") - } +func (u *MemberUpsertOne) ID(ctx context.Context) (id int, err error) { node, err := u.create.Save(ctx) if err != nil { return id, err @@ -972,7 +983,7 @@ func (u *MemberUpsertOne) ID(ctx context.Context) (id uuid.UUID, err error) { } // IDX is like ID, but panics if an error occurs. -func (u *MemberUpsertOne) IDX(ctx context.Context) uuid.UUID { +func (u *MemberUpsertOne) IDX(ctx context.Context) int { id, err := u.ID(ctx) if err != nil { panic(err) @@ -1027,6 +1038,10 @@ func (mcb *MemberCreateBulk) Save(ctx context.Context) ([]*Member, error) { return nil, err } mutation.id = &nodes[i].ID + if specs[i].ID.Value != nil { + id := specs[i].ID.Value.(int64) + nodes[i].ID = int(id) + } mutation.done = true return nodes[i], nil }) @@ -1113,18 +1128,12 @@ type MemberUpsertBulk struct { // client.Member.Create(). // OnConflict( // sql.ResolveWithNewValues(), -// sql.ResolveWith(func(u *sql.UpdateSet) { -// u.SetIgnore(member.FieldID) -// }), // ). // Exec(ctx) func (u *MemberUpsertBulk) UpdateNewValues() *MemberUpsertBulk { 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(member.FieldID) - } if _, exists := b.mutation.CreateTime(); exists { s.SetIgnore(member.FieldCreateTime) } @@ -1271,24 +1280,24 @@ func (u *MemberUpsertBulk) ClearBcmbCode() *MemberUpsertBulk { }) } -// SetBcmbWxMsgID sets the "bcmb_wx_msg_id" field. -func (u *MemberUpsertBulk) SetBcmbWxMsgID(v string) *MemberUpsertBulk { +// SetBcmbRegMsgID sets the "bcmb_reg_msg_id" field. +func (u *MemberUpsertBulk) SetBcmbRegMsgID(v string) *MemberUpsertBulk { return u.Update(func(s *MemberUpsert) { - s.SetBcmbWxMsgID(v) + s.SetBcmbRegMsgID(v) }) } -// UpdateBcmbWxMsgID sets the "bcmb_wx_msg_id" field to the value that was provided on create. -func (u *MemberUpsertBulk) UpdateBcmbWxMsgID() *MemberUpsertBulk { +// UpdateBcmbRegMsgID sets the "bcmb_reg_msg_id" field to the value that was provided on create. +func (u *MemberUpsertBulk) UpdateBcmbRegMsgID() *MemberUpsertBulk { return u.Update(func(s *MemberUpsert) { - s.UpdateBcmbWxMsgID() + s.UpdateBcmbRegMsgID() }) } -// ClearBcmbWxMsgID clears the value of the "bcmb_wx_msg_id" field. -func (u *MemberUpsertBulk) ClearBcmbWxMsgID() *MemberUpsertBulk { +// ClearBcmbRegMsgID clears the value of the "bcmb_reg_msg_id" field. +func (u *MemberUpsertBulk) ClearBcmbRegMsgID() *MemberUpsertBulk { return u.Update(func(s *MemberUpsert) { - s.ClearBcmbWxMsgID() + s.ClearBcmbRegMsgID() }) } @@ -1334,45 +1343,59 @@ func (u *MemberUpsertBulk) UpdateLevel() *MemberUpsertBulk { }) } -// SetStatus sets the "status" field. -func (u *MemberUpsertBulk) SetStatus(v int) *MemberUpsertBulk { +// SetSource sets the "source" field. +func (u *MemberUpsertBulk) SetSource(v int) *MemberUpsertBulk { return u.Update(func(s *MemberUpsert) { - s.SetStatus(v) + s.SetSource(v) }) } -// AddStatus adds v to the "status" field. -func (u *MemberUpsertBulk) AddStatus(v int) *MemberUpsertBulk { +// AddSource adds v to the "source" field. +func (u *MemberUpsertBulk) AddSource(v int) *MemberUpsertBulk { return u.Update(func(s *MemberUpsert) { - s.AddStatus(v) + s.AddSource(v) }) } -// UpdateStatus sets the "status" field to the value that was provided on create. -func (u *MemberUpsertBulk) UpdateStatus() *MemberUpsertBulk { +// UpdateSource sets the "source" field to the value that was provided on create. +func (u *MemberUpsertBulk) UpdateSource() *MemberUpsertBulk { return u.Update(func(s *MemberUpsert) { - s.UpdateStatus() + s.UpdateSource() }) } -// SetSource sets the "source" field. -func (u *MemberUpsertBulk) SetSource(v int) *MemberUpsertBulk { +// SetLastTime sets the "last_time" field. +func (u *MemberUpsertBulk) SetLastTime(v time.Time) *MemberUpsertBulk { return u.Update(func(s *MemberUpsert) { - s.SetSource(v) + s.SetLastTime(v) }) } -// AddSource adds v to the "source" field. -func (u *MemberUpsertBulk) AddSource(v int) *MemberUpsertBulk { +// UpdateLastTime sets the "last_time" field to the value that was provided on create. +func (u *MemberUpsertBulk) UpdateLastTime() *MemberUpsertBulk { return u.Update(func(s *MemberUpsert) { - s.AddSource(v) + s.UpdateLastTime() }) } -// UpdateSource sets the "source" field to the value that was provided on create. -func (u *MemberUpsertBulk) UpdateSource() *MemberUpsertBulk { +// SetStatus sets the "status" field. +func (u *MemberUpsertBulk) SetStatus(v int) *MemberUpsertBulk { return u.Update(func(s *MemberUpsert) { - s.UpdateSource() + s.SetStatus(v) + }) +} + +// AddStatus adds v to the "status" field. +func (u *MemberUpsertBulk) AddStatus(v int) *MemberUpsertBulk { + return u.Update(func(s *MemberUpsert) { + s.AddStatus(v) + }) +} + +// UpdateStatus sets the "status" field to the value that was provided on create. +func (u *MemberUpsertBulk) UpdateStatus() *MemberUpsertBulk { + return u.Update(func(s *MemberUpsert) { + s.UpdateStatus() }) } diff --git a/member/orm/ent/member_delete.go b/member/orm/ent/member_delete.go index 486d3a8..f75db8c 100644 --- a/member/orm/ent/member_delete.go +++ b/member/orm/ent/member_delete.go @@ -40,7 +40,7 @@ func (md *MemberDelete) ExecX(ctx context.Context) int { } func (md *MemberDelete) sqlExec(ctx context.Context) (int, error) { - _spec := sqlgraph.NewDeleteSpec(member.Table, sqlgraph.NewFieldSpec(member.FieldID, field.TypeUUID)) + _spec := sqlgraph.NewDeleteSpec(member.Table, sqlgraph.NewFieldSpec(member.FieldID, field.TypeInt)) if ps := md.mutation.predicates; len(ps) > 0 { _spec.Predicate = func(selector *sql.Selector) { for i := range ps { diff --git a/member/orm/ent/member_query.go b/member/orm/ent/member_query.go index b5d42dc..eafa89a 100644 --- a/member/orm/ent/member_query.go +++ b/member/orm/ent/member_query.go @@ -11,7 +11,6 @@ import ( "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/sqlgraph" "entgo.io/ent/schema/field" - "github.com/google/uuid" "github.com/twiglab/crm/member/orm/ent/member" "github.com/twiglab/crm/member/orm/ent/predicate" ) @@ -83,8 +82,8 @@ func (mq *MemberQuery) FirstX(ctx context.Context) *Member { // FirstID returns the first Member ID from the query. // Returns a *NotFoundError when no Member ID was found. -func (mq *MemberQuery) FirstID(ctx context.Context) (id uuid.UUID, err error) { - var ids []uuid.UUID +func (mq *MemberQuery) FirstID(ctx context.Context) (id int, err error) { + var ids []int if ids, err = mq.Limit(1).IDs(setContextOp(ctx, mq.ctx, ent.OpQueryFirstID)); err != nil { return } @@ -96,7 +95,7 @@ func (mq *MemberQuery) FirstID(ctx context.Context) (id uuid.UUID, err error) { } // FirstIDX is like FirstID, but panics if an error occurs. -func (mq *MemberQuery) FirstIDX(ctx context.Context) uuid.UUID { +func (mq *MemberQuery) FirstIDX(ctx context.Context) int { id, err := mq.FirstID(ctx) if err != nil && !IsNotFound(err) { panic(err) @@ -134,8 +133,8 @@ func (mq *MemberQuery) OnlyX(ctx context.Context) *Member { // OnlyID is like Only, but returns the only Member ID in the query. // Returns a *NotSingularError when more than one Member ID is found. // Returns a *NotFoundError when no entities are found. -func (mq *MemberQuery) OnlyID(ctx context.Context) (id uuid.UUID, err error) { - var ids []uuid.UUID +func (mq *MemberQuery) OnlyID(ctx context.Context) (id int, err error) { + var ids []int if ids, err = mq.Limit(2).IDs(setContextOp(ctx, mq.ctx, ent.OpQueryOnlyID)); err != nil { return } @@ -151,7 +150,7 @@ func (mq *MemberQuery) OnlyID(ctx context.Context) (id uuid.UUID, err error) { } // OnlyIDX is like OnlyID, but panics if an error occurs. -func (mq *MemberQuery) OnlyIDX(ctx context.Context) uuid.UUID { +func (mq *MemberQuery) OnlyIDX(ctx context.Context) int { id, err := mq.OnlyID(ctx) if err != nil { panic(err) @@ -179,7 +178,7 @@ func (mq *MemberQuery) AllX(ctx context.Context) []*Member { } // IDs executes the query and returns a list of Member IDs. -func (mq *MemberQuery) IDs(ctx context.Context) (ids []uuid.UUID, err error) { +func (mq *MemberQuery) IDs(ctx context.Context) (ids []int, err error) { if mq.ctx.Unique == nil && mq.path != nil { mq.Unique(true) } @@ -191,7 +190,7 @@ func (mq *MemberQuery) IDs(ctx context.Context) (ids []uuid.UUID, err error) { } // IDsX is like IDs, but panics if an error occurs. -func (mq *MemberQuery) IDsX(ctx context.Context) []uuid.UUID { +func (mq *MemberQuery) IDsX(ctx context.Context) []int { ids, err := mq.IDs(ctx) if err != nil { panic(err) @@ -366,7 +365,7 @@ func (mq *MemberQuery) sqlCount(ctx context.Context) (int, error) { } func (mq *MemberQuery) querySpec() *sqlgraph.QuerySpec { - _spec := sqlgraph.NewQuerySpec(member.Table, member.Columns, sqlgraph.NewFieldSpec(member.FieldID, field.TypeUUID)) + _spec := sqlgraph.NewQuerySpec(member.Table, member.Columns, sqlgraph.NewFieldSpec(member.FieldID, field.TypeInt)) _spec.From = mq.sql if unique := mq.ctx.Unique; unique != nil { _spec.Unique = *unique diff --git a/member/orm/ent/member_update.go b/member/orm/ent/member_update.go index 6fbfc1f..02e9096 100644 --- a/member/orm/ent/member_update.go +++ b/member/orm/ent/member_update.go @@ -122,23 +122,23 @@ func (mu *MemberUpdate) ClearBcmbCode() *MemberUpdate { return mu } -// SetBcmbWxMsgID sets the "bcmb_wx_msg_id" field. -func (mu *MemberUpdate) SetBcmbWxMsgID(s string) *MemberUpdate { - mu.mutation.SetBcmbWxMsgID(s) +// SetBcmbRegMsgID sets the "bcmb_reg_msg_id" field. +func (mu *MemberUpdate) SetBcmbRegMsgID(s string) *MemberUpdate { + mu.mutation.SetBcmbRegMsgID(s) return mu } -// SetNillableBcmbWxMsgID sets the "bcmb_wx_msg_id" field if the given value is not nil. -func (mu *MemberUpdate) SetNillableBcmbWxMsgID(s *string) *MemberUpdate { +// SetNillableBcmbRegMsgID sets the "bcmb_reg_msg_id" field if the given value is not nil. +func (mu *MemberUpdate) SetNillableBcmbRegMsgID(s *string) *MemberUpdate { if s != nil { - mu.SetBcmbWxMsgID(*s) + mu.SetBcmbRegMsgID(*s) } return mu } -// ClearBcmbWxMsgID clears the value of the "bcmb_wx_msg_id" field. -func (mu *MemberUpdate) ClearBcmbWxMsgID() *MemberUpdate { - mu.mutation.ClearBcmbWxMsgID() +// ClearBcmbRegMsgID clears the value of the "bcmb_reg_msg_id" field. +func (mu *MemberUpdate) ClearBcmbRegMsgID() *MemberUpdate { + mu.mutation.ClearBcmbRegMsgID() return mu } @@ -184,45 +184,59 @@ func (mu *MemberUpdate) AddLevel(i int) *MemberUpdate { return mu } -// SetStatus sets the "status" field. -func (mu *MemberUpdate) SetStatus(i int) *MemberUpdate { - mu.mutation.ResetStatus() - mu.mutation.SetStatus(i) +// SetSource sets the "source" field. +func (mu *MemberUpdate) SetSource(i int) *MemberUpdate { + mu.mutation.ResetSource() + mu.mutation.SetSource(i) return mu } -// SetNillableStatus sets the "status" field if the given value is not nil. -func (mu *MemberUpdate) SetNillableStatus(i *int) *MemberUpdate { +// SetNillableSource sets the "source" field if the given value is not nil. +func (mu *MemberUpdate) SetNillableSource(i *int) *MemberUpdate { if i != nil { - mu.SetStatus(*i) + mu.SetSource(*i) } return mu } -// AddStatus adds i to the "status" field. -func (mu *MemberUpdate) AddStatus(i int) *MemberUpdate { - mu.mutation.AddStatus(i) +// AddSource adds i to the "source" field. +func (mu *MemberUpdate) AddSource(i int) *MemberUpdate { + mu.mutation.AddSource(i) return mu } -// SetSource sets the "source" field. -func (mu *MemberUpdate) SetSource(i int) *MemberUpdate { - mu.mutation.ResetSource() - mu.mutation.SetSource(i) +// SetLastTime sets the "last_time" field. +func (mu *MemberUpdate) SetLastTime(t time.Time) *MemberUpdate { + mu.mutation.SetLastTime(t) return mu } -// SetNillableSource sets the "source" field if the given value is not nil. -func (mu *MemberUpdate) SetNillableSource(i *int) *MemberUpdate { +// SetNillableLastTime sets the "last_time" field if the given value is not nil. +func (mu *MemberUpdate) SetNillableLastTime(t *time.Time) *MemberUpdate { + if t != nil { + mu.SetLastTime(*t) + } + return mu +} + +// SetStatus sets the "status" field. +func (mu *MemberUpdate) SetStatus(i int) *MemberUpdate { + mu.mutation.ResetStatus() + mu.mutation.SetStatus(i) + return mu +} + +// SetNillableStatus sets the "status" field if the given value is not nil. +func (mu *MemberUpdate) SetNillableStatus(i *int) *MemberUpdate { if i != nil { - mu.SetSource(*i) + mu.SetStatus(*i) } return mu } -// AddSource adds i to the "source" field. -func (mu *MemberUpdate) AddSource(i int) *MemberUpdate { - mu.mutation.AddSource(i) +// AddStatus adds i to the "status" field. +func (mu *MemberUpdate) AddStatus(i int) *MemberUpdate { + mu.mutation.AddStatus(i) return mu } @@ -294,9 +308,9 @@ func (mu *MemberUpdate) check() error { return &ValidationError{Name: "bcmb_code", err: fmt.Errorf(`ent: validator failed for field "Member.bcmb_code": %w`, err)} } } - if v, ok := mu.mutation.BcmbWxMsgID(); ok { - if err := member.BcmbWxMsgIDValidator(v); err != nil { - return &ValidationError{Name: "bcmb_wx_msg_id", err: fmt.Errorf(`ent: validator failed for field "Member.bcmb_wx_msg_id": %w`, err)} + if v, ok := mu.mutation.BcmbRegMsgID(); ok { + if err := member.BcmbRegMsgIDValidator(v); err != nil { + return &ValidationError{Name: "bcmb_reg_msg_id", err: fmt.Errorf(`ent: validator failed for field "Member.bcmb_reg_msg_id": %w`, err)} } } return nil @@ -306,7 +320,7 @@ func (mu *MemberUpdate) sqlSave(ctx context.Context) (n int, err error) { if err := mu.check(); err != nil { return n, err } - _spec := sqlgraph.NewUpdateSpec(member.Table, member.Columns, sqlgraph.NewFieldSpec(member.FieldID, field.TypeUUID)) + _spec := sqlgraph.NewUpdateSpec(member.Table, member.Columns, sqlgraph.NewFieldSpec(member.FieldID, field.TypeInt)) if ps := mu.mutation.predicates; len(ps) > 0 { _spec.Predicate = func(selector *sql.Selector) { for i := range ps { @@ -344,11 +358,11 @@ func (mu *MemberUpdate) sqlSave(ctx context.Context) (n int, err error) { if mu.mutation.BcmbRegTimeCleared() { _spec.ClearField(member.FieldBcmbRegTime, field.TypeTime) } - if value, ok := mu.mutation.BcmbWxMsgID(); ok { - _spec.SetField(member.FieldBcmbWxMsgID, field.TypeString, value) + if value, ok := mu.mutation.BcmbRegMsgID(); ok { + _spec.SetField(member.FieldBcmbRegMsgID, field.TypeString, value) } - if mu.mutation.BcmbWxMsgIDCleared() { - _spec.ClearField(member.FieldBcmbWxMsgID, field.TypeString) + if mu.mutation.BcmbRegMsgIDCleared() { + _spec.ClearField(member.FieldBcmbRegMsgID, field.TypeString) } if value, ok := mu.mutation.BcmbType(); ok { _spec.SetField(member.FieldBcmbType, field.TypeInt, value) @@ -362,18 +376,21 @@ func (mu *MemberUpdate) sqlSave(ctx context.Context) (n int, err error) { if value, ok := mu.mutation.AddedLevel(); ok { _spec.AddField(member.FieldLevel, field.TypeInt, value) } - if value, ok := mu.mutation.Status(); ok { - _spec.SetField(member.FieldStatus, field.TypeInt, value) - } - if value, ok := mu.mutation.AddedStatus(); ok { - _spec.AddField(member.FieldStatus, field.TypeInt, value) - } if value, ok := mu.mutation.Source(); ok { _spec.SetField(member.FieldSource, field.TypeInt, value) } if value, ok := mu.mutation.AddedSource(); ok { _spec.AddField(member.FieldSource, field.TypeInt, value) } + if value, ok := mu.mutation.LastTime(); ok { + _spec.SetField(member.FieldLastTime, field.TypeTime, value) + } + if value, ok := mu.mutation.Status(); ok { + _spec.SetField(member.FieldStatus, field.TypeInt, value) + } + if value, ok := mu.mutation.AddedStatus(); ok { + _spec.AddField(member.FieldStatus, field.TypeInt, value) + } if n, err = sqlgraph.UpdateNodes(ctx, mu.driver, _spec); err != nil { if _, ok := err.(*sqlgraph.NotFoundError); ok { err = &NotFoundError{member.Label} @@ -488,23 +505,23 @@ func (muo *MemberUpdateOne) ClearBcmbCode() *MemberUpdateOne { return muo } -// SetBcmbWxMsgID sets the "bcmb_wx_msg_id" field. -func (muo *MemberUpdateOne) SetBcmbWxMsgID(s string) *MemberUpdateOne { - muo.mutation.SetBcmbWxMsgID(s) +// SetBcmbRegMsgID sets the "bcmb_reg_msg_id" field. +func (muo *MemberUpdateOne) SetBcmbRegMsgID(s string) *MemberUpdateOne { + muo.mutation.SetBcmbRegMsgID(s) return muo } -// SetNillableBcmbWxMsgID sets the "bcmb_wx_msg_id" field if the given value is not nil. -func (muo *MemberUpdateOne) SetNillableBcmbWxMsgID(s *string) *MemberUpdateOne { +// SetNillableBcmbRegMsgID sets the "bcmb_reg_msg_id" field if the given value is not nil. +func (muo *MemberUpdateOne) SetNillableBcmbRegMsgID(s *string) *MemberUpdateOne { if s != nil { - muo.SetBcmbWxMsgID(*s) + muo.SetBcmbRegMsgID(*s) } return muo } -// ClearBcmbWxMsgID clears the value of the "bcmb_wx_msg_id" field. -func (muo *MemberUpdateOne) ClearBcmbWxMsgID() *MemberUpdateOne { - muo.mutation.ClearBcmbWxMsgID() +// ClearBcmbRegMsgID clears the value of the "bcmb_reg_msg_id" field. +func (muo *MemberUpdateOne) ClearBcmbRegMsgID() *MemberUpdateOne { + muo.mutation.ClearBcmbRegMsgID() return muo } @@ -550,45 +567,59 @@ func (muo *MemberUpdateOne) AddLevel(i int) *MemberUpdateOne { return muo } -// SetStatus sets the "status" field. -func (muo *MemberUpdateOne) SetStatus(i int) *MemberUpdateOne { - muo.mutation.ResetStatus() - muo.mutation.SetStatus(i) +// SetSource sets the "source" field. +func (muo *MemberUpdateOne) SetSource(i int) *MemberUpdateOne { + muo.mutation.ResetSource() + muo.mutation.SetSource(i) return muo } -// SetNillableStatus sets the "status" field if the given value is not nil. -func (muo *MemberUpdateOne) SetNillableStatus(i *int) *MemberUpdateOne { +// SetNillableSource sets the "source" field if the given value is not nil. +func (muo *MemberUpdateOne) SetNillableSource(i *int) *MemberUpdateOne { if i != nil { - muo.SetStatus(*i) + muo.SetSource(*i) } return muo } -// AddStatus adds i to the "status" field. -func (muo *MemberUpdateOne) AddStatus(i int) *MemberUpdateOne { - muo.mutation.AddStatus(i) +// AddSource adds i to the "source" field. +func (muo *MemberUpdateOne) AddSource(i int) *MemberUpdateOne { + muo.mutation.AddSource(i) return muo } -// SetSource sets the "source" field. -func (muo *MemberUpdateOne) SetSource(i int) *MemberUpdateOne { - muo.mutation.ResetSource() - muo.mutation.SetSource(i) +// SetLastTime sets the "last_time" field. +func (muo *MemberUpdateOne) SetLastTime(t time.Time) *MemberUpdateOne { + muo.mutation.SetLastTime(t) return muo } -// SetNillableSource sets the "source" field if the given value is not nil. -func (muo *MemberUpdateOne) SetNillableSource(i *int) *MemberUpdateOne { +// SetNillableLastTime sets the "last_time" field if the given value is not nil. +func (muo *MemberUpdateOne) SetNillableLastTime(t *time.Time) *MemberUpdateOne { + if t != nil { + muo.SetLastTime(*t) + } + return muo +} + +// SetStatus sets the "status" field. +func (muo *MemberUpdateOne) SetStatus(i int) *MemberUpdateOne { + muo.mutation.ResetStatus() + muo.mutation.SetStatus(i) + return muo +} + +// SetNillableStatus sets the "status" field if the given value is not nil. +func (muo *MemberUpdateOne) SetNillableStatus(i *int) *MemberUpdateOne { if i != nil { - muo.SetSource(*i) + muo.SetStatus(*i) } return muo } -// AddSource adds i to the "source" field. -func (muo *MemberUpdateOne) AddSource(i int) *MemberUpdateOne { - muo.mutation.AddSource(i) +// AddStatus adds i to the "status" field. +func (muo *MemberUpdateOne) AddStatus(i int) *MemberUpdateOne { + muo.mutation.AddStatus(i) return muo } @@ -673,9 +704,9 @@ func (muo *MemberUpdateOne) check() error { return &ValidationError{Name: "bcmb_code", err: fmt.Errorf(`ent: validator failed for field "Member.bcmb_code": %w`, err)} } } - if v, ok := muo.mutation.BcmbWxMsgID(); ok { - if err := member.BcmbWxMsgIDValidator(v); err != nil { - return &ValidationError{Name: "bcmb_wx_msg_id", err: fmt.Errorf(`ent: validator failed for field "Member.bcmb_wx_msg_id": %w`, err)} + if v, ok := muo.mutation.BcmbRegMsgID(); ok { + if err := member.BcmbRegMsgIDValidator(v); err != nil { + return &ValidationError{Name: "bcmb_reg_msg_id", err: fmt.Errorf(`ent: validator failed for field "Member.bcmb_reg_msg_id": %w`, err)} } } return nil @@ -685,7 +716,7 @@ func (muo *MemberUpdateOne) sqlSave(ctx context.Context) (_node *Member, err err if err := muo.check(); err != nil { return _node, err } - _spec := sqlgraph.NewUpdateSpec(member.Table, member.Columns, sqlgraph.NewFieldSpec(member.FieldID, field.TypeUUID)) + _spec := sqlgraph.NewUpdateSpec(member.Table, member.Columns, sqlgraph.NewFieldSpec(member.FieldID, field.TypeInt)) id, ok := muo.mutation.ID() if !ok { return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "Member.id" for update`)} @@ -740,11 +771,11 @@ func (muo *MemberUpdateOne) sqlSave(ctx context.Context) (_node *Member, err err if muo.mutation.BcmbRegTimeCleared() { _spec.ClearField(member.FieldBcmbRegTime, field.TypeTime) } - if value, ok := muo.mutation.BcmbWxMsgID(); ok { - _spec.SetField(member.FieldBcmbWxMsgID, field.TypeString, value) + if value, ok := muo.mutation.BcmbRegMsgID(); ok { + _spec.SetField(member.FieldBcmbRegMsgID, field.TypeString, value) } - if muo.mutation.BcmbWxMsgIDCleared() { - _spec.ClearField(member.FieldBcmbWxMsgID, field.TypeString) + if muo.mutation.BcmbRegMsgIDCleared() { + _spec.ClearField(member.FieldBcmbRegMsgID, field.TypeString) } if value, ok := muo.mutation.BcmbType(); ok { _spec.SetField(member.FieldBcmbType, field.TypeInt, value) @@ -758,18 +789,21 @@ func (muo *MemberUpdateOne) sqlSave(ctx context.Context) (_node *Member, err err if value, ok := muo.mutation.AddedLevel(); ok { _spec.AddField(member.FieldLevel, field.TypeInt, value) } - if value, ok := muo.mutation.Status(); ok { - _spec.SetField(member.FieldStatus, field.TypeInt, value) - } - if value, ok := muo.mutation.AddedStatus(); ok { - _spec.AddField(member.FieldStatus, field.TypeInt, value) - } if value, ok := muo.mutation.Source(); ok { _spec.SetField(member.FieldSource, field.TypeInt, value) } if value, ok := muo.mutation.AddedSource(); ok { _spec.AddField(member.FieldSource, field.TypeInt, value) } + if value, ok := muo.mutation.LastTime(); ok { + _spec.SetField(member.FieldLastTime, field.TypeTime, value) + } + if value, ok := muo.mutation.Status(); ok { + _spec.SetField(member.FieldStatus, field.TypeInt, value) + } + if value, ok := muo.mutation.AddedStatus(); ok { + _spec.AddField(member.FieldStatus, field.TypeInt, value) + } _node = &Member{config: muo.config} _spec.Assign = _node.assignValues _spec.ScanValues = _node.scanValues diff --git a/member/orm/ent/migrate/schema.go b/member/orm/ent/migrate/schema.go index eba4a4a..68325a8 100644 --- a/member/orm/ent/migrate/schema.go +++ b/member/orm/ent/migrate/schema.go @@ -11,7 +11,7 @@ import ( var ( // TMemberColumns holds the columns for the "t_member" table. TMemberColumns = []*schema.Column{ - {Name: "id", Type: field.TypeUUID, Unique: true}, + {Name: "id", Type: field.TypeInt, Increment: true}, {Name: "create_time", Type: field.TypeTime}, {Name: "update_time", Type: field.TypeTime}, {Name: "code", Type: field.TypeString, Unique: true, Size: 36, SchemaType: map[string]string{"mysql": "char(36)", "postgres": "char(36)", "sqlite3": "char(36)"}}, @@ -19,13 +19,14 @@ var ( {Name: "nickname", Type: field.TypeString, Nullable: true, Size: 64, SchemaType: map[string]string{"mysql": "varchar(64)", "postgres": "varchar(64)", "sqlite3": "varchar(64)"}}, {Name: "wx_open_id", Type: field.TypeString, Unique: true, Size: 256, SchemaType: map[string]string{"mysql": "varchar(256)", "postgres": "varchar(256)", "sqlite3": "varchar(256)"}}, {Name: "wx_uid", Type: field.TypeString, Unique: true, Size: 256, SchemaType: map[string]string{"mysql": "varchar(256)", "postgres": "varchar(256)", "sqlite3": "varchar(256)"}}, - {Name: "bcmb_code", Type: field.TypeString, Unique: true, Nullable: true, Size: 64, SchemaType: map[string]string{"mysql": "varchar(64)", "postgres": "varchar(64)", "sqlite3": "varchar(64)"}}, + {Name: "bcmb_code", Type: field.TypeString, Nullable: true, Size: 64, SchemaType: map[string]string{"mysql": "varchar(64)", "postgres": "varchar(64)", "sqlite3": "varchar(64)"}}, {Name: "bcmb_reg_time", Type: field.TypeTime, Nullable: true}, - {Name: "bcmb_wx_msg_id", Type: field.TypeString, Unique: true, Nullable: true, Size: 64, SchemaType: map[string]string{"mysql": "varchar(64)", "postgres": "varchar(64)", "sqlite3": "varchar(64)"}}, + {Name: "bcmb_reg_msg_id", Type: field.TypeString, Unique: true, Nullable: true, Size: 64, SchemaType: map[string]string{"mysql": "varchar(64)", "postgres": "varchar(64)", "sqlite3": "varchar(64)"}}, {Name: "bcmb_type", Type: field.TypeInt, Default: 0}, {Name: "level", Type: field.TypeInt, Default: 0}, - {Name: "status", Type: field.TypeInt, Default: 1}, {Name: "source", Type: field.TypeInt, Default: 0}, + {Name: "last_time", Type: field.TypeTime}, + {Name: "status", Type: field.TypeInt, Default: 1}, } // TMemberTable holds the schema information for the "t_member" table. TMemberTable = &schema.Table{ diff --git a/member/orm/ent/mutation.go b/member/orm/ent/mutation.go index af86215..852cae7 100644 --- a/member/orm/ent/mutation.go +++ b/member/orm/ent/mutation.go @@ -11,7 +11,6 @@ import ( "entgo.io/ent" "entgo.io/ent/dialect/sql" - "github.com/google/uuid" "github.com/twiglab/crm/member/orm/ent/member" "github.com/twiglab/crm/member/orm/ent/predicate" ) @@ -31,31 +30,32 @@ const ( // MemberMutation represents an operation that mutates the Member nodes in the graph. type MemberMutation struct { config - op Op - typ string - id *uuid.UUID - create_time *time.Time - update_time *time.Time - code *string - phone *string - nickname *string - wx_open_id *string - wx_uid *string - bcmb_code *string - bcmb_reg_time *time.Time - bcmb_wx_msg_id *string - bcmb_type *int - addbcmb_type *int - level *int - addlevel *int - status *int - addstatus *int - source *int - addsource *int - clearedFields map[string]struct{} - done bool - oldValue func(context.Context) (*Member, error) - predicates []predicate.Member + op Op + typ string + id *int + create_time *time.Time + update_time *time.Time + code *string + phone *string + nickname *string + wx_open_id *string + wx_uid *string + bcmb_code *string + bcmb_reg_time *time.Time + bcmb_reg_msg_id *string + bcmb_type *int + addbcmb_type *int + level *int + addlevel *int + source *int + addsource *int + last_time *time.Time + status *int + addstatus *int + clearedFields map[string]struct{} + done bool + oldValue func(context.Context) (*Member, error) + predicates []predicate.Member } var _ ent.Mutation = (*MemberMutation)(nil) @@ -78,7 +78,7 @@ func newMemberMutation(c config, op Op, opts ...memberOption) *MemberMutation { } // withMemberID sets the ID field of the mutation. -func withMemberID(id uuid.UUID) memberOption { +func withMemberID(id int) memberOption { return func(m *MemberMutation) { var ( err error @@ -128,15 +128,9 @@ func (m MemberMutation) Tx() (*Tx, error) { return tx, nil } -// SetID sets the value of the id field. Note that this -// operation is only accepted on creation of Member entities. -func (m *MemberMutation) SetID(id uuid.UUID) { - 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 *MemberMutation) ID() (id uuid.UUID, exists bool) { +func (m *MemberMutation) ID() (id int, exists bool) { if m.id == nil { return } @@ -147,12 +141,12 @@ func (m *MemberMutation) ID() (id uuid.UUID, 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 *MemberMutation) IDs(ctx context.Context) ([]uuid.UUID, error) { +func (m *MemberMutation) IDs(ctx context.Context) ([]int, error) { switch { case m.op.Is(OpUpdateOne | OpDeleteOne): id, exists := m.ID() if exists { - return []uuid.UUID{id}, nil + return []int{id}, nil } fallthrough case m.op.Is(OpUpdate | OpDelete): @@ -538,53 +532,53 @@ func (m *MemberMutation) ResetBcmbRegTime() { delete(m.clearedFields, member.FieldBcmbRegTime) } -// SetBcmbWxMsgID sets the "bcmb_wx_msg_id" field. -func (m *MemberMutation) SetBcmbWxMsgID(s string) { - m.bcmb_wx_msg_id = &s +// SetBcmbRegMsgID sets the "bcmb_reg_msg_id" field. +func (m *MemberMutation) SetBcmbRegMsgID(s string) { + m.bcmb_reg_msg_id = &s } -// BcmbWxMsgID returns the value of the "bcmb_wx_msg_id" field in the mutation. -func (m *MemberMutation) BcmbWxMsgID() (r string, exists bool) { - v := m.bcmb_wx_msg_id +// BcmbRegMsgID returns the value of the "bcmb_reg_msg_id" field in the mutation. +func (m *MemberMutation) BcmbRegMsgID() (r string, exists bool) { + v := m.bcmb_reg_msg_id if v == nil { return } return *v, true } -// OldBcmbWxMsgID returns the old "bcmb_wx_msg_id" field's value of the Member entity. +// OldBcmbRegMsgID returns the old "bcmb_reg_msg_id" field's value of the Member entity. // If the Member 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 *MemberMutation) OldBcmbWxMsgID(ctx context.Context) (v string, err error) { +func (m *MemberMutation) OldBcmbRegMsgID(ctx context.Context) (v string, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldBcmbWxMsgID is only allowed on UpdateOne operations") + return v, errors.New("OldBcmbRegMsgID is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldBcmbWxMsgID requires an ID field in the mutation") + return v, errors.New("OldBcmbRegMsgID requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldBcmbWxMsgID: %w", err) + return v, fmt.Errorf("querying old value for OldBcmbRegMsgID: %w", err) } - return oldValue.BcmbWxMsgID, nil + return oldValue.BcmbRegMsgID, nil } -// ClearBcmbWxMsgID clears the value of the "bcmb_wx_msg_id" field. -func (m *MemberMutation) ClearBcmbWxMsgID() { - m.bcmb_wx_msg_id = nil - m.clearedFields[member.FieldBcmbWxMsgID] = struct{}{} +// ClearBcmbRegMsgID clears the value of the "bcmb_reg_msg_id" field. +func (m *MemberMutation) ClearBcmbRegMsgID() { + m.bcmb_reg_msg_id = nil + m.clearedFields[member.FieldBcmbRegMsgID] = struct{}{} } -// BcmbWxMsgIDCleared returns if the "bcmb_wx_msg_id" field was cleared in this mutation. -func (m *MemberMutation) BcmbWxMsgIDCleared() bool { - _, ok := m.clearedFields[member.FieldBcmbWxMsgID] +// BcmbRegMsgIDCleared returns if the "bcmb_reg_msg_id" field was cleared in this mutation. +func (m *MemberMutation) BcmbRegMsgIDCleared() bool { + _, ok := m.clearedFields[member.FieldBcmbRegMsgID] return ok } -// ResetBcmbWxMsgID resets all changes to the "bcmb_wx_msg_id" field. -func (m *MemberMutation) ResetBcmbWxMsgID() { - m.bcmb_wx_msg_id = nil - delete(m.clearedFields, member.FieldBcmbWxMsgID) +// ResetBcmbRegMsgID resets all changes to the "bcmb_reg_msg_id" field. +func (m *MemberMutation) ResetBcmbRegMsgID() { + m.bcmb_reg_msg_id = nil + delete(m.clearedFields, member.FieldBcmbRegMsgID) } // SetBcmbType sets the "bcmb_type" field. @@ -699,116 +693,152 @@ func (m *MemberMutation) ResetLevel() { m.addlevel = nil } -// SetStatus sets the "status" field. -func (m *MemberMutation) SetStatus(i int) { - m.status = &i - m.addstatus = nil +// SetSource sets the "source" field. +func (m *MemberMutation) SetSource(i int) { + m.source = &i + m.addsource = nil } -// Status returns the value of the "status" field in the mutation. -func (m *MemberMutation) Status() (r int, exists bool) { - v := m.status +// Source returns the value of the "source" field in the mutation. +func (m *MemberMutation) Source() (r int, exists bool) { + v := m.source if v == nil { return } return *v, true } -// OldStatus returns the old "status" field's value of the Member entity. +// OldSource returns the old "source" field's value of the Member entity. // If the Member 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 *MemberMutation) OldStatus(ctx context.Context) (v int, err error) { +func (m *MemberMutation) OldSource(ctx context.Context) (v int, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldStatus is only allowed on UpdateOne operations") + return v, errors.New("OldSource 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") + return v, errors.New("OldSource 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 v, fmt.Errorf("querying old value for OldSource: %w", err) } - return oldValue.Status, nil + return oldValue.Source, nil } -// AddStatus adds i to the "status" field. -func (m *MemberMutation) AddStatus(i int) { - if m.addstatus != nil { - *m.addstatus += i +// AddSource adds i to the "source" field. +func (m *MemberMutation) AddSource(i int) { + if m.addsource != nil { + *m.addsource += i } else { - m.addstatus = &i + m.addsource = &i } } -// AddedStatus returns the value that was added to the "status" field in this mutation. -func (m *MemberMutation) AddedStatus() (r int, exists bool) { - v := m.addstatus +// AddedSource returns the value that was added to the "source" field in this mutation. +func (m *MemberMutation) AddedSource() (r int, exists bool) { + v := m.addsource if v == nil { return } return *v, true } -// ResetStatus resets all changes to the "status" field. -func (m *MemberMutation) ResetStatus() { - m.status = nil - m.addstatus = nil +// ResetSource resets all changes to the "source" field. +func (m *MemberMutation) ResetSource() { + m.source = nil + m.addsource = nil } -// SetSource sets the "source" field. -func (m *MemberMutation) SetSource(i int) { - m.source = &i - m.addsource = nil +// SetLastTime sets the "last_time" field. +func (m *MemberMutation) SetLastTime(t time.Time) { + m.last_time = &t } -// Source returns the value of the "source" field in the mutation. -func (m *MemberMutation) Source() (r int, exists bool) { - v := m.source +// LastTime returns the value of the "last_time" field in the mutation. +func (m *MemberMutation) LastTime() (r time.Time, exists bool) { + v := m.last_time if v == nil { return } return *v, true } -// OldSource returns the old "source" field's value of the Member entity. +// OldLastTime returns the old "last_time" field's value of the Member entity. // If the Member 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 *MemberMutation) OldSource(ctx context.Context) (v int, err error) { +func (m *MemberMutation) OldLastTime(ctx context.Context) (v time.Time, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldSource is only allowed on UpdateOne operations") + return v, errors.New("OldLastTime is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldSource requires an ID field in the mutation") + return v, errors.New("OldLastTime requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldSource: %w", err) + return v, fmt.Errorf("querying old value for OldLastTime: %w", err) } - return oldValue.Source, nil + return oldValue.LastTime, nil } -// AddSource adds i to the "source" field. -func (m *MemberMutation) AddSource(i int) { - if m.addsource != nil { - *m.addsource += i +// ResetLastTime resets all changes to the "last_time" field. +func (m *MemberMutation) ResetLastTime() { + m.last_time = nil +} + +// SetStatus sets the "status" field. +func (m *MemberMutation) SetStatus(i int) { + m.status = &i + m.addstatus = nil +} + +// Status returns the value of the "status" field in the mutation. +func (m *MemberMutation) Status() (r int, exists bool) { + v := m.status + if v == nil { + return + } + return *v, true +} + +// OldStatus returns the old "status" field's value of the Member entity. +// If the Member 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 *MemberMutation) OldStatus(ctx context.Context) (v int, 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 i to the "status" field. +func (m *MemberMutation) AddStatus(i int) { + if m.addstatus != nil { + *m.addstatus += i } else { - m.addsource = &i + m.addstatus = &i } } -// AddedSource returns the value that was added to the "source" field in this mutation. -func (m *MemberMutation) AddedSource() (r int, exists bool) { - v := m.addsource +// AddedStatus returns the value that was added to the "status" field in this mutation. +func (m *MemberMutation) AddedStatus() (r int, exists bool) { + v := m.addstatus if v == nil { return } return *v, true } -// ResetSource resets all changes to the "source" field. -func (m *MemberMutation) ResetSource() { - m.source = nil - m.addsource = nil +// ResetStatus resets all changes to the "status" field. +func (m *MemberMutation) ResetStatus() { + m.status = nil + m.addstatus = nil } // Where appends a list predicates to the MemberMutation builder. @@ -845,7 +875,7 @@ func (m *MemberMutation) Type() string { // order to get all numeric fields that were incremented/decremented, call // AddedFields(). func (m *MemberMutation) Fields() []string { - fields := make([]string, 0, 14) + fields := make([]string, 0, 15) if m.create_time != nil { fields = append(fields, member.FieldCreateTime) } @@ -873,8 +903,8 @@ func (m *MemberMutation) Fields() []string { if m.bcmb_reg_time != nil { fields = append(fields, member.FieldBcmbRegTime) } - if m.bcmb_wx_msg_id != nil { - fields = append(fields, member.FieldBcmbWxMsgID) + if m.bcmb_reg_msg_id != nil { + fields = append(fields, member.FieldBcmbRegMsgID) } if m.bcmb_type != nil { fields = append(fields, member.FieldBcmbType) @@ -882,12 +912,15 @@ func (m *MemberMutation) Fields() []string { if m.level != nil { fields = append(fields, member.FieldLevel) } - if m.status != nil { - fields = append(fields, member.FieldStatus) - } if m.source != nil { fields = append(fields, member.FieldSource) } + if m.last_time != nil { + fields = append(fields, member.FieldLastTime) + } + if m.status != nil { + fields = append(fields, member.FieldStatus) + } return fields } @@ -914,16 +947,18 @@ func (m *MemberMutation) Field(name string) (ent.Value, bool) { return m.BcmbCode() case member.FieldBcmbRegTime: return m.BcmbRegTime() - case member.FieldBcmbWxMsgID: - return m.BcmbWxMsgID() + case member.FieldBcmbRegMsgID: + return m.BcmbRegMsgID() case member.FieldBcmbType: return m.BcmbType() case member.FieldLevel: return m.Level() - case member.FieldStatus: - return m.Status() case member.FieldSource: return m.Source() + case member.FieldLastTime: + return m.LastTime() + case member.FieldStatus: + return m.Status() } return nil, false } @@ -951,16 +986,18 @@ func (m *MemberMutation) OldField(ctx context.Context, name string) (ent.Value, return m.OldBcmbCode(ctx) case member.FieldBcmbRegTime: return m.OldBcmbRegTime(ctx) - case member.FieldBcmbWxMsgID: - return m.OldBcmbWxMsgID(ctx) + case member.FieldBcmbRegMsgID: + return m.OldBcmbRegMsgID(ctx) case member.FieldBcmbType: return m.OldBcmbType(ctx) case member.FieldLevel: return m.OldLevel(ctx) - case member.FieldStatus: - return m.OldStatus(ctx) case member.FieldSource: return m.OldSource(ctx) + case member.FieldLastTime: + return m.OldLastTime(ctx) + case member.FieldStatus: + return m.OldStatus(ctx) } return nil, fmt.Errorf("unknown Member field %s", name) } @@ -1033,12 +1070,12 @@ func (m *MemberMutation) SetField(name string, value ent.Value) error { } m.SetBcmbRegTime(v) return nil - case member.FieldBcmbWxMsgID: + case member.FieldBcmbRegMsgID: v, ok := value.(string) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } - m.SetBcmbWxMsgID(v) + m.SetBcmbRegMsgID(v) return nil case member.FieldBcmbType: v, ok := value.(int) @@ -1054,19 +1091,26 @@ func (m *MemberMutation) SetField(name string, value ent.Value) error { } m.SetLevel(v) return nil - case member.FieldStatus: + case member.FieldSource: v, ok := value.(int) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } - m.SetStatus(v) + m.SetSource(v) return nil - case member.FieldSource: + case member.FieldLastTime: + v, ok := value.(time.Time) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetLastTime(v) + return nil + case member.FieldStatus: v, ok := value.(int) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } - m.SetSource(v) + m.SetStatus(v) return nil } return fmt.Errorf("unknown Member field %s", name) @@ -1082,12 +1126,12 @@ func (m *MemberMutation) AddedFields() []string { if m.addlevel != nil { fields = append(fields, member.FieldLevel) } - if m.addstatus != nil { - fields = append(fields, member.FieldStatus) - } if m.addsource != nil { fields = append(fields, member.FieldSource) } + if m.addstatus != nil { + fields = append(fields, member.FieldStatus) + } return fields } @@ -1100,10 +1144,10 @@ func (m *MemberMutation) AddedField(name string) (ent.Value, bool) { return m.AddedBcmbType() case member.FieldLevel: return m.AddedLevel() - case member.FieldStatus: - return m.AddedStatus() case member.FieldSource: return m.AddedSource() + case member.FieldStatus: + return m.AddedStatus() } return nil, false } @@ -1127,19 +1171,19 @@ func (m *MemberMutation) AddField(name string, value ent.Value) error { } m.AddLevel(v) return nil - case member.FieldStatus: + case member.FieldSource: v, ok := value.(int) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } - m.AddStatus(v) + m.AddSource(v) return nil - case member.FieldSource: + case member.FieldStatus: v, ok := value.(int) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } - m.AddSource(v) + m.AddStatus(v) return nil } return fmt.Errorf("unknown Member numeric field %s", name) @@ -1161,8 +1205,8 @@ func (m *MemberMutation) ClearedFields() []string { if m.FieldCleared(member.FieldBcmbRegTime) { fields = append(fields, member.FieldBcmbRegTime) } - if m.FieldCleared(member.FieldBcmbWxMsgID) { - fields = append(fields, member.FieldBcmbWxMsgID) + if m.FieldCleared(member.FieldBcmbRegMsgID) { + fields = append(fields, member.FieldBcmbRegMsgID) } return fields } @@ -1190,8 +1234,8 @@ func (m *MemberMutation) ClearField(name string) error { case member.FieldBcmbRegTime: m.ClearBcmbRegTime() return nil - case member.FieldBcmbWxMsgID: - m.ClearBcmbWxMsgID() + case member.FieldBcmbRegMsgID: + m.ClearBcmbRegMsgID() return nil } return fmt.Errorf("unknown Member nullable field %s", name) @@ -1228,8 +1272,8 @@ func (m *MemberMutation) ResetField(name string) error { case member.FieldBcmbRegTime: m.ResetBcmbRegTime() return nil - case member.FieldBcmbWxMsgID: - m.ResetBcmbWxMsgID() + case member.FieldBcmbRegMsgID: + m.ResetBcmbRegMsgID() return nil case member.FieldBcmbType: m.ResetBcmbType() @@ -1237,12 +1281,15 @@ func (m *MemberMutation) ResetField(name string) error { case member.FieldLevel: m.ResetLevel() return nil - case member.FieldStatus: - m.ResetStatus() - return nil case member.FieldSource: m.ResetSource() return nil + case member.FieldLastTime: + m.ResetLastTime() + return nil + case member.FieldStatus: + m.ResetStatus() + return nil } return fmt.Errorf("unknown Member field %s", name) } diff --git a/member/orm/ent/runtime.go b/member/orm/ent/runtime.go index 02a7a8e..b1231ec 100644 --- a/member/orm/ent/runtime.go +++ b/member/orm/ent/runtime.go @@ -5,7 +5,6 @@ package ent import ( "time" - "github.com/google/uuid" "github.com/twiglab/crm/member/orm/ent/member" "github.com/twiglab/crm/member/orm/schema" ) @@ -30,7 +29,7 @@ func init() { // member.UpdateDefaultUpdateTime holds the default value on update for the update_time field. member.UpdateDefaultUpdateTime = memberDescUpdateTime.UpdateDefault.(func() time.Time) // memberDescCode is the schema descriptor for code field. - memberDescCode := memberFields[1].Descriptor() + memberDescCode := memberFields[0].Descriptor() // member.DefaultCode holds the default value on creation for the code field. member.DefaultCode = memberDescCode.Default.(func() string) // member.CodeValidator is a validator for the "code" field. It is called by the builders before save. @@ -50,7 +49,7 @@ func init() { } }() // memberDescPhone is the schema descriptor for phone field. - memberDescPhone := memberFields[2].Descriptor() + memberDescPhone := memberFields[1].Descriptor() // member.PhoneValidator is a validator for the "phone" field. It is called by the builders before save. member.PhoneValidator = func() func(string) error { validators := memberDescPhone.Validators @@ -68,43 +67,43 @@ func init() { } }() // memberDescNickname is the schema descriptor for nickname field. - memberDescNickname := memberFields[3].Descriptor() + memberDescNickname := memberFields[2].Descriptor() // member.NicknameValidator is a validator for the "nickname" field. It is called by the builders before save. member.NicknameValidator = memberDescNickname.Validators[0].(func(string) error) // memberDescWxOpenID is the schema descriptor for wx_open_id field. - memberDescWxOpenID := memberFields[4].Descriptor() + memberDescWxOpenID := memberFields[3].Descriptor() // member.WxOpenIDValidator is a validator for the "wx_open_id" field. It is called by the builders before save. member.WxOpenIDValidator = memberDescWxOpenID.Validators[0].(func(string) error) // memberDescWxUID is the schema descriptor for wx_uid field. - memberDescWxUID := memberFields[5].Descriptor() + memberDescWxUID := memberFields[4].Descriptor() // member.WxUIDValidator is a validator for the "wx_uid" field. It is called by the builders before save. member.WxUIDValidator = memberDescWxUID.Validators[0].(func(string) error) // memberDescBcmbCode is the schema descriptor for bcmb_code field. - memberDescBcmbCode := memberFields[6].Descriptor() + memberDescBcmbCode := memberFields[5].Descriptor() // member.BcmbCodeValidator is a validator for the "bcmb_code" field. It is called by the builders before save. member.BcmbCodeValidator = memberDescBcmbCode.Validators[0].(func(string) error) - // memberDescBcmbWxMsgID is the schema descriptor for bcmb_wx_msg_id field. - memberDescBcmbWxMsgID := memberFields[8].Descriptor() - // member.BcmbWxMsgIDValidator is a validator for the "bcmb_wx_msg_id" field. It is called by the builders before save. - member.BcmbWxMsgIDValidator = memberDescBcmbWxMsgID.Validators[0].(func(string) error) + // memberDescBcmbRegMsgID is the schema descriptor for bcmb_reg_msg_id field. + memberDescBcmbRegMsgID := memberFields[7].Descriptor() + // member.BcmbRegMsgIDValidator is a validator for the "bcmb_reg_msg_id" field. It is called by the builders before save. + member.BcmbRegMsgIDValidator = memberDescBcmbRegMsgID.Validators[0].(func(string) error) // memberDescBcmbType is the schema descriptor for bcmb_type field. - memberDescBcmbType := memberFields[9].Descriptor() + memberDescBcmbType := memberFields[8].Descriptor() // member.DefaultBcmbType holds the default value on creation for the bcmb_type field. member.DefaultBcmbType = memberDescBcmbType.Default.(int) // memberDescLevel is the schema descriptor for level field. - memberDescLevel := memberFields[10].Descriptor() + memberDescLevel := memberFields[9].Descriptor() // member.DefaultLevel holds the default value on creation for the level field. member.DefaultLevel = memberDescLevel.Default.(int) - // memberDescStatus is the schema descriptor for status field. - memberDescStatus := memberFields[11].Descriptor() - // member.DefaultStatus holds the default value on creation for the status field. - member.DefaultStatus = memberDescStatus.Default.(int) // memberDescSource is the schema descriptor for source field. - memberDescSource := memberFields[12].Descriptor() + memberDescSource := memberFields[10].Descriptor() // member.DefaultSource holds the default value on creation for the source field. member.DefaultSource = memberDescSource.Default.(int) - // memberDescID is the schema descriptor for id field. - memberDescID := memberFields[0].Descriptor() - // member.DefaultID holds the default value on creation for the id field. - member.DefaultID = memberDescID.Default.(func() uuid.UUID) + // memberDescLastTime is the schema descriptor for last_time field. + memberDescLastTime := memberFields[11].Descriptor() + // member.DefaultLastTime holds the default value on creation for the last_time field. + member.DefaultLastTime = memberDescLastTime.Default.(func() time.Time) + // memberDescStatus is the schema descriptor for status field. + memberDescStatus := memberFields[12].Descriptor() + // member.DefaultStatus holds the default value on creation for the status field. + member.DefaultStatus = memberDescStatus.Default.(int) } diff --git a/member/orm/schema/member.go b/member/orm/schema/member.go index ec23d67..52b204f 100644 --- a/member/orm/schema/member.go +++ b/member/orm/schema/member.go @@ -1,6 +1,8 @@ package schema import ( + "time" + "entgo.io/ent" "entgo.io/ent/dialect" "entgo.io/ent/dialect/entsql" @@ -8,7 +10,6 @@ import ( "entgo.io/ent/schema/field" "entgo.io/ent/schema/index" "entgo.io/ent/schema/mixin" - "github.com/google/uuid" "github.com/twiglab/crm/member/orm/schema/internal/x" ) @@ -18,10 +19,6 @@ type Member struct { func (Member) Fields() []ent.Field { return []ent.Field{ - field.UUID("id", uuid.Nil). - Default(x.ID). - Unique(). - Immutable(), field.String("code"). MaxLen(36). @@ -77,7 +74,6 @@ func (Member) Fields() []ent.Field { // 用户在商圈会员卡card_id下的唯一标志,用户领取会员卡后获得的code field.String("bcmb_code"). MaxLen(64). - Unique(). Optional(). SchemaType(map[string]string{ dialect.MySQL: "varchar(64)", // Override MySQL. @@ -92,7 +88,7 @@ func (Member) Fields() []ent.Field { Immutable(), // 商圈会员消息id,用于幂等 - field.String("bcmb_wx_msg_id"). + field.String("bcmb_reg_msg_id"). MaxLen(64). Unique(). Optional(). @@ -111,9 +107,12 @@ func (Member) Fields() []ent.Field { // 会员等级 field.Int("level").Default(0), - field.Int("status").Default(1), - field.Int("source").Default(0), + + // 最后一次登录时间 + field.Time("last_time").Default(time.Now), + + field.Int("status").Default(1), } } diff --git a/wechat/go.mod b/wechat/go.mod index ef63434..86361e5 100644 --- a/wechat/go.mod +++ b/wechat/go.mod @@ -35,10 +35,13 @@ require ( github.com/go-viper/mapstructure/v2 v2.2.1 // indirect github.com/gorilla/websocket v1.5.0 // indirect github.com/hashicorp/golang-lru/v2 v2.0.7 // indirect + github.com/inconshreveable/mousetrap v1.1.0 // indirect github.com/onsi/gomega v1.34.1 // indirect github.com/philhofer/fwd v1.1.3-0.20240916144458-20a13a1f6b7c // indirect github.com/sirupsen/logrus v1.9.0 // indirect github.com/spf13/cast v1.4.1 // indirect + github.com/spf13/cobra v1.8.1 // indirect + github.com/spf13/pflag v1.0.5 // indirect github.com/tidwall/gjson v1.14.1 // indirect github.com/tidwall/match v1.1.1 // indirect github.com/tidwall/pretty v1.2.0 // indirect diff --git a/wechat/go.sum b/wechat/go.sum index 6f987ca..4e29881 100644 --- a/wechat/go.sum +++ b/wechat/go.sum @@ -24,6 +24,7 @@ github.com/cespare/xxhash/v2 v2.2.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XL github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI= github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e/go.mod h1:nSuG5e5PlCu98SY8svDHJxuZscDgtXS6KTTbou5AhLI= github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1/go.mod h1:Q3SI9o4m/ZMnBNeIyt5eFwwo7qiLfzFZmjNmxjkiQlU= +github.com/cpuguy83/go-md2man/v2 v2.0.4/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= @@ -81,6 +82,8 @@ github.com/hashicorp/golang-lru/v2 v2.0.7 h1:a+bsQ5rvGLjzHuww6tVxozPZFVghXaHOwFs github.com/hashicorp/golang-lru/v2 v2.0.7/go.mod h1:QeFd9opnmA6QUJc5vARoKUSoFhyfM2/ZepoAG6RGpeM= github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU= github.com/ianlancetaylor/demangle v0.0.0-20200824232613-28f6c0f3b639/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc= +github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8= +github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw= github.com/it512/box v0.0.4 h1:eDhbcufVCWHMSrIYZVpyaDzB4TkEkuV9sRKeHY5hUW0= github.com/it512/box v0.0.4/go.mod h1:DCOijMT58jkk2xbW2pNAP4GpdBv4GlBUcBflf7gw8S8= github.com/joho/godotenv v1.5.1 h1:7eLL/+HRGLY0ldzfGMeQkb7vMd0as4CfYvUVzLqw0N0= @@ -107,6 +110,7 @@ github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZb github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/rabbitmq/amqp091-go v1.10.0 h1:STpn5XsHlHGcecLmMFCtg7mqq0RnD+zFr4uzukfVhBw= github.com/rabbitmq/amqp091-go v1.10.0/go.mod h1:Hy4jKW5kQART1u+JkDTF9YYOQUHXqMuhrgxOEeS7G4o= +github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= github.com/sergi/go-diff v1.3.1 h1:xkr+Oxo4BOQKmkn/B9eMK0g5Kg/983T9DqqPHwYqD+8= github.com/sergi/go-diff v1.3.1/go.mod h1:aMJSSKb2lpPvRNec0+w3fl7LP9IOFzdc9Pa4NFbPK1I= github.com/silenceper/wechat/v2 v2.1.7 h1:v4AC4pa6NRm7Pa2FJnmWABOxZ9hx3IIo20xKT4t1msY= @@ -117,6 +121,10 @@ github.com/sosodev/duration v1.3.1 h1:qtHBDMQ6lvMQsL15g4aopM4HEfOaYuhWBw3NPTtlqq github.com/sosodev/duration v1.3.1/go.mod h1:RQIBBX0+fMLc/D9+Jb/fwvVmo0eZvDDEERAikUR6SDg= github.com/spf13/cast v1.4.1 h1:s0hze+J0196ZfEMTs80N7UlFt0BDuQ7Q+JDnHiMWKdA= github.com/spf13/cast v1.4.1/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkUJE= +github.com/spf13/cobra v1.8.1 h1:e5/vxKd/rZsfSJMUX1agtjeTDf+qv1/JdBF8gg5k9ZM= +github.com/spf13/cobra v1.8.1/go.mod h1:wHxEcudfqmLYa8iTfL+OuZPbBZkmvliBWKIezN3kD9Y= +github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA= +github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA=