Browse Source

fix:创建whatsapp号码

jimmyyem 1 month ago
parent
commit
cf7729248e

+ 2 - 1
desc/wechat/whatsapp.api

@@ -10,7 +10,7 @@ type (
         // Status 1: normal 2: ban | 状态 1 正常 2 禁用 
         Status  *uint8 `json:"status,optional"`
 
-        WaId  *uint64 `json:"waId,optional"`
+        WaId  *string `json:"waId,optional"`
 
         // 回调地址 
         Callback  *string `json:"callback,optional"`
@@ -24,6 +24,7 @@ type (
 
         // 手机号
         Phone  *string `json:"phone,optional"`
+		Cc *string `json:"cc,optional"`
 
 		// 号码名称
 		PhoneName  *string `json:"phoneName,optional"`

+ 1 - 1
desc/wechat/whatsapp_channel.api

@@ -15,7 +15,7 @@ type (
         Sk  *string `json:"sk,optional"`
 
         // 通道ID 
-        WaId  *uint64 `json:"waId,optional"`
+        WaId  *string `json:"waId,optional"`
 
         // 通道名 
         WaName  *string `json:"waName,optional"`

+ 4 - 3
ent/migrate/schema.go

@@ -1040,9 +1040,10 @@ var (
 		{Name: "updated_at", Type: field.TypeTime, Comment: "Update Time | 修改日期"},
 		{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.TypeUint64, Nullable: true, Default: 0},
+		{Name: "wa_id", 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: ""},
 		{Name: "phone", Type: field.TypeString, Default: ""},
 		{Name: "phone_name", Type: field.TypeString, Default: ""},
 		{Name: "phone_status", Type: field.TypeInt8, Default: 0},
@@ -1063,7 +1064,7 @@ var (
 		ForeignKeys: []*schema.ForeignKey{
 			{
 				Symbol:     "whatsapp_agent_wa_agent",
-				Columns:    []*schema.Column{WhatsappColumns[18]},
+				Columns:    []*schema.Column{WhatsappColumns[19]},
 				RefColumns: []*schema.Column{AgentColumns[0]},
 				OnDelete:   schema.NoAction,
 			},
@@ -1078,7 +1079,7 @@ var (
 		{Name: "deleted_at", Type: field.TypeTime, Nullable: true, Comment: "Delete Time | 删除日期"},
 		{Name: "ak", Type: field.TypeString, Nullable: true, Default: ""},
 		{Name: "sk", Type: field.TypeString, Default: ""},
-		{Name: "wa_id", Type: field.TypeUint64, Nullable: true, Default: 0},
+		{Name: "wa_id", Type: field.TypeString, Nullable: true, Default: ""},
 		{Name: "wa_name", Type: field.TypeString, Nullable: true, Default: ""},
 		{Name: "waba_id", Type: field.TypeUint64, Default: 0},
 		{Name: "business_id", Type: field.TypeUint64, Default: 0},

+ 67 - 81
ent/mutation.go

@@ -36959,10 +36959,10 @@ type WhatsappMutation struct {
 	status                 *uint8
 	addstatus              *int8
 	deleted_at             *time.Time
-	wa_id                  *uint64
-	addwa_id               *int64
+	wa_id                  *string
 	callback               *string
 	account                *string
+	cc                     *string
 	phone                  *string
 	phone_name             *string
 	phone_status           *int8
@@ -37283,13 +37283,12 @@ func (m *WhatsappMutation) ResetDeletedAt() {
 }
 
 // SetWaID sets the "wa_id" field.
-func (m *WhatsappMutation) SetWaID(u uint64) {
-	m.wa_id = &u
-	m.addwa_id = nil
+func (m *WhatsappMutation) SetWaID(s string) {
+	m.wa_id = &s
 }
 
 // WaID returns the value of the "wa_id" field in the mutation.
-func (m *WhatsappMutation) WaID() (r uint64, exists bool) {
+func (m *WhatsappMutation) WaID() (r string, exists bool) {
 	v := m.wa_id
 	if v == nil {
 		return
@@ -37300,7 +37299,7 @@ func (m *WhatsappMutation) WaID() (r uint64, exists bool) {
 // OldWaID returns the old "wa_id" 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) OldWaID(ctx context.Context) (v uint64, err error) {
+func (m *WhatsappMutation) OldWaID(ctx context.Context) (v string, err error) {
 	if !m.op.Is(OpUpdateOne) {
 		return v, errors.New("OldWaID is only allowed on UpdateOne operations")
 	}
@@ -37314,28 +37313,9 @@ func (m *WhatsappMutation) OldWaID(ctx context.Context) (v uint64, err error) {
 	return oldValue.WaID, nil
 }
 
-// AddWaID adds u to the "wa_id" field.
-func (m *WhatsappMutation) AddWaID(u int64) {
-	if m.addwa_id != nil {
-		*m.addwa_id += u
-	} else {
-		m.addwa_id = &u
-	}
-}
-
-// AddedWaID returns the value that was added to the "wa_id" field in this mutation.
-func (m *WhatsappMutation) AddedWaID() (r int64, exists bool) {
-	v := m.addwa_id
-	if v == nil {
-		return
-	}
-	return *v, true
-}
-
 // ClearWaID clears the value of the "wa_id" field.
 func (m *WhatsappMutation) ClearWaID() {
 	m.wa_id = nil
-	m.addwa_id = nil
 	m.clearedFields[whatsapp.FieldWaID] = struct{}{}
 }
 
@@ -37348,7 +37328,6 @@ func (m *WhatsappMutation) WaIDCleared() bool {
 // ResetWaID resets all changes to the "wa_id" field.
 func (m *WhatsappMutation) ResetWaID() {
 	m.wa_id = nil
-	m.addwa_id = nil
 	delete(m.clearedFields, whatsapp.FieldWaID)
 }
 
@@ -37486,6 +37465,42 @@ func (m *WhatsappMutation) ResetAccount() {
 	delete(m.clearedFields, whatsapp.FieldAccount)
 }
 
+// SetCc sets the "cc" field.
+func (m *WhatsappMutation) SetCc(s string) {
+	m.cc = &s
+}
+
+// Cc returns the value of the "cc" field in the mutation.
+func (m *WhatsappMutation) Cc() (r string, exists bool) {
+	v := m.cc
+	if v == nil {
+		return
+	}
+	return *v, true
+}
+
+// OldCc returns the old "cc" 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) OldCc(ctx context.Context) (v string, err error) {
+	if !m.op.Is(OpUpdateOne) {
+		return v, errors.New("OldCc is only allowed on UpdateOne operations")
+	}
+	if m.id == nil || m.oldValue == nil {
+		return v, errors.New("OldCc requires an ID field in the mutation")
+	}
+	oldValue, err := m.oldValue(ctx)
+	if err != nil {
+		return v, fmt.Errorf("querying old value for OldCc: %w", err)
+	}
+	return oldValue.Cc, nil
+}
+
+// ResetCc resets all changes to the "cc" field.
+func (m *WhatsappMutation) ResetCc() {
+	m.cc = nil
+}
+
 // SetPhone sets the "phone" field.
 func (m *WhatsappMutation) SetPhone(s string) {
 	m.phone = &s
@@ -38103,7 +38118,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, 18)
+	fields := make([]string, 0, 19)
 	if m.created_at != nil {
 		fields = append(fields, whatsapp.FieldCreatedAt)
 	}
@@ -38128,6 +38143,9 @@ func (m *WhatsappMutation) Fields() []string {
 	if m.account != nil {
 		fields = append(fields, whatsapp.FieldAccount)
 	}
+	if m.cc != nil {
+		fields = append(fields, whatsapp.FieldCc)
+	}
 	if m.phone != nil {
 		fields = append(fields, whatsapp.FieldPhone)
 	}
@@ -38182,6 +38200,8 @@ func (m *WhatsappMutation) Field(name string) (ent.Value, bool) {
 		return m.AgentID()
 	case whatsapp.FieldAccount:
 		return m.Account()
+	case whatsapp.FieldCc:
+		return m.Cc()
 	case whatsapp.FieldPhone:
 		return m.Phone()
 	case whatsapp.FieldPhoneName:
@@ -38227,6 +38247,8 @@ func (m *WhatsappMutation) OldField(ctx context.Context, name string) (ent.Value
 		return m.OldAgentID(ctx)
 	case whatsapp.FieldAccount:
 		return m.OldAccount(ctx)
+	case whatsapp.FieldCc:
+		return m.OldCc(ctx)
 	case whatsapp.FieldPhone:
 		return m.OldPhone(ctx)
 	case whatsapp.FieldPhoneName:
@@ -38285,7 +38307,7 @@ func (m *WhatsappMutation) SetField(name string, value ent.Value) error {
 		m.SetDeletedAt(v)
 		return nil
 	case whatsapp.FieldWaID:
-		v, ok := value.(uint64)
+		v, ok := value.(string)
 		if !ok {
 			return fmt.Errorf("unexpected type %T for field %s", value, name)
 		}
@@ -38312,6 +38334,13 @@ func (m *WhatsappMutation) SetField(name string, value ent.Value) error {
 		}
 		m.SetAccount(v)
 		return nil
+	case whatsapp.FieldCc:
+		v, ok := value.(string)
+		if !ok {
+			return fmt.Errorf("unexpected type %T for field %s", value, name)
+		}
+		m.SetCc(v)
+		return nil
 	case whatsapp.FieldPhone:
 		v, ok := value.(string)
 		if !ok {
@@ -38393,9 +38422,6 @@ func (m *WhatsappMutation) AddedFields() []string {
 	if m.addstatus != nil {
 		fields = append(fields, whatsapp.FieldStatus)
 	}
-	if m.addwa_id != nil {
-		fields = append(fields, whatsapp.FieldWaID)
-	}
 	if m.addphone_status != nil {
 		fields = append(fields, whatsapp.FieldPhoneStatus)
 	}
@@ -38412,8 +38438,6 @@ func (m *WhatsappMutation) AddedField(name string) (ent.Value, bool) {
 	switch name {
 	case whatsapp.FieldStatus:
 		return m.AddedStatus()
-	case whatsapp.FieldWaID:
-		return m.AddedWaID()
 	case whatsapp.FieldPhoneStatus:
 		return m.AddedPhoneStatus()
 	case whatsapp.FieldOrganizationID:
@@ -38434,13 +38458,6 @@ func (m *WhatsappMutation) AddField(name string, value ent.Value) error {
 		}
 		m.AddStatus(v)
 		return nil
-	case whatsapp.FieldWaID:
-		v, ok := value.(int64)
-		if !ok {
-			return fmt.Errorf("unexpected type %T for field %s", value, name)
-		}
-		m.AddWaID(v)
-		return nil
 	case whatsapp.FieldPhoneStatus:
 		v, ok := value.(int8)
 		if !ok {
@@ -38581,6 +38598,9 @@ func (m *WhatsappMutation) ResetField(name string) error {
 	case whatsapp.FieldAccount:
 		m.ResetAccount()
 		return nil
+	case whatsapp.FieldCc:
+		m.ResetCc()
+		return nil
 	case whatsapp.FieldPhone:
 		m.ResetPhone()
 		return nil
@@ -38702,8 +38722,7 @@ type WhatsappChannelMutation struct {
 	deleted_at         *time.Time
 	ak                 *string
 	sk                 *string
-	wa_id              *uint64
-	addwa_id           *int64
+	wa_id              *string
 	wa_name            *string
 	waba_id            *uint64
 	addwaba_id         *int64
@@ -39099,13 +39118,12 @@ func (m *WhatsappChannelMutation) ResetSk() {
 }
 
 // SetWaID sets the "wa_id" field.
-func (m *WhatsappChannelMutation) SetWaID(u uint64) {
-	m.wa_id = &u
-	m.addwa_id = nil
+func (m *WhatsappChannelMutation) SetWaID(s string) {
+	m.wa_id = &s
 }
 
 // WaID returns the value of the "wa_id" field in the mutation.
-func (m *WhatsappChannelMutation) WaID() (r uint64, exists bool) {
+func (m *WhatsappChannelMutation) WaID() (r string, exists bool) {
 	v := m.wa_id
 	if v == nil {
 		return
@@ -39116,7 +39134,7 @@ func (m *WhatsappChannelMutation) WaID() (r uint64, exists bool) {
 // OldWaID returns the old "wa_id" field's value of the WhatsappChannel entity.
 // If the WhatsappChannel 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 *WhatsappChannelMutation) OldWaID(ctx context.Context) (v uint64, err error) {
+func (m *WhatsappChannelMutation) OldWaID(ctx context.Context) (v string, err error) {
 	if !m.op.Is(OpUpdateOne) {
 		return v, errors.New("OldWaID is only allowed on UpdateOne operations")
 	}
@@ -39130,28 +39148,9 @@ func (m *WhatsappChannelMutation) OldWaID(ctx context.Context) (v uint64, err er
 	return oldValue.WaID, nil
 }
 
-// AddWaID adds u to the "wa_id" field.
-func (m *WhatsappChannelMutation) AddWaID(u int64) {
-	if m.addwa_id != nil {
-		*m.addwa_id += u
-	} else {
-		m.addwa_id = &u
-	}
-}
-
-// AddedWaID returns the value that was added to the "wa_id" field in this mutation.
-func (m *WhatsappChannelMutation) AddedWaID() (r int64, exists bool) {
-	v := m.addwa_id
-	if v == nil {
-		return
-	}
-	return *v, true
-}
-
 // ClearWaID clears the value of the "wa_id" field.
 func (m *WhatsappChannelMutation) ClearWaID() {
 	m.wa_id = nil
-	m.addwa_id = nil
 	m.clearedFields[whatsappchannel.FieldWaID] = struct{}{}
 }
 
@@ -39164,7 +39163,6 @@ func (m *WhatsappChannelMutation) WaIDCleared() bool {
 // ResetWaID resets all changes to the "wa_id" field.
 func (m *WhatsappChannelMutation) ResetWaID() {
 	m.wa_id = nil
-	m.addwa_id = nil
 	delete(m.clearedFields, whatsappchannel.FieldWaID)
 }
 
@@ -39623,7 +39621,7 @@ func (m *WhatsappChannelMutation) SetField(name string, value ent.Value) error {
 		m.SetSk(v)
 		return nil
 	case whatsappchannel.FieldWaID:
-		v, ok := value.(uint64)
+		v, ok := value.(string)
 		if !ok {
 			return fmt.Errorf("unexpected type %T for field %s", value, name)
 		}
@@ -39675,9 +39673,6 @@ func (m *WhatsappChannelMutation) AddedFields() []string {
 	if m.addstatus != nil {
 		fields = append(fields, whatsappchannel.FieldStatus)
 	}
-	if m.addwa_id != nil {
-		fields = append(fields, whatsappchannel.FieldWaID)
-	}
 	if m.addwaba_id != nil {
 		fields = append(fields, whatsappchannel.FieldWabaID)
 	}
@@ -39697,8 +39692,6 @@ func (m *WhatsappChannelMutation) AddedField(name string) (ent.Value, bool) {
 	switch name {
 	case whatsappchannel.FieldStatus:
 		return m.AddedStatus()
-	case whatsappchannel.FieldWaID:
-		return m.AddedWaID()
 	case whatsappchannel.FieldWabaID:
 		return m.AddedWabaID()
 	case whatsappchannel.FieldBusinessID:
@@ -39721,13 +39714,6 @@ func (m *WhatsappChannelMutation) AddField(name string, value ent.Value) error {
 		}
 		m.AddStatus(v)
 		return nil
-	case whatsappchannel.FieldWaID:
-		v, ok := value.(int64)
-		if !ok {
-			return fmt.Errorf("unexpected type %T for field %s", value, name)
-		}
-		m.AddWaID(v)
-		return nil
 	case whatsappchannel.FieldWabaID:
 		v, ok := value.(int64)
 		if !ok {

+ 12 - 8
ent/runtime/runtime.go

@@ -1300,7 +1300,7 @@ func init() {
 	// whatsappDescWaID is the schema descriptor for wa_id field.
 	whatsappDescWaID := whatsappFields[0].Descriptor()
 	// whatsapp.DefaultWaID holds the default value on creation for the wa_id field.
-	whatsapp.DefaultWaID = whatsappDescWaID.Default.(uint64)
+	whatsapp.DefaultWaID = whatsappDescWaID.Default.(string)
 	// whatsappDescCallback is the schema descriptor for callback field.
 	whatsappDescCallback := whatsappFields[1].Descriptor()
 	// whatsapp.DefaultCallback holds the default value on creation for the callback field.
@@ -1313,28 +1313,32 @@ func init() {
 	whatsappDescAccount := whatsappFields[3].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()
+	// 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[4].Descriptor()
+	whatsappDescPhone := whatsappFields[5].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[5].Descriptor()
+	whatsappDescPhoneName := whatsappFields[6].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[6].Descriptor()
+	whatsappDescPhoneStatus := whatsappFields[7].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[7].Descriptor()
+	whatsappDescOrganizationID := whatsappFields[8].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[8].Descriptor()
+	whatsappDescAPIBase := whatsappFields[9].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[9].Descriptor()
+	whatsappDescAPIKey := whatsappFields[10].Descriptor()
 	// whatsapp.DefaultAPIKey holds the default value on creation for the api_key field.
 	whatsapp.DefaultAPIKey = whatsappDescAPIKey.Default.(string)
 	whatsappchannelMixin := schema.WhatsappChannel{}.Mixin()
@@ -1373,7 +1377,7 @@ func init() {
 	// whatsappchannelDescWaID is the schema descriptor for wa_id field.
 	whatsappchannelDescWaID := whatsappchannelFields[2].Descriptor()
 	// whatsappchannel.DefaultWaID holds the default value on creation for the wa_id field.
-	whatsappchannel.DefaultWaID = whatsappchannelDescWaID.Default.(uint64)
+	whatsappchannel.DefaultWaID = whatsappchannelDescWaID.Default.(string)
 	// whatsappchannelDescWaName is the schema descriptor for wa_name field.
 	whatsappchannelDescWaName := whatsappchannelFields[3].Descriptor()
 	// whatsappchannel.DefaultWaName holds the default value on creation for the wa_name field.

+ 2 - 2
ent/schema/whatsapp.go

@@ -17,11 +17,11 @@ type Whatsapp struct {
 
 func (Whatsapp) Fields() []ent.Field {
 	return []ent.Field{
-		field.Uint64("wa_id").Optional().Default(0).Comment("通道ID"),
+		field.String("wa_id").Optional().Default("").Comment("通道ID"),
 		field.String("callback").Optional().Default("").Comment("回调地址"),
 		field.Uint64("agent_id").Default(0).Comment("AI角色ID"),
 		field.String("account").Optional().Default("").Comment("账号"),
-		//field.String("nickname").Default("").Comment("昵称"),
+		field.String("cc").Default("").Comment("国家区号"),
 		field.String("phone").Default("").Comment("手机号"),
 		field.String("phone_name").Default("").Comment("号码名称"),
 		field.Int8("phone_status").Default(0).Comment("号码状态"),

+ 1 - 1
ent/schema/whatsapp_channel.go

@@ -19,7 +19,7 @@ func (WhatsappChannel) Fields() []ent.Field {
 	return []ent.Field{
 		field.String("ak").Optional().Default("").Comment("ak"),
 		field.String("sk").Default("").Comment("端口号"),
-		field.Uint64("wa_id").Optional().Default(0).Comment("通道ID"),
+		field.String("wa_id").Optional().Default("").Comment("通道ID"),
 		field.String("wa_name").Optional().Default("").Comment("通道名"),
 		field.Uint64("waba_id").Default(0).Comment("WABA ID"),
 		field.Uint64("business_id").Default(0).Comment("商业平台ID"),

+ 30 - 6
ent/set_not_nil.go

@@ -7832,7 +7832,7 @@ func (w *WhatsappCreate) SetNotNilDeletedAt(value *time.Time) *WhatsappCreate {
 }
 
 // set field if value's pointer is not nil.
-func (w *WhatsappUpdate) SetNotNilWaID(value *uint64) *WhatsappUpdate {
+func (w *WhatsappUpdate) SetNotNilWaID(value *string) *WhatsappUpdate {
 	if value != nil {
 		return w.SetWaID(*value)
 	}
@@ -7840,7 +7840,7 @@ func (w *WhatsappUpdate) SetNotNilWaID(value *uint64) *WhatsappUpdate {
 }
 
 // set field if value's pointer is not nil.
-func (w *WhatsappUpdateOne) SetNotNilWaID(value *uint64) *WhatsappUpdateOne {
+func (w *WhatsappUpdateOne) SetNotNilWaID(value *string) *WhatsappUpdateOne {
 	if value != nil {
 		return w.SetWaID(*value)
 	}
@@ -7848,7 +7848,7 @@ func (w *WhatsappUpdateOne) SetNotNilWaID(value *uint64) *WhatsappUpdateOne {
 }
 
 // set field if value's pointer is not nil.
-func (w *WhatsappCreate) SetNotNilWaID(value *uint64) *WhatsappCreate {
+func (w *WhatsappCreate) SetNotNilWaID(value *string) *WhatsappCreate {
 	if value != nil {
 		return w.SetWaID(*value)
 	}
@@ -7928,6 +7928,30 @@ func (w *WhatsappCreate) SetNotNilAccount(value *string) *WhatsappCreate {
 }
 
 // set field if value's pointer is not nil.
+func (w *WhatsappUpdate) SetNotNilCc(value *string) *WhatsappUpdate {
+	if value != nil {
+		return w.SetCc(*value)
+	}
+	return w
+}
+
+// set field if value's pointer is not nil.
+func (w *WhatsappUpdateOne) SetNotNilCc(value *string) *WhatsappUpdateOne {
+	if value != nil {
+		return w.SetCc(*value)
+	}
+	return w
+}
+
+// set field if value's pointer is not nil.
+func (w *WhatsappCreate) SetNotNilCc(value *string) *WhatsappCreate {
+	if value != nil {
+		return w.SetCc(*value)
+	}
+	return w
+}
+
+// set field if value's pointer is not nil.
 func (w *WhatsappUpdate) SetNotNilPhone(value *string) *WhatsappUpdate {
 	if value != nil {
 		return w.SetPhone(*value)
@@ -8288,7 +8312,7 @@ func (wc *WhatsappChannelCreate) SetNotNilSk(value *string) *WhatsappChannelCrea
 }
 
 // set field if value's pointer is not nil.
-func (wc *WhatsappChannelUpdate) SetNotNilWaID(value *uint64) *WhatsappChannelUpdate {
+func (wc *WhatsappChannelUpdate) SetNotNilWaID(value *string) *WhatsappChannelUpdate {
 	if value != nil {
 		return wc.SetWaID(*value)
 	}
@@ -8296,7 +8320,7 @@ func (wc *WhatsappChannelUpdate) SetNotNilWaID(value *uint64) *WhatsappChannelUp
 }
 
 // set field if value's pointer is not nil.
-func (wc *WhatsappChannelUpdateOne) SetNotNilWaID(value *uint64) *WhatsappChannelUpdateOne {
+func (wc *WhatsappChannelUpdateOne) SetNotNilWaID(value *string) *WhatsappChannelUpdateOne {
 	if value != nil {
 		return wc.SetWaID(*value)
 	}
@@ -8304,7 +8328,7 @@ func (wc *WhatsappChannelUpdateOne) SetNotNilWaID(value *uint64) *WhatsappChanne
 }
 
 // set field if value's pointer is not nil.
-func (wc *WhatsappChannelCreate) SetNotNilWaID(value *uint64) *WhatsappChannelCreate {
+func (wc *WhatsappChannelCreate) SetNotNilWaID(value *string) *WhatsappChannelCreate {
 	if value != nil {
 		return wc.SetWaID(*value)
 	}

+ 17 - 6
ent/whatsapp.go

@@ -28,13 +28,15 @@ type Whatsapp struct {
 	// Delete Time | 删除日期
 	DeletedAt time.Time `json:"deleted_at,omitempty"`
 	// 通道ID
-	WaID uint64 `json:"wa_id,omitempty"`
+	WaID string `json:"wa_id,omitempty"`
 	// 回调地址
 	Callback string `json:"callback,omitempty"`
 	// AI角色ID
 	AgentID uint64 `json:"agent_id,omitempty"`
 	// 账号
 	Account string `json:"account,omitempty"`
+	// 国家区号
+	Cc string `json:"cc,omitempty"`
 	// 手机号
 	Phone string `json:"phone,omitempty"`
 	// 号码名称
@@ -88,9 +90,9 @@ func (*Whatsapp) scanValues(columns []string) ([]any, error) {
 		switch columns[i] {
 		case whatsapp.FieldAllowList, whatsapp.FieldGroupAllowList, whatsapp.FieldBlockList, whatsapp.FieldGroupBlockList:
 			values[i] = new([]byte)
-		case whatsapp.FieldID, whatsapp.FieldStatus, whatsapp.FieldWaID, whatsapp.FieldAgentID, whatsapp.FieldPhoneStatus, whatsapp.FieldOrganizationID:
+		case whatsapp.FieldID, whatsapp.FieldStatus, whatsapp.FieldAgentID, whatsapp.FieldPhoneStatus, whatsapp.FieldOrganizationID:
 			values[i] = new(sql.NullInt64)
-		case whatsapp.FieldCallback, whatsapp.FieldAccount, whatsapp.FieldPhone, whatsapp.FieldPhoneName, whatsapp.FieldAPIBase, whatsapp.FieldAPIKey:
+		case whatsapp.FieldWaID, 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)
@@ -140,10 +142,10 @@ func (w *Whatsapp) assignValues(columns []string, values []any) error {
 				w.DeletedAt = value.Time
 			}
 		case whatsapp.FieldWaID:
-			if value, ok := values[i].(*sql.NullInt64); !ok {
+			if value, ok := values[i].(*sql.NullString); !ok {
 				return fmt.Errorf("unexpected type %T for field wa_id", values[i])
 			} else if value.Valid {
-				w.WaID = uint64(value.Int64)
+				w.WaID = value.String
 			}
 		case whatsapp.FieldCallback:
 			if value, ok := values[i].(*sql.NullString); !ok {
@@ -163,6 +165,12 @@ func (w *Whatsapp) assignValues(columns []string, values []any) error {
 			} else if value.Valid {
 				w.Account = value.String
 			}
+		case whatsapp.FieldCc:
+			if value, ok := values[i].(*sql.NullString); !ok {
+				return fmt.Errorf("unexpected type %T for field cc", values[i])
+			} else if value.Valid {
+				w.Cc = value.String
+			}
 		case whatsapp.FieldPhone:
 			if value, ok := values[i].(*sql.NullString); !ok {
 				return fmt.Errorf("unexpected type %T for field phone", values[i])
@@ -285,7 +293,7 @@ func (w *Whatsapp) String() string {
 	builder.WriteString(w.DeletedAt.Format(time.ANSIC))
 	builder.WriteString(", ")
 	builder.WriteString("wa_id=")
-	builder.WriteString(fmt.Sprintf("%v", w.WaID))
+	builder.WriteString(w.WaID)
 	builder.WriteString(", ")
 	builder.WriteString("callback=")
 	builder.WriteString(w.Callback)
@@ -296,6 +304,9 @@ func (w *Whatsapp) String() string {
 	builder.WriteString("account=")
 	builder.WriteString(w.Account)
 	builder.WriteString(", ")
+	builder.WriteString("cc=")
+	builder.WriteString(w.Cc)
+	builder.WriteString(", ")
 	builder.WriteString("phone=")
 	builder.WriteString(w.Phone)
 	builder.WriteString(", ")

+ 11 - 1
ent/whatsapp/whatsapp.go

@@ -31,6 +31,8 @@ const (
 	FieldAgentID = "agent_id"
 	// FieldAccount holds the string denoting the account field in the database.
 	FieldAccount = "account"
+	// FieldCc holds the string denoting the cc field in the database.
+	FieldCc = "cc"
 	// FieldPhone holds the string denoting the phone field in the database.
 	FieldPhone = "phone"
 	// FieldPhoneName holds the string denoting the phone_name field in the database.
@@ -75,6 +77,7 @@ var Columns = []string{
 	FieldCallback,
 	FieldAgentID,
 	FieldAccount,
+	FieldCc,
 	FieldPhone,
 	FieldPhoneName,
 	FieldPhoneStatus,
@@ -114,13 +117,15 @@ var (
 	// DefaultStatus holds the default value on creation for the "status" field.
 	DefaultStatus uint8
 	// DefaultWaID holds the default value on creation for the "wa_id" field.
-	DefaultWaID uint64
+	DefaultWaID 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.
 	DefaultAgentID uint64
 	// DefaultAccount holds the default value on creation for the "account" field.
 	DefaultAccount string
+	// DefaultCc holds the default value on creation for the "cc" field.
+	DefaultCc string
 	// DefaultPhone holds the default value on creation for the "phone" field.
 	DefaultPhone string
 	// DefaultPhoneName holds the default value on creation for the "phone_name" field.
@@ -183,6 +188,11 @@ func ByAccount(opts ...sql.OrderTermOption) OrderOption {
 	return sql.OrderByField(FieldAccount, opts...).ToFunc()
 }
 
+// ByCc orders the results by the cc field.
+func ByCc(opts ...sql.OrderTermOption) OrderOption {
+	return sql.OrderByField(FieldCc, opts...).ToFunc()
+}
+
 // ByPhone orders the results by the phone field.
 func ByPhone(opts ...sql.OrderTermOption) OrderOption {
 	return sql.OrderByField(FieldPhone, opts...).ToFunc()

+ 104 - 9
ent/whatsapp/where.go

@@ -76,7 +76,7 @@ func DeletedAt(v time.Time) predicate.Whatsapp {
 }
 
 // WaID applies equality check predicate on the "wa_id" field. It's identical to WaIDEQ.
-func WaID(v uint64) predicate.Whatsapp {
+func WaID(v string) predicate.Whatsapp {
 	return predicate.Whatsapp(sql.FieldEQ(FieldWaID, v))
 }
 
@@ -95,6 +95,11 @@ func Account(v string) predicate.Whatsapp {
 	return predicate.Whatsapp(sql.FieldEQ(FieldAccount, v))
 }
 
+// Cc applies equality check predicate on the "cc" field. It's identical to CcEQ.
+func Cc(v string) predicate.Whatsapp {
+	return predicate.Whatsapp(sql.FieldEQ(FieldCc, v))
+}
+
 // Phone applies equality check predicate on the "phone" field. It's identical to PhoneEQ.
 func Phone(v string) predicate.Whatsapp {
 	return predicate.Whatsapp(sql.FieldEQ(FieldPhone, v))
@@ -306,45 +311,60 @@ func DeletedAtNotNil() predicate.Whatsapp {
 }
 
 // WaIDEQ applies the EQ predicate on the "wa_id" field.
-func WaIDEQ(v uint64) predicate.Whatsapp {
+func WaIDEQ(v string) predicate.Whatsapp {
 	return predicate.Whatsapp(sql.FieldEQ(FieldWaID, v))
 }
 
 // WaIDNEQ applies the NEQ predicate on the "wa_id" field.
-func WaIDNEQ(v uint64) predicate.Whatsapp {
+func WaIDNEQ(v string) predicate.Whatsapp {
 	return predicate.Whatsapp(sql.FieldNEQ(FieldWaID, v))
 }
 
 // WaIDIn applies the In predicate on the "wa_id" field.
-func WaIDIn(vs ...uint64) predicate.Whatsapp {
+func WaIDIn(vs ...string) predicate.Whatsapp {
 	return predicate.Whatsapp(sql.FieldIn(FieldWaID, vs...))
 }
 
 // WaIDNotIn applies the NotIn predicate on the "wa_id" field.
-func WaIDNotIn(vs ...uint64) predicate.Whatsapp {
+func WaIDNotIn(vs ...string) predicate.Whatsapp {
 	return predicate.Whatsapp(sql.FieldNotIn(FieldWaID, vs...))
 }
 
 // WaIDGT applies the GT predicate on the "wa_id" field.
-func WaIDGT(v uint64) predicate.Whatsapp {
+func WaIDGT(v string) predicate.Whatsapp {
 	return predicate.Whatsapp(sql.FieldGT(FieldWaID, v))
 }
 
 // WaIDGTE applies the GTE predicate on the "wa_id" field.
-func WaIDGTE(v uint64) predicate.Whatsapp {
+func WaIDGTE(v string) predicate.Whatsapp {
 	return predicate.Whatsapp(sql.FieldGTE(FieldWaID, v))
 }
 
 // WaIDLT applies the LT predicate on the "wa_id" field.
-func WaIDLT(v uint64) predicate.Whatsapp {
+func WaIDLT(v string) predicate.Whatsapp {
 	return predicate.Whatsapp(sql.FieldLT(FieldWaID, v))
 }
 
 // WaIDLTE applies the LTE predicate on the "wa_id" field.
-func WaIDLTE(v uint64) predicate.Whatsapp {
+func WaIDLTE(v string) predicate.Whatsapp {
 	return predicate.Whatsapp(sql.FieldLTE(FieldWaID, v))
 }
 
+// WaIDContains applies the Contains predicate on the "wa_id" field.
+func WaIDContains(v string) predicate.Whatsapp {
+	return predicate.Whatsapp(sql.FieldContains(FieldWaID, v))
+}
+
+// WaIDHasPrefix applies the HasPrefix predicate on the "wa_id" field.
+func WaIDHasPrefix(v string) predicate.Whatsapp {
+	return predicate.Whatsapp(sql.FieldHasPrefix(FieldWaID, v))
+}
+
+// WaIDHasSuffix applies the HasSuffix predicate on the "wa_id" field.
+func WaIDHasSuffix(v string) predicate.Whatsapp {
+	return predicate.Whatsapp(sql.FieldHasSuffix(FieldWaID, v))
+}
+
 // WaIDIsNil applies the IsNil predicate on the "wa_id" field.
 func WaIDIsNil() predicate.Whatsapp {
 	return predicate.Whatsapp(sql.FieldIsNull(FieldWaID))
@@ -355,6 +375,16 @@ func WaIDNotNil() predicate.Whatsapp {
 	return predicate.Whatsapp(sql.FieldNotNull(FieldWaID))
 }
 
+// WaIDEqualFold applies the EqualFold predicate on the "wa_id" field.
+func WaIDEqualFold(v string) predicate.Whatsapp {
+	return predicate.Whatsapp(sql.FieldEqualFold(FieldWaID, v))
+}
+
+// WaIDContainsFold applies the ContainsFold predicate on the "wa_id" field.
+func WaIDContainsFold(v string) predicate.Whatsapp {
+	return predicate.Whatsapp(sql.FieldContainsFold(FieldWaID, v))
+}
+
 // CallbackEQ applies the EQ predicate on the "callback" field.
 func CallbackEQ(v string) predicate.Whatsapp {
 	return predicate.Whatsapp(sql.FieldEQ(FieldCallback, v))
@@ -525,6 +555,71 @@ func AccountContainsFold(v string) predicate.Whatsapp {
 	return predicate.Whatsapp(sql.FieldContainsFold(FieldAccount, v))
 }
 
+// CcEQ applies the EQ predicate on the "cc" field.
+func CcEQ(v string) predicate.Whatsapp {
+	return predicate.Whatsapp(sql.FieldEQ(FieldCc, v))
+}
+
+// CcNEQ applies the NEQ predicate on the "cc" field.
+func CcNEQ(v string) predicate.Whatsapp {
+	return predicate.Whatsapp(sql.FieldNEQ(FieldCc, v))
+}
+
+// CcIn applies the In predicate on the "cc" field.
+func CcIn(vs ...string) predicate.Whatsapp {
+	return predicate.Whatsapp(sql.FieldIn(FieldCc, vs...))
+}
+
+// CcNotIn applies the NotIn predicate on the "cc" field.
+func CcNotIn(vs ...string) predicate.Whatsapp {
+	return predicate.Whatsapp(sql.FieldNotIn(FieldCc, vs...))
+}
+
+// CcGT applies the GT predicate on the "cc" field.
+func CcGT(v string) predicate.Whatsapp {
+	return predicate.Whatsapp(sql.FieldGT(FieldCc, v))
+}
+
+// CcGTE applies the GTE predicate on the "cc" field.
+func CcGTE(v string) predicate.Whatsapp {
+	return predicate.Whatsapp(sql.FieldGTE(FieldCc, v))
+}
+
+// CcLT applies the LT predicate on the "cc" field.
+func CcLT(v string) predicate.Whatsapp {
+	return predicate.Whatsapp(sql.FieldLT(FieldCc, v))
+}
+
+// CcLTE applies the LTE predicate on the "cc" field.
+func CcLTE(v string) predicate.Whatsapp {
+	return predicate.Whatsapp(sql.FieldLTE(FieldCc, v))
+}
+
+// CcContains applies the Contains predicate on the "cc" field.
+func CcContains(v string) predicate.Whatsapp {
+	return predicate.Whatsapp(sql.FieldContains(FieldCc, v))
+}
+
+// CcHasPrefix applies the HasPrefix predicate on the "cc" field.
+func CcHasPrefix(v string) predicate.Whatsapp {
+	return predicate.Whatsapp(sql.FieldHasPrefix(FieldCc, v))
+}
+
+// CcHasSuffix applies the HasSuffix predicate on the "cc" field.
+func CcHasSuffix(v string) predicate.Whatsapp {
+	return predicate.Whatsapp(sql.FieldHasSuffix(FieldCc, v))
+}
+
+// CcEqualFold applies the EqualFold predicate on the "cc" field.
+func CcEqualFold(v string) predicate.Whatsapp {
+	return predicate.Whatsapp(sql.FieldEqualFold(FieldCc, v))
+}
+
+// CcContainsFold applies the ContainsFold predicate on the "cc" field.
+func CcContainsFold(v string) predicate.Whatsapp {
+	return predicate.Whatsapp(sql.FieldContainsFold(FieldCc, v))
+}
+
 // PhoneEQ applies the EQ predicate on the "phone" field.
 func PhoneEQ(v string) predicate.Whatsapp {
 	return predicate.Whatsapp(sql.FieldEQ(FieldPhone, v))

+ 74 - 29
ent/whatsapp_create.go

@@ -80,15 +80,15 @@ func (wc *WhatsappCreate) SetNillableDeletedAt(t *time.Time) *WhatsappCreate {
 }
 
 // SetWaID sets the "wa_id" field.
-func (wc *WhatsappCreate) SetWaID(u uint64) *WhatsappCreate {
-	wc.mutation.SetWaID(u)
+func (wc *WhatsappCreate) SetWaID(s string) *WhatsappCreate {
+	wc.mutation.SetWaID(s)
 	return wc
 }
 
 // SetNillableWaID sets the "wa_id" field if the given value is not nil.
-func (wc *WhatsappCreate) SetNillableWaID(u *uint64) *WhatsappCreate {
-	if u != nil {
-		wc.SetWaID(*u)
+func (wc *WhatsappCreate) SetNillableWaID(s *string) *WhatsappCreate {
+	if s != nil {
+		wc.SetWaID(*s)
 	}
 	return wc
 }
@@ -135,6 +135,20 @@ func (wc *WhatsappCreate) SetNillableAccount(s *string) *WhatsappCreate {
 	return wc
 }
 
+// SetCc sets the "cc" field.
+func (wc *WhatsappCreate) SetCc(s string) *WhatsappCreate {
+	wc.mutation.SetCc(s)
+	return wc
+}
+
+// SetNillableCc sets the "cc" field if the given value is not nil.
+func (wc *WhatsappCreate) SetNillableCc(s *string) *WhatsappCreate {
+	if s != nil {
+		wc.SetCc(*s)
+	}
+	return wc
+}
+
 // SetPhone sets the "phone" field.
 func (wc *WhatsappCreate) SetPhone(s string) *WhatsappCreate {
 	wc.mutation.SetPhone(s)
@@ -325,6 +339,10 @@ func (wc *WhatsappCreate) defaults() error {
 		v := whatsapp.DefaultAccount
 		wc.mutation.SetAccount(v)
 	}
+	if _, ok := wc.mutation.Cc(); !ok {
+		v := whatsapp.DefaultCc
+		wc.mutation.SetCc(v)
+	}
 	if _, ok := wc.mutation.Phone(); !ok {
 		v := whatsapp.DefaultPhone
 		wc.mutation.SetPhone(v)
@@ -363,6 +381,9 @@ func (wc *WhatsappCreate) check() error {
 	if _, ok := wc.mutation.AgentID(); !ok {
 		return &ValidationError{Name: "agent_id", err: errors.New(`ent: missing required field "Whatsapp.agent_id"`)}
 	}
+	if _, ok := wc.mutation.Cc(); !ok {
+		return &ValidationError{Name: "cc", err: errors.New(`ent: missing required field "Whatsapp.cc"`)}
+	}
 	if _, ok := wc.mutation.Phone(); !ok {
 		return &ValidationError{Name: "phone", err: errors.New(`ent: missing required field "Whatsapp.phone"`)}
 	}
@@ -425,7 +446,7 @@ func (wc *WhatsappCreate) createSpec() (*Whatsapp, *sqlgraph.CreateSpec) {
 		_node.DeletedAt = value
 	}
 	if value, ok := wc.mutation.WaID(); ok {
-		_spec.SetField(whatsapp.FieldWaID, field.TypeUint64, value)
+		_spec.SetField(whatsapp.FieldWaID, field.TypeString, value)
 		_node.WaID = value
 	}
 	if value, ok := wc.mutation.Callback(); ok {
@@ -436,6 +457,10 @@ func (wc *WhatsappCreate) createSpec() (*Whatsapp, *sqlgraph.CreateSpec) {
 		_spec.SetField(whatsapp.FieldAccount, field.TypeString, value)
 		_node.Account = value
 	}
+	if value, ok := wc.mutation.Cc(); ok {
+		_spec.SetField(whatsapp.FieldCc, field.TypeString, value)
+		_node.Cc = value
+	}
 	if value, ok := wc.mutation.Phone(); ok {
 		_spec.SetField(whatsapp.FieldPhone, field.TypeString, value)
 		_node.Phone = value
@@ -600,7 +625,7 @@ func (u *WhatsappUpsert) ClearDeletedAt() *WhatsappUpsert {
 }
 
 // SetWaID sets the "wa_id" field.
-func (u *WhatsappUpsert) SetWaID(v uint64) *WhatsappUpsert {
+func (u *WhatsappUpsert) SetWaID(v string) *WhatsappUpsert {
 	u.Set(whatsapp.FieldWaID, v)
 	return u
 }
@@ -611,12 +636,6 @@ func (u *WhatsappUpsert) UpdateWaID() *WhatsappUpsert {
 	return u
 }
 
-// AddWaID adds v to the "wa_id" field.
-func (u *WhatsappUpsert) AddWaID(v uint64) *WhatsappUpsert {
-	u.Add(whatsapp.FieldWaID, v)
-	return u
-}
-
 // ClearWaID clears the value of the "wa_id" field.
 func (u *WhatsappUpsert) ClearWaID() *WhatsappUpsert {
 	u.SetNull(whatsapp.FieldWaID)
@@ -671,6 +690,18 @@ func (u *WhatsappUpsert) ClearAccount() *WhatsappUpsert {
 	return u
 }
 
+// SetCc sets the "cc" field.
+func (u *WhatsappUpsert) SetCc(v string) *WhatsappUpsert {
+	u.Set(whatsapp.FieldCc, v)
+	return u
+}
+
+// UpdateCc sets the "cc" field to the value that was provided on create.
+func (u *WhatsappUpsert) UpdateCc() *WhatsappUpsert {
+	u.SetExcluded(whatsapp.FieldCc)
+	return u
+}
+
 // SetPhone sets the "phone" field.
 func (u *WhatsappUpsert) SetPhone(v string) *WhatsappUpsert {
 	u.Set(whatsapp.FieldPhone, v)
@@ -960,19 +991,12 @@ func (u *WhatsappUpsertOne) ClearDeletedAt() *WhatsappUpsertOne {
 }
 
 // SetWaID sets the "wa_id" field.
-func (u *WhatsappUpsertOne) SetWaID(v uint64) *WhatsappUpsertOne {
+func (u *WhatsappUpsertOne) SetWaID(v string) *WhatsappUpsertOne {
 	return u.Update(func(s *WhatsappUpsert) {
 		s.SetWaID(v)
 	})
 }
 
-// AddWaID adds v to the "wa_id" field.
-func (u *WhatsappUpsertOne) AddWaID(v uint64) *WhatsappUpsertOne {
-	return u.Update(func(s *WhatsappUpsert) {
-		s.AddWaID(v)
-	})
-}
-
 // UpdateWaID sets the "wa_id" field to the value that was provided on create.
 func (u *WhatsappUpsertOne) UpdateWaID() *WhatsappUpsertOne {
 	return u.Update(func(s *WhatsappUpsert) {
@@ -1043,6 +1067,20 @@ func (u *WhatsappUpsertOne) ClearAccount() *WhatsappUpsertOne {
 	})
 }
 
+// SetCc sets the "cc" field.
+func (u *WhatsappUpsertOne) SetCc(v string) *WhatsappUpsertOne {
+	return u.Update(func(s *WhatsappUpsert) {
+		s.SetCc(v)
+	})
+}
+
+// UpdateCc sets the "cc" field to the value that was provided on create.
+func (u *WhatsappUpsertOne) UpdateCc() *WhatsappUpsertOne {
+	return u.Update(func(s *WhatsappUpsert) {
+		s.UpdateCc()
+	})
+}
+
 // SetPhone sets the "phone" field.
 func (u *WhatsappUpsertOne) SetPhone(v string) *WhatsappUpsertOne {
 	return u.Update(func(s *WhatsappUpsert) {
@@ -1527,19 +1565,12 @@ func (u *WhatsappUpsertBulk) ClearDeletedAt() *WhatsappUpsertBulk {
 }
 
 // SetWaID sets the "wa_id" field.
-func (u *WhatsappUpsertBulk) SetWaID(v uint64) *WhatsappUpsertBulk {
+func (u *WhatsappUpsertBulk) SetWaID(v string) *WhatsappUpsertBulk {
 	return u.Update(func(s *WhatsappUpsert) {
 		s.SetWaID(v)
 	})
 }
 
-// AddWaID adds v to the "wa_id" field.
-func (u *WhatsappUpsertBulk) AddWaID(v uint64) *WhatsappUpsertBulk {
-	return u.Update(func(s *WhatsappUpsert) {
-		s.AddWaID(v)
-	})
-}
-
 // UpdateWaID sets the "wa_id" field to the value that was provided on create.
 func (u *WhatsappUpsertBulk) UpdateWaID() *WhatsappUpsertBulk {
 	return u.Update(func(s *WhatsappUpsert) {
@@ -1610,6 +1641,20 @@ func (u *WhatsappUpsertBulk) ClearAccount() *WhatsappUpsertBulk {
 	})
 }
 
+// SetCc sets the "cc" field.
+func (u *WhatsappUpsertBulk) SetCc(v string) *WhatsappUpsertBulk {
+	return u.Update(func(s *WhatsappUpsert) {
+		s.SetCc(v)
+	})
+}
+
+// UpdateCc sets the "cc" field to the value that was provided on create.
+func (u *WhatsappUpsertBulk) UpdateCc() *WhatsappUpsertBulk {
+	return u.Update(func(s *WhatsappUpsert) {
+		s.UpdateCc()
+	})
+}
+
 // SetPhone sets the "phone" field.
 func (u *WhatsappUpsertBulk) SetPhone(v string) *WhatsappUpsertBulk {
 	return u.Update(func(s *WhatsappUpsert) {

+ 48 - 34
ent/whatsapp_update.go

@@ -84,26 +84,19 @@ func (wu *WhatsappUpdate) ClearDeletedAt() *WhatsappUpdate {
 }
 
 // SetWaID sets the "wa_id" field.
-func (wu *WhatsappUpdate) SetWaID(u uint64) *WhatsappUpdate {
-	wu.mutation.ResetWaID()
-	wu.mutation.SetWaID(u)
+func (wu *WhatsappUpdate) SetWaID(s string) *WhatsappUpdate {
+	wu.mutation.SetWaID(s)
 	return wu
 }
 
 // SetNillableWaID sets the "wa_id" field if the given value is not nil.
-func (wu *WhatsappUpdate) SetNillableWaID(u *uint64) *WhatsappUpdate {
-	if u != nil {
-		wu.SetWaID(*u)
+func (wu *WhatsappUpdate) SetNillableWaID(s *string) *WhatsappUpdate {
+	if s != nil {
+		wu.SetWaID(*s)
 	}
 	return wu
 }
 
-// AddWaID adds u to the "wa_id" field.
-func (wu *WhatsappUpdate) AddWaID(u int64) *WhatsappUpdate {
-	wu.mutation.AddWaID(u)
-	return wu
-}
-
 // ClearWaID clears the value of the "wa_id" field.
 func (wu *WhatsappUpdate) ClearWaID() *WhatsappUpdate {
 	wu.mutation.ClearWaID()
@@ -164,6 +157,20 @@ func (wu *WhatsappUpdate) ClearAccount() *WhatsappUpdate {
 	return wu
 }
 
+// SetCc sets the "cc" field.
+func (wu *WhatsappUpdate) SetCc(s string) *WhatsappUpdate {
+	wu.mutation.SetCc(s)
+	return wu
+}
+
+// SetNillableCc sets the "cc" field if the given value is not nil.
+func (wu *WhatsappUpdate) SetNillableCc(s *string) *WhatsappUpdate {
+	if s != nil {
+		wu.SetCc(*s)
+	}
+	return wu
+}
+
 // SetPhone sets the "phone" field.
 func (wu *WhatsappUpdate) SetPhone(s string) *WhatsappUpdate {
 	wu.mutation.SetPhone(s)
@@ -449,13 +456,10 @@ func (wu *WhatsappUpdate) sqlSave(ctx context.Context) (n int, err error) {
 		_spec.ClearField(whatsapp.FieldDeletedAt, field.TypeTime)
 	}
 	if value, ok := wu.mutation.WaID(); ok {
-		_spec.SetField(whatsapp.FieldWaID, field.TypeUint64, value)
-	}
-	if value, ok := wu.mutation.AddedWaID(); ok {
-		_spec.AddField(whatsapp.FieldWaID, field.TypeUint64, value)
+		_spec.SetField(whatsapp.FieldWaID, field.TypeString, value)
 	}
 	if wu.mutation.WaIDCleared() {
-		_spec.ClearField(whatsapp.FieldWaID, field.TypeUint64)
+		_spec.ClearField(whatsapp.FieldWaID, field.TypeString)
 	}
 	if value, ok := wu.mutation.Callback(); ok {
 		_spec.SetField(whatsapp.FieldCallback, field.TypeString, value)
@@ -469,6 +473,9 @@ func (wu *WhatsappUpdate) sqlSave(ctx context.Context) (n int, err error) {
 	if wu.mutation.AccountCleared() {
 		_spec.ClearField(whatsapp.FieldAccount, field.TypeString)
 	}
+	if value, ok := wu.mutation.Cc(); ok {
+		_spec.SetField(whatsapp.FieldCc, field.TypeString, value)
+	}
 	if value, ok := wu.mutation.Phone(); ok {
 		_spec.SetField(whatsapp.FieldPhone, field.TypeString, value)
 	}
@@ -649,26 +656,19 @@ func (wuo *WhatsappUpdateOne) ClearDeletedAt() *WhatsappUpdateOne {
 }
 
 // SetWaID sets the "wa_id" field.
-func (wuo *WhatsappUpdateOne) SetWaID(u uint64) *WhatsappUpdateOne {
-	wuo.mutation.ResetWaID()
-	wuo.mutation.SetWaID(u)
+func (wuo *WhatsappUpdateOne) SetWaID(s string) *WhatsappUpdateOne {
+	wuo.mutation.SetWaID(s)
 	return wuo
 }
 
 // SetNillableWaID sets the "wa_id" field if the given value is not nil.
-func (wuo *WhatsappUpdateOne) SetNillableWaID(u *uint64) *WhatsappUpdateOne {
-	if u != nil {
-		wuo.SetWaID(*u)
+func (wuo *WhatsappUpdateOne) SetNillableWaID(s *string) *WhatsappUpdateOne {
+	if s != nil {
+		wuo.SetWaID(*s)
 	}
 	return wuo
 }
 
-// AddWaID adds u to the "wa_id" field.
-func (wuo *WhatsappUpdateOne) AddWaID(u int64) *WhatsappUpdateOne {
-	wuo.mutation.AddWaID(u)
-	return wuo
-}
-
 // ClearWaID clears the value of the "wa_id" field.
 func (wuo *WhatsappUpdateOne) ClearWaID() *WhatsappUpdateOne {
 	wuo.mutation.ClearWaID()
@@ -729,6 +729,20 @@ func (wuo *WhatsappUpdateOne) ClearAccount() *WhatsappUpdateOne {
 	return wuo
 }
 
+// SetCc sets the "cc" field.
+func (wuo *WhatsappUpdateOne) SetCc(s string) *WhatsappUpdateOne {
+	wuo.mutation.SetCc(s)
+	return wuo
+}
+
+// SetNillableCc sets the "cc" field if the given value is not nil.
+func (wuo *WhatsappUpdateOne) SetNillableCc(s *string) *WhatsappUpdateOne {
+	if s != nil {
+		wuo.SetCc(*s)
+	}
+	return wuo
+}
+
 // SetPhone sets the "phone" field.
 func (wuo *WhatsappUpdateOne) SetPhone(s string) *WhatsappUpdateOne {
 	wuo.mutation.SetPhone(s)
@@ -1044,13 +1058,10 @@ func (wuo *WhatsappUpdateOne) sqlSave(ctx context.Context) (_node *Whatsapp, err
 		_spec.ClearField(whatsapp.FieldDeletedAt, field.TypeTime)
 	}
 	if value, ok := wuo.mutation.WaID(); ok {
-		_spec.SetField(whatsapp.FieldWaID, field.TypeUint64, value)
-	}
-	if value, ok := wuo.mutation.AddedWaID(); ok {
-		_spec.AddField(whatsapp.FieldWaID, field.TypeUint64, value)
+		_spec.SetField(whatsapp.FieldWaID, field.TypeString, value)
 	}
 	if wuo.mutation.WaIDCleared() {
-		_spec.ClearField(whatsapp.FieldWaID, field.TypeUint64)
+		_spec.ClearField(whatsapp.FieldWaID, field.TypeString)
 	}
 	if value, ok := wuo.mutation.Callback(); ok {
 		_spec.SetField(whatsapp.FieldCallback, field.TypeString, value)
@@ -1064,6 +1075,9 @@ func (wuo *WhatsappUpdateOne) sqlSave(ctx context.Context) (_node *Whatsapp, err
 	if wuo.mutation.AccountCleared() {
 		_spec.ClearField(whatsapp.FieldAccount, field.TypeString)
 	}
+	if value, ok := wuo.mutation.Cc(); ok {
+		_spec.SetField(whatsapp.FieldCc, field.TypeString, value)
+	}
 	if value, ok := wuo.mutation.Phone(); ok {
 		_spec.SetField(whatsapp.FieldPhone, field.TypeString, value)
 	}

+ 6 - 6
ent/whatsappchannel.go

@@ -30,7 +30,7 @@ type WhatsappChannel struct {
 	// 端口号
 	Sk string `json:"sk,omitempty"`
 	// 通道ID
-	WaID uint64 `json:"wa_id,omitempty"`
+	WaID string `json:"wa_id,omitempty"`
 	// 通道名
 	WaName string `json:"wa_name,omitempty"`
 	// WABA ID
@@ -49,9 +49,9 @@ func (*WhatsappChannel) scanValues(columns []string) ([]any, error) {
 	values := make([]any, len(columns))
 	for i := range columns {
 		switch columns[i] {
-		case whatsappchannel.FieldID, whatsappchannel.FieldStatus, whatsappchannel.FieldWaID, whatsappchannel.FieldWabaID, whatsappchannel.FieldBusinessID, whatsappchannel.FieldOrganizationID:
+		case whatsappchannel.FieldID, whatsappchannel.FieldStatus, whatsappchannel.FieldWabaID, whatsappchannel.FieldBusinessID, whatsappchannel.FieldOrganizationID:
 			values[i] = new(sql.NullInt64)
-		case whatsappchannel.FieldAk, whatsappchannel.FieldSk, whatsappchannel.FieldWaName, whatsappchannel.FieldVerifyAccount:
+		case whatsappchannel.FieldAk, whatsappchannel.FieldSk, whatsappchannel.FieldWaID, whatsappchannel.FieldWaName, whatsappchannel.FieldVerifyAccount:
 			values[i] = new(sql.NullString)
 		case whatsappchannel.FieldCreatedAt, whatsappchannel.FieldUpdatedAt, whatsappchannel.FieldDeletedAt:
 			values[i] = new(sql.NullTime)
@@ -113,10 +113,10 @@ func (wc *WhatsappChannel) assignValues(columns []string, values []any) error {
 				wc.Sk = value.String
 			}
 		case whatsappchannel.FieldWaID:
-			if value, ok := values[i].(*sql.NullInt64); !ok {
+			if value, ok := values[i].(*sql.NullString); !ok {
 				return fmt.Errorf("unexpected type %T for field wa_id", values[i])
 			} else if value.Valid {
-				wc.WaID = uint64(value.Int64)
+				wc.WaID = value.String
 			}
 		case whatsappchannel.FieldWaName:
 			if value, ok := values[i].(*sql.NullString); !ok {
@@ -203,7 +203,7 @@ func (wc *WhatsappChannel) String() string {
 	builder.WriteString(wc.Sk)
 	builder.WriteString(", ")
 	builder.WriteString("wa_id=")
-	builder.WriteString(fmt.Sprintf("%v", wc.WaID))
+	builder.WriteString(wc.WaID)
 	builder.WriteString(", ")
 	builder.WriteString("wa_name=")
 	builder.WriteString(wc.WaName)

+ 1 - 1
ent/whatsappchannel/whatsappchannel.go

@@ -90,7 +90,7 @@ var (
 	// DefaultSk holds the default value on creation for the "sk" field.
 	DefaultSk string
 	// DefaultWaID holds the default value on creation for the "wa_id" field.
-	DefaultWaID uint64
+	DefaultWaID string
 	// DefaultWaName holds the default value on creation for the "wa_name" field.
 	DefaultWaName string
 	// DefaultWabaID holds the default value on creation for the "waba_id" field.

+ 34 - 9
ent/whatsappchannel/where.go

@@ -85,7 +85,7 @@ func Sk(v string) predicate.WhatsappChannel {
 }
 
 // WaID applies equality check predicate on the "wa_id" field. It's identical to WaIDEQ.
-func WaID(v uint64) predicate.WhatsappChannel {
+func WaID(v string) predicate.WhatsappChannel {
 	return predicate.WhatsappChannel(sql.FieldEQ(FieldWaID, v))
 }
 
@@ -435,45 +435,60 @@ func SkContainsFold(v string) predicate.WhatsappChannel {
 }
 
 // WaIDEQ applies the EQ predicate on the "wa_id" field.
-func WaIDEQ(v uint64) predicate.WhatsappChannel {
+func WaIDEQ(v string) predicate.WhatsappChannel {
 	return predicate.WhatsappChannel(sql.FieldEQ(FieldWaID, v))
 }
 
 // WaIDNEQ applies the NEQ predicate on the "wa_id" field.
-func WaIDNEQ(v uint64) predicate.WhatsappChannel {
+func WaIDNEQ(v string) predicate.WhatsappChannel {
 	return predicate.WhatsappChannel(sql.FieldNEQ(FieldWaID, v))
 }
 
 // WaIDIn applies the In predicate on the "wa_id" field.
-func WaIDIn(vs ...uint64) predicate.WhatsappChannel {
+func WaIDIn(vs ...string) predicate.WhatsappChannel {
 	return predicate.WhatsappChannel(sql.FieldIn(FieldWaID, vs...))
 }
 
 // WaIDNotIn applies the NotIn predicate on the "wa_id" field.
-func WaIDNotIn(vs ...uint64) predicate.WhatsappChannel {
+func WaIDNotIn(vs ...string) predicate.WhatsappChannel {
 	return predicate.WhatsappChannel(sql.FieldNotIn(FieldWaID, vs...))
 }
 
 // WaIDGT applies the GT predicate on the "wa_id" field.
-func WaIDGT(v uint64) predicate.WhatsappChannel {
+func WaIDGT(v string) predicate.WhatsappChannel {
 	return predicate.WhatsappChannel(sql.FieldGT(FieldWaID, v))
 }
 
 // WaIDGTE applies the GTE predicate on the "wa_id" field.
-func WaIDGTE(v uint64) predicate.WhatsappChannel {
+func WaIDGTE(v string) predicate.WhatsappChannel {
 	return predicate.WhatsappChannel(sql.FieldGTE(FieldWaID, v))
 }
 
 // WaIDLT applies the LT predicate on the "wa_id" field.
-func WaIDLT(v uint64) predicate.WhatsappChannel {
+func WaIDLT(v string) predicate.WhatsappChannel {
 	return predicate.WhatsappChannel(sql.FieldLT(FieldWaID, v))
 }
 
 // WaIDLTE applies the LTE predicate on the "wa_id" field.
-func WaIDLTE(v uint64) predicate.WhatsappChannel {
+func WaIDLTE(v string) predicate.WhatsappChannel {
 	return predicate.WhatsappChannel(sql.FieldLTE(FieldWaID, v))
 }
 
+// WaIDContains applies the Contains predicate on the "wa_id" field.
+func WaIDContains(v string) predicate.WhatsappChannel {
+	return predicate.WhatsappChannel(sql.FieldContains(FieldWaID, v))
+}
+
+// WaIDHasPrefix applies the HasPrefix predicate on the "wa_id" field.
+func WaIDHasPrefix(v string) predicate.WhatsappChannel {
+	return predicate.WhatsappChannel(sql.FieldHasPrefix(FieldWaID, v))
+}
+
+// WaIDHasSuffix applies the HasSuffix predicate on the "wa_id" field.
+func WaIDHasSuffix(v string) predicate.WhatsappChannel {
+	return predicate.WhatsappChannel(sql.FieldHasSuffix(FieldWaID, v))
+}
+
 // WaIDIsNil applies the IsNil predicate on the "wa_id" field.
 func WaIDIsNil() predicate.WhatsappChannel {
 	return predicate.WhatsappChannel(sql.FieldIsNull(FieldWaID))
@@ -484,6 +499,16 @@ func WaIDNotNil() predicate.WhatsappChannel {
 	return predicate.WhatsappChannel(sql.FieldNotNull(FieldWaID))
 }
 
+// WaIDEqualFold applies the EqualFold predicate on the "wa_id" field.
+func WaIDEqualFold(v string) predicate.WhatsappChannel {
+	return predicate.WhatsappChannel(sql.FieldEqualFold(FieldWaID, v))
+}
+
+// WaIDContainsFold applies the ContainsFold predicate on the "wa_id" field.
+func WaIDContainsFold(v string) predicate.WhatsappChannel {
+	return predicate.WhatsappChannel(sql.FieldContainsFold(FieldWaID, v))
+}
+
 // WaNameEQ applies the EQ predicate on the "wa_name" field.
 func WaNameEQ(v string) predicate.WhatsappChannel {
 	return predicate.WhatsappChannel(sql.FieldEQ(FieldWaName, v))

+ 9 - 29
ent/whatsappchannel_create.go

@@ -107,15 +107,15 @@ func (wcc *WhatsappChannelCreate) SetNillableSk(s *string) *WhatsappChannelCreat
 }
 
 // SetWaID sets the "wa_id" field.
-func (wcc *WhatsappChannelCreate) SetWaID(u uint64) *WhatsappChannelCreate {
-	wcc.mutation.SetWaID(u)
+func (wcc *WhatsappChannelCreate) SetWaID(s string) *WhatsappChannelCreate {
+	wcc.mutation.SetWaID(s)
 	return wcc
 }
 
 // SetNillableWaID sets the "wa_id" field if the given value is not nil.
-func (wcc *WhatsappChannelCreate) SetNillableWaID(u *uint64) *WhatsappChannelCreate {
-	if u != nil {
-		wcc.SetWaID(*u)
+func (wcc *WhatsappChannelCreate) SetNillableWaID(s *string) *WhatsappChannelCreate {
+	if s != nil {
+		wcc.SetWaID(*s)
 	}
 	return wcc
 }
@@ -364,7 +364,7 @@ func (wcc *WhatsappChannelCreate) createSpec() (*WhatsappChannel, *sqlgraph.Crea
 		_node.Sk = value
 	}
 	if value, ok := wcc.mutation.WaID(); ok {
-		_spec.SetField(whatsappchannel.FieldWaID, field.TypeUint64, value)
+		_spec.SetField(whatsappchannel.FieldWaID, field.TypeString, value)
 		_node.WaID = value
 	}
 	if value, ok := wcc.mutation.WaName(); ok {
@@ -524,7 +524,7 @@ func (u *WhatsappChannelUpsert) UpdateSk() *WhatsappChannelUpsert {
 }
 
 // SetWaID sets the "wa_id" field.
-func (u *WhatsappChannelUpsert) SetWaID(v uint64) *WhatsappChannelUpsert {
+func (u *WhatsappChannelUpsert) SetWaID(v string) *WhatsappChannelUpsert {
 	u.Set(whatsappchannel.FieldWaID, v)
 	return u
 }
@@ -535,12 +535,6 @@ func (u *WhatsappChannelUpsert) UpdateWaID() *WhatsappChannelUpsert {
 	return u
 }
 
-// AddWaID adds v to the "wa_id" field.
-func (u *WhatsappChannelUpsert) AddWaID(v uint64) *WhatsappChannelUpsert {
-	u.Add(whatsappchannel.FieldWaID, v)
-	return u
-}
-
 // ClearWaID clears the value of the "wa_id" field.
 func (u *WhatsappChannelUpsert) ClearWaID() *WhatsappChannelUpsert {
 	u.SetNull(whatsappchannel.FieldWaID)
@@ -787,19 +781,12 @@ func (u *WhatsappChannelUpsertOne) UpdateSk() *WhatsappChannelUpsertOne {
 }
 
 // SetWaID sets the "wa_id" field.
-func (u *WhatsappChannelUpsertOne) SetWaID(v uint64) *WhatsappChannelUpsertOne {
+func (u *WhatsappChannelUpsertOne) SetWaID(v string) *WhatsappChannelUpsertOne {
 	return u.Update(func(s *WhatsappChannelUpsert) {
 		s.SetWaID(v)
 	})
 }
 
-// AddWaID adds v to the "wa_id" field.
-func (u *WhatsappChannelUpsertOne) AddWaID(v uint64) *WhatsappChannelUpsertOne {
-	return u.Update(func(s *WhatsappChannelUpsert) {
-		s.AddWaID(v)
-	})
-}
-
 // UpdateWaID sets the "wa_id" field to the value that was provided on create.
 func (u *WhatsappChannelUpsertOne) UpdateWaID() *WhatsappChannelUpsertOne {
 	return u.Update(func(s *WhatsappChannelUpsert) {
@@ -1235,19 +1222,12 @@ func (u *WhatsappChannelUpsertBulk) UpdateSk() *WhatsappChannelUpsertBulk {
 }
 
 // SetWaID sets the "wa_id" field.
-func (u *WhatsappChannelUpsertBulk) SetWaID(v uint64) *WhatsappChannelUpsertBulk {
+func (u *WhatsappChannelUpsertBulk) SetWaID(v string) *WhatsappChannelUpsertBulk {
 	return u.Update(func(s *WhatsappChannelUpsert) {
 		s.SetWaID(v)
 	})
 }
 
-// AddWaID adds v to the "wa_id" field.
-func (u *WhatsappChannelUpsertBulk) AddWaID(v uint64) *WhatsappChannelUpsertBulk {
-	return u.Update(func(s *WhatsappChannelUpsert) {
-		s.AddWaID(v)
-	})
-}
-
 // UpdateWaID sets the "wa_id" field to the value that was provided on create.
 func (u *WhatsappChannelUpsertBulk) UpdateWaID() *WhatsappChannelUpsertBulk {
 	return u.Update(func(s *WhatsappChannelUpsert) {

+ 14 - 34
ent/whatsappchannel_update.go

@@ -116,26 +116,19 @@ func (wcu *WhatsappChannelUpdate) SetNillableSk(s *string) *WhatsappChannelUpdat
 }
 
 // SetWaID sets the "wa_id" field.
-func (wcu *WhatsappChannelUpdate) SetWaID(u uint64) *WhatsappChannelUpdate {
-	wcu.mutation.ResetWaID()
-	wcu.mutation.SetWaID(u)
+func (wcu *WhatsappChannelUpdate) SetWaID(s string) *WhatsappChannelUpdate {
+	wcu.mutation.SetWaID(s)
 	return wcu
 }
 
 // SetNillableWaID sets the "wa_id" field if the given value is not nil.
-func (wcu *WhatsappChannelUpdate) SetNillableWaID(u *uint64) *WhatsappChannelUpdate {
-	if u != nil {
-		wcu.SetWaID(*u)
+func (wcu *WhatsappChannelUpdate) SetNillableWaID(s *string) *WhatsappChannelUpdate {
+	if s != nil {
+		wcu.SetWaID(*s)
 	}
 	return wcu
 }
 
-// AddWaID adds u to the "wa_id" field.
-func (wcu *WhatsappChannelUpdate) AddWaID(u int64) *WhatsappChannelUpdate {
-	wcu.mutation.AddWaID(u)
-	return wcu
-}
-
 // ClearWaID clears the value of the "wa_id" field.
 func (wcu *WhatsappChannelUpdate) ClearWaID() *WhatsappChannelUpdate {
 	wcu.mutation.ClearWaID()
@@ -329,13 +322,10 @@ func (wcu *WhatsappChannelUpdate) sqlSave(ctx context.Context) (n int, err error
 		_spec.SetField(whatsappchannel.FieldSk, field.TypeString, value)
 	}
 	if value, ok := wcu.mutation.WaID(); ok {
-		_spec.SetField(whatsappchannel.FieldWaID, field.TypeUint64, value)
-	}
-	if value, ok := wcu.mutation.AddedWaID(); ok {
-		_spec.AddField(whatsappchannel.FieldWaID, field.TypeUint64, value)
+		_spec.SetField(whatsappchannel.FieldWaID, field.TypeString, value)
 	}
 	if wcu.mutation.WaIDCleared() {
-		_spec.ClearField(whatsappchannel.FieldWaID, field.TypeUint64)
+		_spec.ClearField(whatsappchannel.FieldWaID, field.TypeString)
 	}
 	if value, ok := wcu.mutation.WaName(); ok {
 		_spec.SetField(whatsappchannel.FieldWaName, field.TypeString, value)
@@ -475,26 +465,19 @@ func (wcuo *WhatsappChannelUpdateOne) SetNillableSk(s *string) *WhatsappChannelU
 }
 
 // SetWaID sets the "wa_id" field.
-func (wcuo *WhatsappChannelUpdateOne) SetWaID(u uint64) *WhatsappChannelUpdateOne {
-	wcuo.mutation.ResetWaID()
-	wcuo.mutation.SetWaID(u)
+func (wcuo *WhatsappChannelUpdateOne) SetWaID(s string) *WhatsappChannelUpdateOne {
+	wcuo.mutation.SetWaID(s)
 	return wcuo
 }
 
 // SetNillableWaID sets the "wa_id" field if the given value is not nil.
-func (wcuo *WhatsappChannelUpdateOne) SetNillableWaID(u *uint64) *WhatsappChannelUpdateOne {
-	if u != nil {
-		wcuo.SetWaID(*u)
+func (wcuo *WhatsappChannelUpdateOne) SetNillableWaID(s *string) *WhatsappChannelUpdateOne {
+	if s != nil {
+		wcuo.SetWaID(*s)
 	}
 	return wcuo
 }
 
-// AddWaID adds u to the "wa_id" field.
-func (wcuo *WhatsappChannelUpdateOne) AddWaID(u int64) *WhatsappChannelUpdateOne {
-	wcuo.mutation.AddWaID(u)
-	return wcuo
-}
-
 // ClearWaID clears the value of the "wa_id" field.
 func (wcuo *WhatsappChannelUpdateOne) ClearWaID() *WhatsappChannelUpdateOne {
 	wcuo.mutation.ClearWaID()
@@ -718,13 +701,10 @@ func (wcuo *WhatsappChannelUpdateOne) sqlSave(ctx context.Context) (_node *Whats
 		_spec.SetField(whatsappchannel.FieldSk, field.TypeString, value)
 	}
 	if value, ok := wcuo.mutation.WaID(); ok {
-		_spec.SetField(whatsappchannel.FieldWaID, field.TypeUint64, value)
-	}
-	if value, ok := wcuo.mutation.AddedWaID(); ok {
-		_spec.AddField(whatsappchannel.FieldWaID, field.TypeUint64, value)
+		_spec.SetField(whatsappchannel.FieldWaID, field.TypeString, value)
 	}
 	if wcuo.mutation.WaIDCleared() {
-		_spec.ClearField(whatsappchannel.FieldWaID, field.TypeUint64)
+		_spec.ClearField(whatsappchannel.FieldWaID, field.TypeString)
 	}
 	if value, ok := wcuo.mutation.WaName(); ok {
 		_spec.SetField(whatsappchannel.FieldWaName, field.TypeString, value)

+ 2 - 2
go.mod

@@ -6,6 +6,7 @@ require (
 	entgo.io/ent v0.13.1
 	github.com/ArtisanCloud/PowerWeChat/v2 v2.0.40
 	github.com/alibabacloud-go/avatar-20220130/v2 v2.5.3
+	github.com/alibabacloud-go/cams-20200606/v2 v2.6.0
 	github.com/alibabacloud-go/darabonba-openapi/v2 v2.0.10
 	github.com/alibabacloud-go/sts-20150401/v2 v2.0.2
 	github.com/alibabacloud-go/tea v1.2.2
@@ -39,8 +40,7 @@ require (
 	github.com/alibabacloud-go/alibabacloud-gateway-spi v0.0.5 // indirect
 	github.com/alibabacloud-go/debug v1.0.1 // indirect
 	github.com/alibabacloud-go/endpoint-util v1.1.0 // indirect
-	github.com/alibabacloud-go/openapi-util v0.1.0 // indirect
-	github.com/alibabacloud-go/tea-utils v1.3.1 // indirect
+	github.com/alibabacloud-go/openapi-util v0.1.1 // indirect
 	github.com/alibabacloud-go/tea-xml v1.1.3 // indirect
 	github.com/aliyun/credentials-go v1.3.10 // indirect
 	github.com/andybalholm/brotli v1.1.0 // indirect

+ 4 - 2
go.sum

@@ -44,6 +44,8 @@ github.com/alibabacloud-go/alibabacloud-gateway-spi v0.0.5 h1:zE8vH9C7JiZLNJJQ5O
 github.com/alibabacloud-go/alibabacloud-gateway-spi v0.0.5/go.mod h1:tWnyE9AjF8J8qqLk645oUmVUnFybApTQWklQmi5tY6g=
 github.com/alibabacloud-go/avatar-20220130/v2 v2.5.3 h1:p9rOE5EJDs16TaCcheGNoFUtgDubBTkh8jQ25/cZqdI=
 github.com/alibabacloud-go/avatar-20220130/v2 v2.5.3/go.mod h1:P7j834LZ5IDHVj4Zp/8Yq+KYbJ3PQRUSfXccEKQfTs0=
+github.com/alibabacloud-go/cams-20200606/v2 v2.6.0 h1:8SMPvribttFcq1EaZCbDJKnP3qn1TUnbsfyeKkf5f2c=
+github.com/alibabacloud-go/cams-20200606/v2 v2.6.0/go.mod h1:ifj5V/73KOSuSTDr9OsGYiZ3gjpjIjaktPjq+A0aaFU=
 github.com/alibabacloud-go/darabonba-array v0.1.0 h1:vR8s7b1fWAQIjEjWnuF0JiKsCvclSRTfDzZHTYqfufY=
 github.com/alibabacloud-go/darabonba-array v0.1.0/go.mod h1:BLKxr0brnggqOJPqT09DFJ8g3fsDshapUD3C3aOEFaI=
 github.com/alibabacloud-go/darabonba-encode-util v0.0.2 h1:1uJGrbsGEVqWcWxrS9MyC2NG0Ax+GpOM5gtupki31XE=
@@ -65,8 +67,9 @@ github.com/alibabacloud-go/debug v1.0.1/go.mod h1:8gfgZCCAC3+SCzjWtY053FrOcd4/ql
 github.com/alibabacloud-go/endpoint-util v1.1.0 h1:r/4D3VSw888XGaeNpP994zDUaxdgTSHBbVfZlzf6b5Q=
 github.com/alibabacloud-go/endpoint-util v1.1.0/go.mod h1:O5FuCALmCKs2Ff7JFJMudHs0I5EBgecXXxZRyswlEjE=
 github.com/alibabacloud-go/openapi-util v0.0.11/go.mod h1:sQuElr4ywwFRlCCberQwKRFhRzIyG4QTP/P4y1CJ6Ws=
-github.com/alibabacloud-go/openapi-util v0.1.0 h1:0z75cIULkDrdEhkLWgi9tnLe+KhAFE/r5Pb3312/eAY=
 github.com/alibabacloud-go/openapi-util v0.1.0/go.mod h1:sQuElr4ywwFRlCCberQwKRFhRzIyG4QTP/P4y1CJ6Ws=
+github.com/alibabacloud-go/openapi-util v0.1.1 h1:ujGErJjG8ncRW6XtBBMphzHTvCxn4DjrVw4m04HsS28=
+github.com/alibabacloud-go/openapi-util v0.1.1/go.mod h1:/UehBSE2cf1gYT43GV4E+RxTdLRzURImCYY0aRmlXpw=
 github.com/alibabacloud-go/sts-20150401/v2 v2.0.2 h1:sz6ULL9xaAndxpCXtG5fDBD2aF9L/GXyHfDj1hUnaCs=
 github.com/alibabacloud-go/sts-20150401/v2 v2.0.2/go.mod h1:JXPMuEvl9zJzUAYffyFMxxXGOUbNdvZYWP6MpJq1658=
 github.com/alibabacloud-go/tea v1.1.0/go.mod h1:IkGyUSX4Ba1V+k4pCtJUc6jDpZLFph9QMy2VUPTwukg=
@@ -79,7 +82,6 @@ github.com/alibabacloud-go/tea v1.1.20/go.mod h1:nXxjm6CIFkBhwW4FQkNrolwbfon8Svy
 github.com/alibabacloud-go/tea v1.2.1/go.mod h1:qbzof29bM/IFhLMtJPrgTGK3eauV5J2wSyEUo4OEmnA=
 github.com/alibabacloud-go/tea v1.2.2 h1:aTsR6Rl3ANWPfqeQugPglfurloyBJY85eFy7Gc1+8oU=
 github.com/alibabacloud-go/tea v1.2.2/go.mod h1:CF3vOzEMAG+bR4WOql8gc2G9H3EkH3ZLAQdpmpXMgwk=
-github.com/alibabacloud-go/tea-utils v1.3.1 h1:iWQeRzRheqCMuiF3+XkfybB3kTgUXkXX+JMrqfLeB2I=
 github.com/alibabacloud-go/tea-utils v1.3.1/go.mod h1:EI/o33aBfj3hETm4RLiAxF/ThQdSngxrpF8rKUDJjPE=
 github.com/alibabacloud-go/tea-utils/v2 v2.0.0/go.mod h1:U5MTY10WwlquGPS34DOeomUGBB0gXbLueiq5Trwu0C4=
 github.com/alibabacloud-go/tea-utils/v2 v2.0.4/go.mod h1:sj1PbjPodAVTqGTA3olprfeeqqmwD0A5OQz94o9EuXQ=

+ 75 - 0
hook/aliyun/whatsapp.go

@@ -0,0 +1,75 @@
+package aliyun
+
+import (
+	cams20200606 "github.com/alibabacloud-go/cams-20200606/v2/client"
+	openapi "github.com/alibabacloud-go/darabonba-openapi/v2/client"
+	"github.com/alibabacloud-go/tea/tea"
+)
+
+const (
+	AccessKeyId     string = "LTAI5tSJwCQyuaxXR3UxfnWw"
+	AccessKeySecret string = "0pv4xhSPJv9IPSxrkB52FspJk27W7V"
+	RegionId        string = "cams.ap-southeast-1.aliyuncs.com"
+)
+
+// Description:
+// 使用AK&SK初始化账号Client
+// @return Client
+// @throws Exception
+func CreateCamsClient() (_result *cams20200606.Client, _err error) {
+	// 工程代码泄露可能会导致 AccessKey 泄露,并威胁账号下所有资源的安全性。以下代码示例仅供参考。
+	// 建议使用更安全的 STS 方式,更多鉴权访问方式请参见:https://help.aliyun.com/document_detail/378661.html。
+	config := &openapi.Config{
+		// 必填,请确保代码运行环境设置了环境变量 ALIBABA_CLOUD_ACCESS_KEY_ID。
+		AccessKeyId: tea.String(AccessKeyId),
+		// 必填,请确保代码运行环境设置了环境变量 ALIBABA_CLOUD_ACCESS_KEY_SECRET。
+		AccessKeySecret: tea.String(AccessKeySecret),
+	}
+	// Endpoint 请参考 https://api.aliyun.com/product/cams
+	config.Endpoint = tea.String(RegionId)
+	_result = &cams20200606.Client{}
+	_result, _err = cams20200606.NewClient(config)
+	return _result, _err
+}
+
+// GetCamsAppId 获取 AppId
+// "LTAI5tSJwCQyuaxXR3UxfnWw", "0pv4xhSPJv9IPSxrkB52FspJk27W7V" "cams.ap-southeast-1.aliyuncs.com"
+func GetCamsAppId() (string, error) {
+	client, _err := CreateCamsClient()
+	if _err != nil {
+		return "", _err
+	}
+
+	request := &cams20200606.IsvGetAppIdRequest{
+		Type: tea.String("WHATSAPP"),
+	}
+
+	isvResponse, _err := client.IsvGetAppId(request)
+	if _err != nil {
+		return "", _err
+	}
+
+	return *isvResponse.Body.AppId, nil
+}
+
+// AddCamsPhoneNumber 添加WhatsApp号码
+func AddCamsPhoneNumber(phone, cc, custSpaceId, verifiedName string) (*cams20200606.AddChatappPhoneNumberResponse, error) {
+	client, _err := CreateCamsClient()
+	if _err != nil {
+		return nil, _err
+	}
+
+	request := &cams20200606.AddChatappPhoneNumberRequest{
+		PhoneNumber:  tea.String(phone),
+		Cc:           tea.String(cc),
+		CustSpaceId:  tea.String(custSpaceId),
+		VerifiedName: tea.String(verifiedName),
+	}
+
+	response, _err := client.AddChatappPhoneNumber(request)
+	if _err != nil {
+		return nil, _err
+	}
+
+	return response, nil
+}

+ 38 - 24
internal/logic/whatsapp/create_whatsapp_logic.go

@@ -2,12 +2,14 @@ package whatsapp
 
 import (
 	"context"
-
-	"wechat-api/internal/svc"
-	"wechat-api/internal/types"
+	"wechat-api/ent"
+	"wechat-api/ent/whatsapp"
 	"wechat-api/internal/utils/dberrorhandler"
 
 	"github.com/suyuan32/simple-admin-common/msg/errormsg"
+	"wechat-api/hook/aliyun"
+	"wechat-api/internal/svc"
+	"wechat-api/internal/types"
 
 	"github.com/zeromicro/go-zero/core/logx"
 )
@@ -27,27 +29,39 @@ func NewCreateWhatsappLogic(ctx context.Context, svcCtx *svc.ServiceContext) *Cr
 }
 
 func (l *CreateWhatsappLogic) CreateWhatsapp(req *types.WhatsappInfo) (*types.BaseMsgResp, error) {
-	var stringSlice []string
-
-	_, err := l.svcCtx.DB.Whatsapp.Create().
-		SetNotNilWaID(req.WaId).
-		SetNotNilCallback(req.Callback).
-		SetNotNilAccount(req.Account).
-		SetNotNilPhone(req.Phone).
-		SetNotNilPhoneName(req.PhoneName).
-		SetNotNilPhoneStatus(req.PhoneStatus).
-		SetNotNilOrganizationID(req.OrganizationId).
-		SetNotNilAgentID(req.AgentId).
-		SetNotNilAPIBase(req.ApiBase).
-		SetNotNilAPIKey(req.ApiKey).
-		SetNotNilAllowList(stringSlice).
-		SetNotNilGroupAllowList(stringSlice).
-		SetNotNilBlockList(stringSlice).
-		SetNotNilGroupBlockList(stringSlice).
-		Save(l.ctx)
-
-	if err != nil {
-		return nil, dberrorhandler.DefaultEntError(l.Logger, err, req)
+	add, err := aliyun.AddCamsPhoneNumber(*req.PhoneName, *req.Cc, *req.WaId, *req.PhoneName)
+	//l.Logger.Infof("add=%v err=%v\n", add, err)
+	if *add.Body.Code == "OK" {
+		var stringSlice []string
+
+		_, err := l.svcCtx.DB.Whatsapp.Query().
+			Where(whatsapp.WaID(*req.WaId)).
+			Where(whatsapp.Phone(*req.Phone)).
+			Where(whatsapp.Cc(*req.Cc)).
+			First(l.ctx)
+		if err != nil && ent.IsNotFound(err) {
+			_, err = l.svcCtx.DB.Whatsapp.Create().
+				SetNotNilWaID(req.WaId).
+				SetNotNilCallback(req.Callback).
+				SetNotNilAccount(req.Account).
+				SetNotNilPhone(req.Phone).
+				SetNotNilCc(req.Cc).
+				SetNotNilPhoneName(req.PhoneName).
+				SetNotNilPhoneStatus(req.PhoneStatus).
+				SetNotNilOrganizationID(req.OrganizationId).
+				SetNotNilAgentID(req.AgentId).
+				SetNotNilAPIBase(req.ApiBase).
+				SetNotNilAPIKey(req.ApiKey).
+				SetNotNilAllowList(stringSlice).
+				SetNotNilGroupAllowList(stringSlice).
+				SetNotNilBlockList(stringSlice).
+				SetNotNilGroupBlockList(stringSlice).
+				Save(l.ctx)
+
+			if err != nil {
+				return nil, dberrorhandler.DefaultEntError(l.Logger, err, req)
+			}
+		}
 	}
 
 	return &types.BaseMsgResp{Msg: errormsg.CreateSuccess}, nil

+ 3 - 4
internal/types/types.go

@@ -3415,7 +3415,7 @@ type WhatsappInfo struct {
 	BaseIDInfo
 	// Status 1: normal 2: ban | 状态 1 正常 2 禁用
 	Status *uint8  `json:"status,optional"`
-	WaId   *uint64 `json:"waId,optional"`
+	WaId   *string `json:"waId,optional"`
 	// 回调地址
 	Callback *string `json:"callback,optional"`
 	// 模式ID
@@ -3423,10 +3423,9 @@ type WhatsappInfo struct {
 	AgentInfo *AgentInfo `json:"agentInfo,optional"`
 	// 微信账号
 	Account *string `json:"account,optional"`
-	// 昵称
-	Nickname *string `json:"nickname,optional"`
 	// 手机号
 	Phone *string `json:"phone,optional"`
+	Cc    *string `json:"cc,optional"`
 	// 号码名称
 	PhoneName *string `json:"phoneName,optional"`
 	// 号码状态
@@ -3497,7 +3496,7 @@ type WhatsappChannelInfo struct {
 	// 端口号
 	Sk *string `json:"sk,optional"`
 	// 通道ID
-	WaId *uint64 `json:"waId,optional"`
+	WaId *string `json:"waId,optional"`
 	// 通道名
 	WaName *string `json:"waName,optional"`
 	// WABA ID