Browse Source

fix:add waName

jimmyyem 2 months ago
parent
commit
6f36db5e0e

+ 1 - 0
desc/wechat/whatsapp.api

@@ -11,6 +11,7 @@ type (
         Status  *uint8 `json:"status,optional"`
 
         WaId  *string `json:"waId,optional"`
+		WaName  *string `json:"waName,optional"`
 
         // 回调地址 
         Callback  *string `json:"callback,optional"`

+ 2 - 1
ent/migrate/schema.go

@@ -1041,6 +1041,7 @@ var (
 		{Name: "status", Type: field.TypeUint8, Nullable: true, Comment: "Status 1: normal 2: ban | 状态 1 正常 2 禁用", Default: 1},
 		{Name: "deleted_at", Type: field.TypeTime, Nullable: true, Comment: "Delete Time | 删除日期"},
 		{Name: "wa_id", Type: field.TypeString, Nullable: true, Default: ""},
+		{Name: "wa_name", Type: field.TypeString, Nullable: true, Default: ""},
 		{Name: "callback", Type: field.TypeString, Nullable: true, Default: ""},
 		{Name: "account", Type: field.TypeString, Nullable: true, Default: ""},
 		{Name: "cc", Type: field.TypeString, Default: ""},
@@ -1064,7 +1065,7 @@ var (
 		ForeignKeys: []*schema.ForeignKey{
 			{
 				Symbol:     "whatsapp_agent_wa_agent",
-				Columns:    []*schema.Column{WhatsappColumns[19]},
+				Columns:    []*schema.Column{WhatsappColumns[20]},
 				RefColumns: []*schema.Column{AgentColumns[0]},
 				OnDelete:   schema.NoAction,
 			},

+ 74 - 1
ent/mutation.go

@@ -36960,6 +36960,7 @@ type WhatsappMutation struct {
 	addstatus              *int8
 	deleted_at             *time.Time
 	wa_id                  *string
+	wa_name                *string
 	callback               *string
 	account                *string
 	cc                     *string
@@ -37331,6 +37332,55 @@ func (m *WhatsappMutation) ResetWaID() {
 	delete(m.clearedFields, whatsapp.FieldWaID)
 }
 
+// SetWaName sets the "wa_name" field.
+func (m *WhatsappMutation) SetWaName(s string) {
+	m.wa_name = &s
+}
+
+// WaName returns the value of the "wa_name" field in the mutation.
+func (m *WhatsappMutation) WaName() (r string, exists bool) {
+	v := m.wa_name
+	if v == nil {
+		return
+	}
+	return *v, true
+}
+
+// OldWaName returns the old "wa_name" field's value of the Whatsapp entity.
+// If the Whatsapp 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 *WhatsappMutation) OldWaName(ctx context.Context) (v string, err error) {
+	if !m.op.Is(OpUpdateOne) {
+		return v, errors.New("OldWaName is only allowed on UpdateOne operations")
+	}
+	if m.id == nil || m.oldValue == nil {
+		return v, errors.New("OldWaName requires an ID field in the mutation")
+	}
+	oldValue, err := m.oldValue(ctx)
+	if err != nil {
+		return v, fmt.Errorf("querying old value for OldWaName: %w", err)
+	}
+	return oldValue.WaName, nil
+}
+
+// ClearWaName clears the value of the "wa_name" field.
+func (m *WhatsappMutation) ClearWaName() {
+	m.wa_name = nil
+	m.clearedFields[whatsapp.FieldWaName] = struct{}{}
+}
+
+// WaNameCleared returns if the "wa_name" field was cleared in this mutation.
+func (m *WhatsappMutation) WaNameCleared() bool {
+	_, ok := m.clearedFields[whatsapp.FieldWaName]
+	return ok
+}
+
+// ResetWaName resets all changes to the "wa_name" field.
+func (m *WhatsappMutation) ResetWaName() {
+	m.wa_name = nil
+	delete(m.clearedFields, whatsapp.FieldWaName)
+}
+
 // SetCallback sets the "callback" field.
 func (m *WhatsappMutation) SetCallback(s string) {
 	m.callback = &s
@@ -38118,7 +38168,7 @@ func (m *WhatsappMutation) Type() string {
 // order to get all numeric fields that were incremented/decremented, call
 // AddedFields().
 func (m *WhatsappMutation) Fields() []string {
-	fields := make([]string, 0, 19)
+	fields := make([]string, 0, 20)
 	if m.created_at != nil {
 		fields = append(fields, whatsapp.FieldCreatedAt)
 	}
@@ -38134,6 +38184,9 @@ func (m *WhatsappMutation) Fields() []string {
 	if m.wa_id != nil {
 		fields = append(fields, whatsapp.FieldWaID)
 	}
+	if m.wa_name != nil {
+		fields = append(fields, whatsapp.FieldWaName)
+	}
 	if m.callback != nil {
 		fields = append(fields, whatsapp.FieldCallback)
 	}
@@ -38194,6 +38247,8 @@ func (m *WhatsappMutation) Field(name string) (ent.Value, bool) {
 		return m.DeletedAt()
 	case whatsapp.FieldWaID:
 		return m.WaID()
+	case whatsapp.FieldWaName:
+		return m.WaName()
 	case whatsapp.FieldCallback:
 		return m.Callback()
 	case whatsapp.FieldAgentID:
@@ -38241,6 +38296,8 @@ func (m *WhatsappMutation) OldField(ctx context.Context, name string) (ent.Value
 		return m.OldDeletedAt(ctx)
 	case whatsapp.FieldWaID:
 		return m.OldWaID(ctx)
+	case whatsapp.FieldWaName:
+		return m.OldWaName(ctx)
 	case whatsapp.FieldCallback:
 		return m.OldCallback(ctx)
 	case whatsapp.FieldAgentID:
@@ -38313,6 +38370,13 @@ func (m *WhatsappMutation) SetField(name string, value ent.Value) error {
 		}
 		m.SetWaID(v)
 		return nil
+	case whatsapp.FieldWaName:
+		v, ok := value.(string)
+		if !ok {
+			return fmt.Errorf("unexpected type %T for field %s", value, name)
+		}
+		m.SetWaName(v)
+		return nil
 	case whatsapp.FieldCallback:
 		v, ok := value.(string)
 		if !ok {
@@ -38489,6 +38553,9 @@ func (m *WhatsappMutation) ClearedFields() []string {
 	if m.FieldCleared(whatsapp.FieldWaID) {
 		fields = append(fields, whatsapp.FieldWaID)
 	}
+	if m.FieldCleared(whatsapp.FieldWaName) {
+		fields = append(fields, whatsapp.FieldWaName)
+	}
 	if m.FieldCleared(whatsapp.FieldCallback) {
 		fields = append(fields, whatsapp.FieldCallback)
 	}
@@ -38539,6 +38606,9 @@ func (m *WhatsappMutation) ClearField(name string) error {
 	case whatsapp.FieldWaID:
 		m.ClearWaID()
 		return nil
+	case whatsapp.FieldWaName:
+		m.ClearWaName()
+		return nil
 	case whatsapp.FieldCallback:
 		m.ClearCallback()
 		return nil
@@ -38589,6 +38659,9 @@ func (m *WhatsappMutation) ResetField(name string) error {
 	case whatsapp.FieldWaID:
 		m.ResetWaID()
 		return nil
+	case whatsapp.FieldWaName:
+		m.ResetWaName()
+		return nil
 	case whatsapp.FieldCallback:
 		m.ResetCallback()
 		return nil

+ 14 - 10
ent/runtime/runtime.go

@@ -1301,44 +1301,48 @@ func init() {
 	whatsappDescWaID := whatsappFields[0].Descriptor()
 	// whatsapp.DefaultWaID holds the default value on creation for the wa_id field.
 	whatsapp.DefaultWaID = whatsappDescWaID.Default.(string)
+	// whatsappDescWaName is the schema descriptor for wa_name field.
+	whatsappDescWaName := whatsappFields[1].Descriptor()
+	// whatsapp.DefaultWaName holds the default value on creation for the wa_name field.
+	whatsapp.DefaultWaName = whatsappDescWaName.Default.(string)
 	// whatsappDescCallback is the schema descriptor for callback field.
-	whatsappDescCallback := whatsappFields[1].Descriptor()
+	whatsappDescCallback := whatsappFields[2].Descriptor()
 	// whatsapp.DefaultCallback holds the default value on creation for the callback field.
 	whatsapp.DefaultCallback = whatsappDescCallback.Default.(string)
 	// whatsappDescAgentID is the schema descriptor for agent_id field.
-	whatsappDescAgentID := whatsappFields[2].Descriptor()
+	whatsappDescAgentID := whatsappFields[3].Descriptor()
 	// whatsapp.DefaultAgentID holds the default value on creation for the agent_id field.
 	whatsapp.DefaultAgentID = whatsappDescAgentID.Default.(uint64)
 	// whatsappDescAccount is the schema descriptor for account field.
-	whatsappDescAccount := whatsappFields[3].Descriptor()
+	whatsappDescAccount := whatsappFields[4].Descriptor()
 	// whatsapp.DefaultAccount holds the default value on creation for the account field.
 	whatsapp.DefaultAccount = whatsappDescAccount.Default.(string)
 	// whatsappDescCc is the schema descriptor for cc field.
-	whatsappDescCc := whatsappFields[4].Descriptor()
+	whatsappDescCc := whatsappFields[5].Descriptor()
 	// whatsapp.DefaultCc holds the default value on creation for the cc field.
 	whatsapp.DefaultCc = whatsappDescCc.Default.(string)
 	// whatsappDescPhone is the schema descriptor for phone field.
-	whatsappDescPhone := whatsappFields[5].Descriptor()
+	whatsappDescPhone := whatsappFields[6].Descriptor()
 	// whatsapp.DefaultPhone holds the default value on creation for the phone field.
 	whatsapp.DefaultPhone = whatsappDescPhone.Default.(string)
 	// whatsappDescPhoneName is the schema descriptor for phone_name field.
-	whatsappDescPhoneName := whatsappFields[6].Descriptor()
+	whatsappDescPhoneName := whatsappFields[7].Descriptor()
 	// whatsapp.DefaultPhoneName holds the default value on creation for the phone_name field.
 	whatsapp.DefaultPhoneName = whatsappDescPhoneName.Default.(string)
 	// whatsappDescPhoneStatus is the schema descriptor for phone_status field.
-	whatsappDescPhoneStatus := whatsappFields[7].Descriptor()
+	whatsappDescPhoneStatus := whatsappFields[8].Descriptor()
 	// whatsapp.DefaultPhoneStatus holds the default value on creation for the phone_status field.
 	whatsapp.DefaultPhoneStatus = whatsappDescPhoneStatus.Default.(int8)
 	// whatsappDescOrganizationID is the schema descriptor for organization_id field.
-	whatsappDescOrganizationID := whatsappFields[8].Descriptor()
+	whatsappDescOrganizationID := whatsappFields[9].Descriptor()
 	// whatsapp.DefaultOrganizationID holds the default value on creation for the organization_id field.
 	whatsapp.DefaultOrganizationID = whatsappDescOrganizationID.Default.(uint64)
 	// whatsappDescAPIBase is the schema descriptor for api_base field.
-	whatsappDescAPIBase := whatsappFields[9].Descriptor()
+	whatsappDescAPIBase := whatsappFields[10].Descriptor()
 	// whatsapp.DefaultAPIBase holds the default value on creation for the api_base field.
 	whatsapp.DefaultAPIBase = whatsappDescAPIBase.Default.(string)
 	// whatsappDescAPIKey is the schema descriptor for api_key field.
-	whatsappDescAPIKey := whatsappFields[10].Descriptor()
+	whatsappDescAPIKey := whatsappFields[11].Descriptor()
 	// whatsapp.DefaultAPIKey holds the default value on creation for the api_key field.
 	whatsapp.DefaultAPIKey = whatsappDescAPIKey.Default.(string)
 	whatsappchannelMixin := schema.WhatsappChannel{}.Mixin()

+ 1 - 0
ent/schema/whatsapp.go

@@ -18,6 +18,7 @@ type Whatsapp struct {
 func (Whatsapp) Fields() []ent.Field {
 	return []ent.Field{
 		field.String("wa_id").Optional().Default("").Comment("通道ID"),
+		field.String("wa_name").Optional().Default("").Comment("通道名"),
 		field.String("callback").Optional().Default("").Comment("回调地址"),
 		field.Uint64("agent_id").Default(0).Comment("AI角色ID"),
 		field.String("account").Optional().Default("").Comment("账号"),

+ 24 - 0
ent/set_not_nil.go

@@ -7856,6 +7856,30 @@ func (w *WhatsappCreate) SetNotNilWaID(value *string) *WhatsappCreate {
 }
 
 // set field if value's pointer is not nil.
+func (w *WhatsappUpdate) SetNotNilWaName(value *string) *WhatsappUpdate {
+	if value != nil {
+		return w.SetWaName(*value)
+	}
+	return w
+}
+
+// set field if value's pointer is not nil.
+func (w *WhatsappUpdateOne) SetNotNilWaName(value *string) *WhatsappUpdateOne {
+	if value != nil {
+		return w.SetWaName(*value)
+	}
+	return w
+}
+
+// set field if value's pointer is not nil.
+func (w *WhatsappCreate) SetNotNilWaName(value *string) *WhatsappCreate {
+	if value != nil {
+		return w.SetWaName(*value)
+	}
+	return w
+}
+
+// set field if value's pointer is not nil.
 func (w *WhatsappUpdate) SetNotNilCallback(value *string) *WhatsappUpdate {
 	if value != nil {
 		return w.SetCallback(*value)

+ 12 - 1
ent/whatsapp.go

@@ -29,6 +29,8 @@ type Whatsapp struct {
 	DeletedAt time.Time `json:"deleted_at,omitempty"`
 	// 通道ID
 	WaID string `json:"wa_id,omitempty"`
+	// 通道名
+	WaName string `json:"wa_name,omitempty"`
 	// 回调地址
 	Callback string `json:"callback,omitempty"`
 	// AI角色ID
@@ -92,7 +94,7 @@ func (*Whatsapp) scanValues(columns []string) ([]any, error) {
 			values[i] = new([]byte)
 		case whatsapp.FieldID, whatsapp.FieldStatus, whatsapp.FieldAgentID, whatsapp.FieldPhoneStatus, whatsapp.FieldOrganizationID:
 			values[i] = new(sql.NullInt64)
-		case whatsapp.FieldWaID, whatsapp.FieldCallback, whatsapp.FieldAccount, whatsapp.FieldCc, whatsapp.FieldPhone, whatsapp.FieldPhoneName, whatsapp.FieldAPIBase, whatsapp.FieldAPIKey:
+		case whatsapp.FieldWaID, whatsapp.FieldWaName, whatsapp.FieldCallback, whatsapp.FieldAccount, whatsapp.FieldCc, whatsapp.FieldPhone, whatsapp.FieldPhoneName, whatsapp.FieldAPIBase, whatsapp.FieldAPIKey:
 			values[i] = new(sql.NullString)
 		case whatsapp.FieldCreatedAt, whatsapp.FieldUpdatedAt, whatsapp.FieldDeletedAt:
 			values[i] = new(sql.NullTime)
@@ -147,6 +149,12 @@ func (w *Whatsapp) assignValues(columns []string, values []any) error {
 			} else if value.Valid {
 				w.WaID = value.String
 			}
+		case whatsapp.FieldWaName:
+			if value, ok := values[i].(*sql.NullString); !ok {
+				return fmt.Errorf("unexpected type %T for field wa_name", values[i])
+			} else if value.Valid {
+				w.WaName = value.String
+			}
 		case whatsapp.FieldCallback:
 			if value, ok := values[i].(*sql.NullString); !ok {
 				return fmt.Errorf("unexpected type %T for field callback", values[i])
@@ -295,6 +303,9 @@ func (w *Whatsapp) String() string {
 	builder.WriteString("wa_id=")
 	builder.WriteString(w.WaID)
 	builder.WriteString(", ")
+	builder.WriteString("wa_name=")
+	builder.WriteString(w.WaName)
+	builder.WriteString(", ")
 	builder.WriteString("callback=")
 	builder.WriteString(w.Callback)
 	builder.WriteString(", ")

+ 10 - 0
ent/whatsapp/whatsapp.go

@@ -25,6 +25,8 @@ const (
 	FieldDeletedAt = "deleted_at"
 	// FieldWaID holds the string denoting the wa_id field in the database.
 	FieldWaID = "wa_id"
+	// FieldWaName holds the string denoting the wa_name field in the database.
+	FieldWaName = "wa_name"
 	// FieldCallback holds the string denoting the callback field in the database.
 	FieldCallback = "callback"
 	// FieldAgentID holds the string denoting the agent_id field in the database.
@@ -74,6 +76,7 @@ var Columns = []string{
 	FieldStatus,
 	FieldDeletedAt,
 	FieldWaID,
+	FieldWaName,
 	FieldCallback,
 	FieldAgentID,
 	FieldAccount,
@@ -118,6 +121,8 @@ var (
 	DefaultStatus uint8
 	// DefaultWaID holds the default value on creation for the "wa_id" field.
 	DefaultWaID string
+	// DefaultWaName holds the default value on creation for the "wa_name" field.
+	DefaultWaName string
 	// DefaultCallback holds the default value on creation for the "callback" field.
 	DefaultCallback string
 	// DefaultAgentID holds the default value on creation for the "agent_id" field.
@@ -173,6 +178,11 @@ func ByWaID(opts ...sql.OrderTermOption) OrderOption {
 	return sql.OrderByField(FieldWaID, opts...).ToFunc()
 }
 
+// ByWaName orders the results by the wa_name field.
+func ByWaName(opts ...sql.OrderTermOption) OrderOption {
+	return sql.OrderByField(FieldWaName, opts...).ToFunc()
+}
+
 // ByCallback orders the results by the callback field.
 func ByCallback(opts ...sql.OrderTermOption) OrderOption {
 	return sql.OrderByField(FieldCallback, opts...).ToFunc()

+ 80 - 0
ent/whatsapp/where.go

@@ -80,6 +80,11 @@ func WaID(v string) predicate.Whatsapp {
 	return predicate.Whatsapp(sql.FieldEQ(FieldWaID, v))
 }
 
+// WaName applies equality check predicate on the "wa_name" field. It's identical to WaNameEQ.
+func WaName(v string) predicate.Whatsapp {
+	return predicate.Whatsapp(sql.FieldEQ(FieldWaName, v))
+}
+
 // Callback applies equality check predicate on the "callback" field. It's identical to CallbackEQ.
 func Callback(v string) predicate.Whatsapp {
 	return predicate.Whatsapp(sql.FieldEQ(FieldCallback, v))
@@ -385,6 +390,81 @@ func WaIDContainsFold(v string) predicate.Whatsapp {
 	return predicate.Whatsapp(sql.FieldContainsFold(FieldWaID, v))
 }
 
+// WaNameEQ applies the EQ predicate on the "wa_name" field.
+func WaNameEQ(v string) predicate.Whatsapp {
+	return predicate.Whatsapp(sql.FieldEQ(FieldWaName, v))
+}
+
+// WaNameNEQ applies the NEQ predicate on the "wa_name" field.
+func WaNameNEQ(v string) predicate.Whatsapp {
+	return predicate.Whatsapp(sql.FieldNEQ(FieldWaName, v))
+}
+
+// WaNameIn applies the In predicate on the "wa_name" field.
+func WaNameIn(vs ...string) predicate.Whatsapp {
+	return predicate.Whatsapp(sql.FieldIn(FieldWaName, vs...))
+}
+
+// WaNameNotIn applies the NotIn predicate on the "wa_name" field.
+func WaNameNotIn(vs ...string) predicate.Whatsapp {
+	return predicate.Whatsapp(sql.FieldNotIn(FieldWaName, vs...))
+}
+
+// WaNameGT applies the GT predicate on the "wa_name" field.
+func WaNameGT(v string) predicate.Whatsapp {
+	return predicate.Whatsapp(sql.FieldGT(FieldWaName, v))
+}
+
+// WaNameGTE applies the GTE predicate on the "wa_name" field.
+func WaNameGTE(v string) predicate.Whatsapp {
+	return predicate.Whatsapp(sql.FieldGTE(FieldWaName, v))
+}
+
+// WaNameLT applies the LT predicate on the "wa_name" field.
+func WaNameLT(v string) predicate.Whatsapp {
+	return predicate.Whatsapp(sql.FieldLT(FieldWaName, v))
+}
+
+// WaNameLTE applies the LTE predicate on the "wa_name" field.
+func WaNameLTE(v string) predicate.Whatsapp {
+	return predicate.Whatsapp(sql.FieldLTE(FieldWaName, v))
+}
+
+// WaNameContains applies the Contains predicate on the "wa_name" field.
+func WaNameContains(v string) predicate.Whatsapp {
+	return predicate.Whatsapp(sql.FieldContains(FieldWaName, v))
+}
+
+// WaNameHasPrefix applies the HasPrefix predicate on the "wa_name" field.
+func WaNameHasPrefix(v string) predicate.Whatsapp {
+	return predicate.Whatsapp(sql.FieldHasPrefix(FieldWaName, v))
+}
+
+// WaNameHasSuffix applies the HasSuffix predicate on the "wa_name" field.
+func WaNameHasSuffix(v string) predicate.Whatsapp {
+	return predicate.Whatsapp(sql.FieldHasSuffix(FieldWaName, v))
+}
+
+// WaNameIsNil applies the IsNil predicate on the "wa_name" field.
+func WaNameIsNil() predicate.Whatsapp {
+	return predicate.Whatsapp(sql.FieldIsNull(FieldWaName))
+}
+
+// WaNameNotNil applies the NotNil predicate on the "wa_name" field.
+func WaNameNotNil() predicate.Whatsapp {
+	return predicate.Whatsapp(sql.FieldNotNull(FieldWaName))
+}
+
+// WaNameEqualFold applies the EqualFold predicate on the "wa_name" field.
+func WaNameEqualFold(v string) predicate.Whatsapp {
+	return predicate.Whatsapp(sql.FieldEqualFold(FieldWaName, v))
+}
+
+// WaNameContainsFold applies the ContainsFold predicate on the "wa_name" field.
+func WaNameContainsFold(v string) predicate.Whatsapp {
+	return predicate.Whatsapp(sql.FieldContainsFold(FieldWaName, v))
+}
+
 // CallbackEQ applies the EQ predicate on the "callback" field.
 func CallbackEQ(v string) predicate.Whatsapp {
 	return predicate.Whatsapp(sql.FieldEQ(FieldCallback, v))

+ 82 - 0
ent/whatsapp_create.go

@@ -93,6 +93,20 @@ func (wc *WhatsappCreate) SetNillableWaID(s *string) *WhatsappCreate {
 	return wc
 }
 
+// SetWaName sets the "wa_name" field.
+func (wc *WhatsappCreate) SetWaName(s string) *WhatsappCreate {
+	wc.mutation.SetWaName(s)
+	return wc
+}
+
+// SetNillableWaName sets the "wa_name" field if the given value is not nil.
+func (wc *WhatsappCreate) SetNillableWaName(s *string) *WhatsappCreate {
+	if s != nil {
+		wc.SetWaName(*s)
+	}
+	return wc
+}
+
 // SetCallback sets the "callback" field.
 func (wc *WhatsappCreate) SetCallback(s string) *WhatsappCreate {
 	wc.mutation.SetCallback(s)
@@ -327,6 +341,10 @@ func (wc *WhatsappCreate) defaults() error {
 		v := whatsapp.DefaultWaID
 		wc.mutation.SetWaID(v)
 	}
+	if _, ok := wc.mutation.WaName(); !ok {
+		v := whatsapp.DefaultWaName
+		wc.mutation.SetWaName(v)
+	}
 	if _, ok := wc.mutation.Callback(); !ok {
 		v := whatsapp.DefaultCallback
 		wc.mutation.SetCallback(v)
@@ -449,6 +467,10 @@ func (wc *WhatsappCreate) createSpec() (*Whatsapp, *sqlgraph.CreateSpec) {
 		_spec.SetField(whatsapp.FieldWaID, field.TypeString, value)
 		_node.WaID = value
 	}
+	if value, ok := wc.mutation.WaName(); ok {
+		_spec.SetField(whatsapp.FieldWaName, field.TypeString, value)
+		_node.WaName = value
+	}
 	if value, ok := wc.mutation.Callback(); ok {
 		_spec.SetField(whatsapp.FieldCallback, field.TypeString, value)
 		_node.Callback = value
@@ -642,6 +664,24 @@ func (u *WhatsappUpsert) ClearWaID() *WhatsappUpsert {
 	return u
 }
 
+// SetWaName sets the "wa_name" field.
+func (u *WhatsappUpsert) SetWaName(v string) *WhatsappUpsert {
+	u.Set(whatsapp.FieldWaName, v)
+	return u
+}
+
+// UpdateWaName sets the "wa_name" field to the value that was provided on create.
+func (u *WhatsappUpsert) UpdateWaName() *WhatsappUpsert {
+	u.SetExcluded(whatsapp.FieldWaName)
+	return u
+}
+
+// ClearWaName clears the value of the "wa_name" field.
+func (u *WhatsappUpsert) ClearWaName() *WhatsappUpsert {
+	u.SetNull(whatsapp.FieldWaName)
+	return u
+}
+
 // SetCallback sets the "callback" field.
 func (u *WhatsappUpsert) SetCallback(v string) *WhatsappUpsert {
 	u.Set(whatsapp.FieldCallback, v)
@@ -1011,6 +1051,27 @@ func (u *WhatsappUpsertOne) ClearWaID() *WhatsappUpsertOne {
 	})
 }
 
+// SetWaName sets the "wa_name" field.
+func (u *WhatsappUpsertOne) SetWaName(v string) *WhatsappUpsertOne {
+	return u.Update(func(s *WhatsappUpsert) {
+		s.SetWaName(v)
+	})
+}
+
+// UpdateWaName sets the "wa_name" field to the value that was provided on create.
+func (u *WhatsappUpsertOne) UpdateWaName() *WhatsappUpsertOne {
+	return u.Update(func(s *WhatsappUpsert) {
+		s.UpdateWaName()
+	})
+}
+
+// ClearWaName clears the value of the "wa_name" field.
+func (u *WhatsappUpsertOne) ClearWaName() *WhatsappUpsertOne {
+	return u.Update(func(s *WhatsappUpsert) {
+		s.ClearWaName()
+	})
+}
+
 // SetCallback sets the "callback" field.
 func (u *WhatsappUpsertOne) SetCallback(v string) *WhatsappUpsertOne {
 	return u.Update(func(s *WhatsappUpsert) {
@@ -1585,6 +1646,27 @@ func (u *WhatsappUpsertBulk) ClearWaID() *WhatsappUpsertBulk {
 	})
 }
 
+// SetWaName sets the "wa_name" field.
+func (u *WhatsappUpsertBulk) SetWaName(v string) *WhatsappUpsertBulk {
+	return u.Update(func(s *WhatsappUpsert) {
+		s.SetWaName(v)
+	})
+}
+
+// UpdateWaName sets the "wa_name" field to the value that was provided on create.
+func (u *WhatsappUpsertBulk) UpdateWaName() *WhatsappUpsertBulk {
+	return u.Update(func(s *WhatsappUpsert) {
+		s.UpdateWaName()
+	})
+}
+
+// ClearWaName clears the value of the "wa_name" field.
+func (u *WhatsappUpsertBulk) ClearWaName() *WhatsappUpsertBulk {
+	return u.Update(func(s *WhatsappUpsert) {
+		s.ClearWaName()
+	})
+}
+
 // SetCallback sets the "callback" field.
 func (u *WhatsappUpsertBulk) SetCallback(v string) *WhatsappUpsertBulk {
 	return u.Update(func(s *WhatsappUpsert) {

+ 52 - 0
ent/whatsapp_update.go

@@ -103,6 +103,26 @@ func (wu *WhatsappUpdate) ClearWaID() *WhatsappUpdate {
 	return wu
 }
 
+// SetWaName sets the "wa_name" field.
+func (wu *WhatsappUpdate) SetWaName(s string) *WhatsappUpdate {
+	wu.mutation.SetWaName(s)
+	return wu
+}
+
+// SetNillableWaName sets the "wa_name" field if the given value is not nil.
+func (wu *WhatsappUpdate) SetNillableWaName(s *string) *WhatsappUpdate {
+	if s != nil {
+		wu.SetWaName(*s)
+	}
+	return wu
+}
+
+// ClearWaName clears the value of the "wa_name" field.
+func (wu *WhatsappUpdate) ClearWaName() *WhatsappUpdate {
+	wu.mutation.ClearWaName()
+	return wu
+}
+
 // SetCallback sets the "callback" field.
 func (wu *WhatsappUpdate) SetCallback(s string) *WhatsappUpdate {
 	wu.mutation.SetCallback(s)
@@ -461,6 +481,12 @@ func (wu *WhatsappUpdate) sqlSave(ctx context.Context) (n int, err error) {
 	if wu.mutation.WaIDCleared() {
 		_spec.ClearField(whatsapp.FieldWaID, field.TypeString)
 	}
+	if value, ok := wu.mutation.WaName(); ok {
+		_spec.SetField(whatsapp.FieldWaName, field.TypeString, value)
+	}
+	if wu.mutation.WaNameCleared() {
+		_spec.ClearField(whatsapp.FieldWaName, field.TypeString)
+	}
 	if value, ok := wu.mutation.Callback(); ok {
 		_spec.SetField(whatsapp.FieldCallback, field.TypeString, value)
 	}
@@ -675,6 +701,26 @@ func (wuo *WhatsappUpdateOne) ClearWaID() *WhatsappUpdateOne {
 	return wuo
 }
 
+// SetWaName sets the "wa_name" field.
+func (wuo *WhatsappUpdateOne) SetWaName(s string) *WhatsappUpdateOne {
+	wuo.mutation.SetWaName(s)
+	return wuo
+}
+
+// SetNillableWaName sets the "wa_name" field if the given value is not nil.
+func (wuo *WhatsappUpdateOne) SetNillableWaName(s *string) *WhatsappUpdateOne {
+	if s != nil {
+		wuo.SetWaName(*s)
+	}
+	return wuo
+}
+
+// ClearWaName clears the value of the "wa_name" field.
+func (wuo *WhatsappUpdateOne) ClearWaName() *WhatsappUpdateOne {
+	wuo.mutation.ClearWaName()
+	return wuo
+}
+
 // SetCallback sets the "callback" field.
 func (wuo *WhatsappUpdateOne) SetCallback(s string) *WhatsappUpdateOne {
 	wuo.mutation.SetCallback(s)
@@ -1063,6 +1109,12 @@ func (wuo *WhatsappUpdateOne) sqlSave(ctx context.Context) (_node *Whatsapp, err
 	if wuo.mutation.WaIDCleared() {
 		_spec.ClearField(whatsapp.FieldWaID, field.TypeString)
 	}
+	if value, ok := wuo.mutation.WaName(); ok {
+		_spec.SetField(whatsapp.FieldWaName, field.TypeString, value)
+	}
+	if wuo.mutation.WaNameCleared() {
+		_spec.ClearField(whatsapp.FieldWaName, field.TypeString)
+	}
 	if value, ok := wuo.mutation.Callback(); ok {
 		_spec.SetField(whatsapp.FieldCallback, field.TypeString, value)
 	}

+ 1 - 0
internal/logic/whatsapp/create_whatsapp_logic.go

@@ -41,6 +41,7 @@ func (l *CreateWhatsappLogic) CreateWhatsapp(req *types.WhatsappInfo) (*types.Ba
 		if err != nil && ent.IsNotFound(err) {
 			_, err = l.svcCtx.DB.Whatsapp.Create().
 				SetNotNilWaID(req.WaId).
+				SetNotNilWaName(req.WaName).
 				SetNotNilCallback(req.Callback).
 				SetNotNilAccount(req.Account).
 				SetNotNilPhone(req.Phone).

+ 1 - 0
internal/logic/whatsapp/get_whatsapp_list_logic.go

@@ -111,6 +111,7 @@ func (l *GetWhatsappListLogic) GetWhatsappList(req *types.WhatsappListReq) (*typ
 					UpdatedAt: pointy.GetPointer(v.UpdatedAt.UnixMilli()),
 				},
 				WaId:             &v.WaID,
+				WaName:           &v.WaName,
 				Callback:         &v.Callback,
 				Account:          &v.Account,
 				Phone:            &v.Phone,

+ 1 - 0
internal/types/types.go

@@ -3416,6 +3416,7 @@ type WhatsappInfo struct {
 	// Status 1: normal 2: ban | 状态 1 正常 2 禁用
 	Status *uint8  `json:"status,optional"`
 	WaId   *string `json:"waId,optional"`
+	WaName *string `json:"waName,optional"`
 	// 回调地址
 	Callback *string `json:"callback,optional"`
 	// 模式ID