Просмотр исходного кода

fix:submit whatsapp && credit_balance

jimmyyem 2 месяцев назад
Родитель
Сommit
7e6833724e
52 измененных файлов с 8368 добавлено и 42 удалено
  1. 2 1
      desc/all.api
  2. 25 0
      desc/wechat/credit_balance.api
  3. 11 1
      desc/wechat/usage_detail.api
  4. 121 0
      desc/wechat/whatsapp.api
  5. 151 6
      ent/client.go
  6. 2 0
      ent/creditbalance/creditbalance.go
  7. 12 0
      ent/creditbalance_create.go
  8. 2 0
      ent/creditusage/creditusage.go
  9. 12 0
      ent/creditusage_create.go
  10. 2 0
      ent/ent.go
  11. 12 0
      ent/hook/hook.go
  12. 30 0
      ent/intercept/intercept.go
  13. 42 3
      ent/migrate/schema.go
  14. 1537 0
      ent/mutation.go
  15. 82 0
      ent/pagination.go
  16. 2 0
      ent/payrecharge/payrecharge.go
  17. 12 0
      ent/payrecharge_create.go
  18. 3 0
      ent/predicate/predicate.go
  19. 72 0
      ent/runtime/runtime.go
  20. 1 1
      ent/schema/credit_balance.go
  21. 1 1
      ent/schema/credit_usage.go
  22. 1 1
      ent/schema/pay_recharge.go
  23. 59 0
      ent/schema/whatsapp.go
  24. 408 0
      ent/set_not_nil.go
  25. 3 0
      ent/tx.go
  26. 304 0
      ent/whatsapp.go
  27. 204 0
      ent/whatsapp/whatsapp.go
  28. 960 0
      ent/whatsapp/where.go
  29. 1693 0
      ent/whatsapp_create.go
  30. 88 0
      ent/whatsapp_delete.go
  31. 526 0
      ent/whatsapp_query.go
  32. 961 0
      ent/whatsapp_update.go
  33. 44 0
      internal/handler/UsageDetail/get_usage_detail_handler.go
  34. 44 0
      internal/handler/credit_balance/operate_credit_balance_handler.go
  35. 45 0
      internal/handler/routes.go
  36. 44 0
      internal/handler/whatsapp/create_whatsapp_handler.go
  37. 44 0
      internal/handler/whatsapp/delete_whatsapp_handler.go
  38. 44 0
      internal/handler/whatsapp/get_whatsapp_by_id_handler.go
  39. 44 0
      internal/handler/whatsapp/get_whatsapp_list_handler.go
  40. 44 0
      internal/handler/whatsapp/update_whatsapp_handler.go
  41. 85 0
      internal/logic/UsageDetail/get_usage_detail_logic.go
  42. 62 0
      internal/logic/base/init_api_data.go
  43. 11 10
      internal/logic/credit_balance/create_credit_balance_logic.go
  44. 27 17
      internal/logic/credit_balance/get_credit_balance_by_id_logic.go
  45. 10 0
      internal/logic/credit_balance/get_credit_balance_list_logic.go
  46. 105 0
      internal/logic/credit_balance/operate_credit_balance_logic.go
  47. 55 0
      internal/logic/whatsapp/create_whatsapp_logic.go
  48. 37 0
      internal/logic/whatsapp/delete_whatsapp_logic.go
  49. 60 0
      internal/logic/whatsapp/get_whatsapp_by_id_logic.go
  50. 76 0
      internal/logic/whatsapp/get_whatsapp_list_logic.go
  51. 48 0
      internal/logic/whatsapp/update_whatsapp_logic.go
  52. 98 1
      internal/types/types.go

+ 2 - 1
desc/all.api

@@ -39,4 +39,5 @@ import "./wechat/xiaoice.api"
 import "./wechat/dashboard.api"
 import "./wechat/credit_balance.api"
 import "./wechat/credit_usage.api"
-import "./wechat/pay_recharge.api"
+import "./wechat/pay_recharge.api"
+import "./wechat/whatsapp.api"

+ 25 - 0
desc/wechat/credit_balance.api

@@ -16,8 +16,23 @@ type (
 
         // organization_id | 租户ID 
         OrganizationId  *uint64 `json:"organizationId,optional"`
+
+		User BUserInfo `json:"user,optional"`
     }
 
+	BUserInfo {
+		UserId  *string `json:"userId,optional"`
+
+		// User's name | 用户名
+		Username *string `json:"username,optional"`
+
+		// User's nickname | 用户的昵称
+		Nickname *string `json:"nickname,optional"`
+
+		// The user's avatar path | 用户的头像路径
+		Avatar *string `json:"avatar,optional"`
+	}
+
     // The response data of credit balance list | CreditBalance列表数据
     CreditBalanceListResp {
         BaseDataInfo
@@ -51,6 +66,12 @@ type (
         // CreditBalance information | CreditBalance数据
         Data CreditBalanceInfo `json:"data"`
     }
+
+	CreditBalanceOperateReq {
+		UserId  *string `json:"userId,optional"`
+		Number  *float32 `json:"number,optional"`
+		Reason *string `json:"reason,optional"`
+	}
 )
 
 @server(
@@ -79,4 +100,8 @@ service Wechat {
     // Get credit balance by ID | 通过ID获取CreditBalance
     @handler getCreditBalanceById
     post /credit_balance (IDReq) returns (CreditBalanceInfoResp)
+
+	// Get credit balance by ID | 通过ID获取CreditBalance
+	@handler operateCreditBalance
+	post /credit_balance/operate (CreditBalanceOperateReq) returns (BaseMsgResp)
 }

+ 11 - 1
desc/wechat/usage_detail.api

@@ -65,6 +65,12 @@ type (
         // 租户id
         BotId  *string `json:"botId,optional"`
     }
+
+	UsageDetailResp {
+		BaseDataInfo
+
+		Data UsageDetailInfo `json:"data"`
+	}
 )
 
 @server(
@@ -74,7 +80,11 @@ type (
 )
 
 service Wechat {
-    // Get usage detail list | 获取Wx列表
+    // Get usage detail list | 获取usage_detail列表
     @handler getUsageDetailList
     post /usage_detail/list (UsageDetailListReq) returns (UsageDetailListResp)
+
+	// Get usage detail list | 获取Wx列表
+	@handler getUsageDetail
+	post /usage_detail (IDReq) returns (UsageDetailResp)
 }

+ 121 - 0
desc/wechat/whatsapp.api

@@ -0,0 +1,121 @@
+import "../base.api"
+import "./agent.api"
+import "./label_relationship.api"
+
+type (
+    // The data of whatsapp information | Whatsapp信息
+    WhatsappInfo {
+        BaseIDInfo
+
+        // Status 1: normal 2: ban | 状态 1 正常 2 禁用 
+        Status  *uint8 `json:"status,optional"`
+
+        // ak 
+        Ak  *string `json:"ak,optional"`
+
+        // 端口号 
+        Sk  *string `json:"sk,optional"`
+
+        // 回调地址 
+        Callback  *string `json:"callback,optional"`
+
+        // 微信账号 
+        Account  *string `json:"account,optional"`
+
+        // 昵称 
+        Nickname  *string `json:"nickname,optional"`
+
+        // 手机号 
+        Phone  *string `json:"phone,optional"`
+
+        // 机构 ID 
+        OrganizationId  *uint64 `json:"organizationId,optional"`
+
+        // 模式ID 
+        AgentId  *uint64 `json:"agentId,optional"`
+
+        // 大模型服务地址 
+        ApiBase  *string `json:"apiBase,optional"`
+
+        // 大模型服务密钥 
+        ApiKey  *string `json:"apiKey,optional"`
+
+        // 白名单 
+        AllowList  []ContactInfo `json:"allowList,optional"`
+
+        // 群白名单 
+        GroupAllowList  []ContactInfo `json:"groupAllowList,optional"`
+
+        // 黑名单 
+        BlockList  []ContactInfo `json:"blockList,optional"`
+
+        // 群黑名单 
+        GroupBlockList  []ContactInfo `json:"groupBlockList,optional"`
+    }
+
+    // The response data of whatsapp list | Whatsapp列表数据
+    WhatsappListResp {
+        BaseDataInfo
+
+        // Whatsapp list data | Whatsapp列表数据
+        Data WhatsappListInfo `json:"data"`
+    }
+
+    // Whatsapp list data | Whatsapp列表数据
+    WhatsappListInfo {
+        BaseListInfo
+
+        // The API list data | Whatsapp列表数据
+        Data  []WhatsappInfo  `json:"data"`
+    }
+
+    // Get whatsapp list request params | Whatsapp列表请求参数
+    WhatsappListReq {
+        PageInfo
+
+        // ak 
+        Ak  *string `json:"ak,optional"`
+
+        // 端口号 
+        Sk  *string `json:"sk,optional"`
+
+        // 回调地址 
+        Callback  *string `json:"callback,optional"`
+    }
+
+    // Whatsapp information response | Whatsapp信息返回体
+    WhatsappInfoResp {
+        BaseDataInfo
+
+        // Whatsapp information | Whatsapp数据
+        Data WhatsappInfo `json:"data"`
+    }
+)
+
+@server(
+    jwt: Auth
+    group: whatsapp
+    middleware: Authority
+)
+
+service Wechat {
+    // Create whatsapp information | 创建Whatsapp
+    @handler createWhatsapp
+    post /whatsapp/create (WhatsappInfo) returns (BaseMsgResp)
+
+    // Update whatsapp information | 更新Whatsapp
+    @handler updateWhatsapp
+    post /whatsapp/update (WhatsappInfo) returns (BaseMsgResp)
+
+    // Delete whatsapp information | 删除Whatsapp信息
+    @handler deleteWhatsapp
+    post /whatsapp/delete (IDsReq) returns (BaseMsgResp)
+
+    // Get whatsapp list | 获取Whatsapp列表
+    @handler getWhatsappList
+    post /whatsapp/list (WhatsappListReq) returns (WhatsappListResp)
+
+    // Get whatsapp by ID | 通过ID获取Whatsapp
+    @handler getWhatsappById
+    post /whatsapp (IDReq) returns (WhatsappInfoResp)
+}

+ 151 - 6
ent/client.go

@@ -42,6 +42,7 @@ import (
 	"wechat-api/ent/usagestatistichour"
 	"wechat-api/ent/usagestatisticmonth"
 	"wechat-api/ent/usagetotal"
+	"wechat-api/ent/whatsapp"
 	"wechat-api/ent/workexperience"
 	"wechat-api/ent/wpchatroom"
 	"wechat-api/ent/wpchatroommember"
@@ -125,6 +126,8 @@ type Client struct {
 	UsageStatisticMonth *UsageStatisticMonthClient
 	// UsageTotal is the client for interacting with the UsageTotal builders.
 	UsageTotal *UsageTotalClient
+	// Whatsapp is the client for interacting with the Whatsapp builders.
+	Whatsapp *WhatsappClient
 	// WorkExperience is the client for interacting with the WorkExperience builders.
 	WorkExperience *WorkExperienceClient
 	// WpChatroom is the client for interacting with the WpChatroom builders.
@@ -181,6 +184,7 @@ func (c *Client) init() {
 	c.UsageStatisticHour = NewUsageStatisticHourClient(c.config)
 	c.UsageStatisticMonth = NewUsageStatisticMonthClient(c.config)
 	c.UsageTotal = NewUsageTotalClient(c.config)
+	c.Whatsapp = NewWhatsappClient(c.config)
 	c.WorkExperience = NewWorkExperienceClient(c.config)
 	c.WpChatroom = NewWpChatroomClient(c.config)
 	c.WpChatroomMember = NewWpChatroomMemberClient(c.config)
@@ -311,6 +315,7 @@ func (c *Client) Tx(ctx context.Context) (*Tx, error) {
 		UsageStatisticHour:  NewUsageStatisticHourClient(cfg),
 		UsageStatisticMonth: NewUsageStatisticMonthClient(cfg),
 		UsageTotal:          NewUsageTotalClient(cfg),
+		Whatsapp:            NewWhatsappClient(cfg),
 		WorkExperience:      NewWorkExperienceClient(cfg),
 		WpChatroom:          NewWpChatroomClient(cfg),
 		WpChatroomMember:    NewWpChatroomMemberClient(cfg),
@@ -368,6 +373,7 @@ func (c *Client) BeginTx(ctx context.Context, opts *sql.TxOptions) (*Tx, error)
 		UsageStatisticHour:  NewUsageStatisticHourClient(cfg),
 		UsageStatisticMonth: NewUsageStatisticMonthClient(cfg),
 		UsageTotal:          NewUsageTotalClient(cfg),
+		Whatsapp:            NewWhatsappClient(cfg),
 		WorkExperience:      NewWorkExperienceClient(cfg),
 		WpChatroom:          NewWpChatroomClient(cfg),
 		WpChatroomMember:    NewWpChatroomMemberClient(cfg),
@@ -409,8 +415,9 @@ func (c *Client) Use(hooks ...Hook) {
 		c.Employee, c.EmployeeConfig, c.Label, c.LabelRelationship, c.LabelTagging,
 		c.Message, c.MessageRecords, c.Msg, c.PayRecharge, c.Server, c.SopNode,
 		c.SopStage, c.SopTask, c.Token, c.Tutorial, c.UsageDetail, c.UsageStatisticDay,
-		c.UsageStatisticHour, c.UsageStatisticMonth, c.UsageTotal, c.WorkExperience,
-		c.WpChatroom, c.WpChatroomMember, c.Wx, c.WxCard, c.WxCardUser, c.WxCardVisit,
+		c.UsageStatisticHour, c.UsageStatisticMonth, c.UsageTotal, c.Whatsapp,
+		c.WorkExperience, c.WpChatroom, c.WpChatroomMember, c.Wx, c.WxCard,
+		c.WxCardUser, c.WxCardVisit,
 	} {
 		n.Use(hooks...)
 	}
@@ -425,8 +432,9 @@ func (c *Client) Intercept(interceptors ...Interceptor) {
 		c.Employee, c.EmployeeConfig, c.Label, c.LabelRelationship, c.LabelTagging,
 		c.Message, c.MessageRecords, c.Msg, c.PayRecharge, c.Server, c.SopNode,
 		c.SopStage, c.SopTask, c.Token, c.Tutorial, c.UsageDetail, c.UsageStatisticDay,
-		c.UsageStatisticHour, c.UsageStatisticMonth, c.UsageTotal, c.WorkExperience,
-		c.WpChatroom, c.WpChatroomMember, c.Wx, c.WxCard, c.WxCardUser, c.WxCardVisit,
+		c.UsageStatisticHour, c.UsageStatisticMonth, c.UsageTotal, c.Whatsapp,
+		c.WorkExperience, c.WpChatroom, c.WpChatroomMember, c.Wx, c.WxCard,
+		c.WxCardUser, c.WxCardVisit,
 	} {
 		n.Intercept(interceptors...)
 	}
@@ -497,6 +505,8 @@ func (c *Client) Mutate(ctx context.Context, m Mutation) (Value, error) {
 		return c.UsageStatisticMonth.mutate(ctx, m)
 	case *UsageTotalMutation:
 		return c.UsageTotal.mutate(ctx, m)
+	case *WhatsappMutation:
+		return c.Whatsapp.mutate(ctx, m)
 	case *WorkExperienceMutation:
 		return c.WorkExperience.mutate(ctx, m)
 	case *WpChatroomMutation:
@@ -5039,6 +5049,141 @@ func (c *UsageTotalClient) mutate(ctx context.Context, m *UsageTotalMutation) (V
 	}
 }
 
+// WhatsappClient is a client for the Whatsapp schema.
+type WhatsappClient struct {
+	config
+}
+
+// NewWhatsappClient returns a client for the Whatsapp from the given config.
+func NewWhatsappClient(c config) *WhatsappClient {
+	return &WhatsappClient{config: c}
+}
+
+// Use adds a list of mutation hooks to the hooks stack.
+// A call to `Use(f, g, h)` equals to `whatsapp.Hooks(f(g(h())))`.
+func (c *WhatsappClient) Use(hooks ...Hook) {
+	c.hooks.Whatsapp = append(c.hooks.Whatsapp, hooks...)
+}
+
+// Intercept adds a list of query interceptors to the interceptors stack.
+// A call to `Intercept(f, g, h)` equals to `whatsapp.Intercept(f(g(h())))`.
+func (c *WhatsappClient) Intercept(interceptors ...Interceptor) {
+	c.inters.Whatsapp = append(c.inters.Whatsapp, interceptors...)
+}
+
+// Create returns a builder for creating a Whatsapp entity.
+func (c *WhatsappClient) Create() *WhatsappCreate {
+	mutation := newWhatsappMutation(c.config, OpCreate)
+	return &WhatsappCreate{config: c.config, hooks: c.Hooks(), mutation: mutation}
+}
+
+// CreateBulk returns a builder for creating a bulk of Whatsapp entities.
+func (c *WhatsappClient) CreateBulk(builders ...*WhatsappCreate) *WhatsappCreateBulk {
+	return &WhatsappCreateBulk{config: c.config, builders: builders}
+}
+
+// MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates
+// a builder and applies setFunc on it.
+func (c *WhatsappClient) MapCreateBulk(slice any, setFunc func(*WhatsappCreate, int)) *WhatsappCreateBulk {
+	rv := reflect.ValueOf(slice)
+	if rv.Kind() != reflect.Slice {
+		return &WhatsappCreateBulk{err: fmt.Errorf("calling to WhatsappClient.MapCreateBulk with wrong type %T, need slice", slice)}
+	}
+	builders := make([]*WhatsappCreate, rv.Len())
+	for i := 0; i < rv.Len(); i++ {
+		builders[i] = c.Create()
+		setFunc(builders[i], i)
+	}
+	return &WhatsappCreateBulk{config: c.config, builders: builders}
+}
+
+// Update returns an update builder for Whatsapp.
+func (c *WhatsappClient) Update() *WhatsappUpdate {
+	mutation := newWhatsappMutation(c.config, OpUpdate)
+	return &WhatsappUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation}
+}
+
+// UpdateOne returns an update builder for the given entity.
+func (c *WhatsappClient) UpdateOne(w *Whatsapp) *WhatsappUpdateOne {
+	mutation := newWhatsappMutation(c.config, OpUpdateOne, withWhatsapp(w))
+	return &WhatsappUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
+}
+
+// UpdateOneID returns an update builder for the given id.
+func (c *WhatsappClient) UpdateOneID(id uint64) *WhatsappUpdateOne {
+	mutation := newWhatsappMutation(c.config, OpUpdateOne, withWhatsappID(id))
+	return &WhatsappUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
+}
+
+// Delete returns a delete builder for Whatsapp.
+func (c *WhatsappClient) Delete() *WhatsappDelete {
+	mutation := newWhatsappMutation(c.config, OpDelete)
+	return &WhatsappDelete{config: c.config, hooks: c.Hooks(), mutation: mutation}
+}
+
+// DeleteOne returns a builder for deleting the given entity.
+func (c *WhatsappClient) DeleteOne(w *Whatsapp) *WhatsappDeleteOne {
+	return c.DeleteOneID(w.ID)
+}
+
+// DeleteOneID returns a builder for deleting the given entity by its id.
+func (c *WhatsappClient) DeleteOneID(id uint64) *WhatsappDeleteOne {
+	builder := c.Delete().Where(whatsapp.ID(id))
+	builder.mutation.id = &id
+	builder.mutation.op = OpDeleteOne
+	return &WhatsappDeleteOne{builder}
+}
+
+// Query returns a query builder for Whatsapp.
+func (c *WhatsappClient) Query() *WhatsappQuery {
+	return &WhatsappQuery{
+		config: c.config,
+		ctx:    &QueryContext{Type: TypeWhatsapp},
+		inters: c.Interceptors(),
+	}
+}
+
+// Get returns a Whatsapp entity by its id.
+func (c *WhatsappClient) Get(ctx context.Context, id uint64) (*Whatsapp, error) {
+	return c.Query().Where(whatsapp.ID(id)).Only(ctx)
+}
+
+// GetX is like Get, but panics if an error occurs.
+func (c *WhatsappClient) GetX(ctx context.Context, id uint64) *Whatsapp {
+	obj, err := c.Get(ctx, id)
+	if err != nil {
+		panic(err)
+	}
+	return obj
+}
+
+// Hooks returns the client hooks.
+func (c *WhatsappClient) Hooks() []Hook {
+	hooks := c.hooks.Whatsapp
+	return append(hooks[:len(hooks):len(hooks)], whatsapp.Hooks[:]...)
+}
+
+// Interceptors returns the client interceptors.
+func (c *WhatsappClient) Interceptors() []Interceptor {
+	inters := c.inters.Whatsapp
+	return append(inters[:len(inters):len(inters)], whatsapp.Interceptors[:]...)
+}
+
+func (c *WhatsappClient) mutate(ctx context.Context, m *WhatsappMutation) (Value, error) {
+	switch m.Op() {
+	case OpCreate:
+		return (&WhatsappCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
+	case OpUpdate:
+		return (&WhatsappUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
+	case OpUpdateOne:
+		return (&WhatsappUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
+	case OpDelete, OpDeleteOne:
+		return (&WhatsappDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx)
+	default:
+		return nil, fmt.Errorf("ent: unknown Whatsapp mutation op: %q", m.Op())
+	}
+}
+
 // WorkExperienceClient is a client for the WorkExperience schema.
 type WorkExperienceClient struct {
 	config
@@ -6036,7 +6181,7 @@ type (
 		Label, LabelRelationship, LabelTagging, Message, MessageRecords, Msg,
 		PayRecharge, Server, SopNode, SopStage, SopTask, Token, Tutorial, UsageDetail,
 		UsageStatisticDay, UsageStatisticHour, UsageStatisticMonth, UsageTotal,
-		WorkExperience, WpChatroom, WpChatroomMember, Wx, WxCard, WxCardUser,
+		Whatsapp, WorkExperience, WpChatroom, WpChatroomMember, Wx, WxCard, WxCardUser,
 		WxCardVisit []ent.Hook
 	}
 	inters struct {
@@ -6045,7 +6190,7 @@ type (
 		Label, LabelRelationship, LabelTagging, Message, MessageRecords, Msg,
 		PayRecharge, Server, SopNode, SopStage, SopTask, Token, Tutorial, UsageDetail,
 		UsageStatisticDay, UsageStatisticHour, UsageStatisticMonth, UsageTotal,
-		WorkExperience, WpChatroom, WpChatroomMember, Wx, WxCard, WxCardUser,
+		Whatsapp, WorkExperience, WpChatroom, WpChatroomMember, Wx, WxCard, WxCardUser,
 		WxCardVisit []ent.Interceptor
 	}
 )

+ 2 - 0
ent/creditbalance/creditbalance.go

@@ -74,6 +74,8 @@ var (
 	DefaultStatus int
 	// StatusValidator is a validator for the "status" field. It is called by the builders before save.
 	StatusValidator func(int) error
+	// DefaultOrganizationID holds the default value on creation for the "organization_id" field.
+	DefaultOrganizationID uint64
 	// OrganizationIDValidator is a validator for the "organization_id" field. It is called by the builders before save.
 	OrganizationIDValidator func(uint64) error
 )

+ 12 - 0
ent/creditbalance_create.go

@@ -96,6 +96,14 @@ func (cbc *CreditBalanceCreate) SetOrganizationID(u uint64) *CreditBalanceCreate
 	return cbc
 }
 
+// SetNillableOrganizationID sets the "organization_id" field if the given value is not nil.
+func (cbc *CreditBalanceCreate) SetNillableOrganizationID(u *uint64) *CreditBalanceCreate {
+	if u != nil {
+		cbc.SetOrganizationID(*u)
+	}
+	return cbc
+}
+
 // SetID sets the "id" field.
 func (cbc *CreditBalanceCreate) SetID(u uint64) *CreditBalanceCreate {
 	cbc.mutation.SetID(u)
@@ -157,6 +165,10 @@ func (cbc *CreditBalanceCreate) defaults() error {
 		v := creditbalance.DefaultStatus
 		cbc.mutation.SetStatus(v)
 	}
+	if _, ok := cbc.mutation.OrganizationID(); !ok {
+		v := creditbalance.DefaultOrganizationID
+		cbc.mutation.SetOrganizationID(v)
+	}
 	return nil
 }
 

+ 2 - 0
ent/creditusage/creditusage.go

@@ -93,6 +93,8 @@ var (
 	DefaultNtype int
 	// DefaultTable holds the default value on creation for the "table" field.
 	DefaultTable string
+	// DefaultOrganizationID holds the default value on creation for the "organization_id" field.
+	DefaultOrganizationID uint64
 	// OrganizationIDValidator is a validator for the "organization_id" field. It is called by the builders before save.
 	OrganizationIDValidator func(uint64) error
 	// DefaultNid holds the default value on creation for the "nid" field.

+ 12 - 0
ent/creditusage_create.go

@@ -124,6 +124,14 @@ func (cuc *CreditUsageCreate) SetOrganizationID(u uint64) *CreditUsageCreate {
 	return cuc
 }
 
+// SetNillableOrganizationID sets the "organization_id" field if the given value is not nil.
+func (cuc *CreditUsageCreate) SetNillableOrganizationID(u *uint64) *CreditUsageCreate {
+	if u != nil {
+		cuc.SetOrganizationID(*u)
+	}
+	return cuc
+}
+
 // SetNid sets the "nid" field.
 func (cuc *CreditUsageCreate) SetNid(u uint64) *CreditUsageCreate {
 	cuc.mutation.SetNid(u)
@@ -235,6 +243,10 @@ func (cuc *CreditUsageCreate) defaults() error {
 		v := creditusage.DefaultTable
 		cuc.mutation.SetTable(v)
 	}
+	if _, ok := cuc.mutation.OrganizationID(); !ok {
+		v := creditusage.DefaultOrganizationID
+		cuc.mutation.SetOrganizationID(v)
+	}
 	if _, ok := cuc.mutation.Nid(); !ok {
 		v := creditusage.DefaultNid
 		cuc.mutation.SetNid(v)

+ 2 - 0
ent/ent.go

@@ -39,6 +39,7 @@ import (
 	"wechat-api/ent/usagestatistichour"
 	"wechat-api/ent/usagestatisticmonth"
 	"wechat-api/ent/usagetotal"
+	"wechat-api/ent/whatsapp"
 	"wechat-api/ent/workexperience"
 	"wechat-api/ent/wpchatroom"
 	"wechat-api/ent/wpchatroommember"
@@ -141,6 +142,7 @@ func checkColumn(table, column string) error {
 			usagestatistichour.Table:  usagestatistichour.ValidColumn,
 			usagestatisticmonth.Table: usagestatisticmonth.ValidColumn,
 			usagetotal.Table:          usagetotal.ValidColumn,
+			whatsapp.Table:            whatsapp.ValidColumn,
 			workexperience.Table:      workexperience.ValidColumn,
 			wpchatroom.Table:          wpchatroom.ValidColumn,
 			wpchatroommember.Table:    wpchatroommember.ValidColumn,

+ 12 - 0
ent/hook/hook.go

@@ -380,6 +380,18 @@ func (f UsageTotalFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.Value,
 	return nil, fmt.Errorf("unexpected mutation type %T. expect *ent.UsageTotalMutation", m)
 }
 
+// The WhatsappFunc type is an adapter to allow the use of ordinary
+// function as Whatsapp mutator.
+type WhatsappFunc func(context.Context, *ent.WhatsappMutation) (ent.Value, error)
+
+// Mutate calls f(ctx, m).
+func (f WhatsappFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.Value, error) {
+	if mv, ok := m.(*ent.WhatsappMutation); ok {
+		return f(ctx, mv)
+	}
+	return nil, fmt.Errorf("unexpected mutation type %T. expect *ent.WhatsappMutation", m)
+}
+
 // The WorkExperienceFunc type is an adapter to allow the use of ordinary
 // function as WorkExperience mutator.
 type WorkExperienceFunc func(context.Context, *ent.WorkExperienceMutation) (ent.Value, error)

+ 30 - 0
ent/intercept/intercept.go

@@ -38,6 +38,7 @@ import (
 	"wechat-api/ent/usagestatistichour"
 	"wechat-api/ent/usagestatisticmonth"
 	"wechat-api/ent/usagetotal"
+	"wechat-api/ent/whatsapp"
 	"wechat-api/ent/workexperience"
 	"wechat-api/ent/wpchatroom"
 	"wechat-api/ent/wpchatroommember"
@@ -942,6 +943,33 @@ func (f TraverseUsageTotal) Traverse(ctx context.Context, q ent.Query) error {
 	return fmt.Errorf("unexpected query type %T. expect *ent.UsageTotalQuery", q)
 }
 
+// The WhatsappFunc type is an adapter to allow the use of ordinary function as a Querier.
+type WhatsappFunc func(context.Context, *ent.WhatsappQuery) (ent.Value, error)
+
+// Query calls f(ctx, q).
+func (f WhatsappFunc) Query(ctx context.Context, q ent.Query) (ent.Value, error) {
+	if q, ok := q.(*ent.WhatsappQuery); ok {
+		return f(ctx, q)
+	}
+	return nil, fmt.Errorf("unexpected query type %T. expect *ent.WhatsappQuery", q)
+}
+
+// The TraverseWhatsapp type is an adapter to allow the use of ordinary function as Traverser.
+type TraverseWhatsapp func(context.Context, *ent.WhatsappQuery) error
+
+// Intercept is a dummy implementation of Intercept that returns the next Querier in the pipeline.
+func (f TraverseWhatsapp) Intercept(next ent.Querier) ent.Querier {
+	return next
+}
+
+// Traverse calls f(ctx, q).
+func (f TraverseWhatsapp) Traverse(ctx context.Context, q ent.Query) error {
+	if q, ok := q.(*ent.WhatsappQuery); ok {
+		return f(ctx, q)
+	}
+	return fmt.Errorf("unexpected query type %T. expect *ent.WhatsappQuery", q)
+}
+
 // The WorkExperienceFunc type is an adapter to allow the use of ordinary function as a Querier.
 type WorkExperienceFunc func(context.Context, *ent.WorkExperienceQuery) (ent.Value, error)
 
@@ -1196,6 +1224,8 @@ func NewQuery(q ent.Query) (Query, error) {
 		return &query[*ent.UsageStatisticMonthQuery, predicate.UsageStatisticMonth, usagestatisticmonth.OrderOption]{typ: ent.TypeUsageStatisticMonth, tq: q}, nil
 	case *ent.UsageTotalQuery:
 		return &query[*ent.UsageTotalQuery, predicate.UsageTotal, usagetotal.OrderOption]{typ: ent.TypeUsageTotal, tq: q}, nil
+	case *ent.WhatsappQuery:
+		return &query[*ent.WhatsappQuery, predicate.Whatsapp, whatsapp.OrderOption]{typ: ent.TypeWhatsapp, tq: q}, nil
 	case *ent.WorkExperienceQuery:
 		return &query[*ent.WorkExperienceQuery, predicate.WorkExperience, workexperience.OrderOption]{typ: ent.TypeWorkExperience, tq: q}, nil
 	case *ent.WpChatroomQuery:

+ 42 - 3
ent/migrate/schema.go

@@ -292,7 +292,7 @@ var (
 		{Name: "user_id", Type: field.TypeString, Size: 255, Comment: "user_id | 用户ID"},
 		{Name: "balance", Type: field.TypeFloat32, Comment: "role | 角色设定"},
 		{Name: "status", Type: field.TypeInt, Nullable: true, Comment: "status | 状态 1-正常 2-禁用", Default: 1},
-		{Name: "organization_id", Type: field.TypeUint64, Comment: "organization_id | 租户ID"},
+		{Name: "organization_id", Type: field.TypeUint64, Comment: "organization_id | 租户ID", Default: 1},
 	}
 	// CreditBalanceTable holds the schema information for the "credit_balance" table.
 	CreditBalanceTable = &schema.Table{
@@ -323,7 +323,7 @@ var (
 		{Name: "status", Type: field.TypeInt, Nullable: true, Comment: "status | 状态 1-正常 2-禁用", Default: 1},
 		{Name: "ntype", Type: field.TypeInt, Comment: "ntype | 积分变化类型:1-消耗 2-增加", Default: 1},
 		{Name: "table", Type: field.TypeString, Comment: "table | 积分变化表名", Default: ""},
-		{Name: "organization_id", Type: field.TypeUint64, Comment: "organization_id | 租户ID"},
+		{Name: "organization_id", Type: field.TypeUint64, Comment: "organization_id | 租户ID", Default: 1},
 		{Name: "nid", Type: field.TypeUint64, Comment: "nid | 积分变化关联信息ID", Default: 0},
 		{Name: "reason", Type: field.TypeString, Size: 255, Comment: "reason | 积分变动原因", Default: ""},
 		{Name: "operator", Type: field.TypeString, Size: 255, Comment: "operator | 积分变动人", Default: ""},
@@ -610,7 +610,7 @@ var (
 		{Name: "status", Type: field.TypeInt, Nullable: true, Comment: "status | 状态 1-正常 2-禁用", Default: 1},
 		{Name: "money", Type: field.TypeFloat32, Nullable: true, Comment: "money | 充值钱数", Default: 0},
 		{Name: "out_trade_no", Type: field.TypeString, Nullable: true, Comment: "out_trade_no | 外部订单号", Default: ""},
-		{Name: "organization_id", Type: field.TypeUint64, Comment: "organization_id | 租户ID"},
+		{Name: "organization_id", Type: field.TypeUint64, Comment: "organization_id | 租户ID", Default: 1},
 	}
 	// PayRechargeTable holds the schema information for the "pay_recharge" table.
 	PayRechargeTable = &schema.Table{
@@ -1033,6 +1033,41 @@ var (
 			},
 		},
 	}
+	// WhatsappColumns holds the columns for the "whatsapp" table.
+	WhatsappColumns = []*schema.Column{
+		{Name: "id", Type: field.TypeUint64, Increment: true},
+		{Name: "created_at", Type: field.TypeTime, Comment: "Create Time | 创建日期"},
+		{Name: "updated_at", Type: field.TypeTime, Comment: "Update Time | 修改日期"},
+		{Name: "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: "ak", Type: field.TypeString, Nullable: true, Default: ""},
+		{Name: "sk", Type: field.TypeString, Default: ""},
+		{Name: "callback", Type: field.TypeString, Default: ""},
+		{Name: "account", Type: field.TypeString, Default: ""},
+		{Name: "nickname", Type: field.TypeString, Default: ""},
+		{Name: "phone", Type: field.TypeString, Default: ""},
+		{Name: "organization_id", Type: field.TypeUint64, Nullable: true, Default: 1},
+		{Name: "agent_id", Type: field.TypeUint64, Default: 0},
+		{Name: "api_base", Type: field.TypeString, Nullable: true, Default: ""},
+		{Name: "api_key", Type: field.TypeString, Nullable: true, Default: ""},
+		{Name: "allow_list", Type: field.TypeJSON},
+		{Name: "group_allow_list", Type: field.TypeJSON},
+		{Name: "block_list", Type: field.TypeJSON},
+		{Name: "group_block_list", Type: field.TypeJSON},
+	}
+	// WhatsappTable holds the schema information for the "whatsapp" table.
+	WhatsappTable = &schema.Table{
+		Name:       "whatsapp",
+		Columns:    WhatsappColumns,
+		PrimaryKey: []*schema.Column{WhatsappColumns[0]},
+		Indexes: []*schema.Index{
+			{
+				Name:    "whatsapp_ak_sk",
+				Unique:  false,
+				Columns: []*schema.Column{WhatsappColumns[5], WhatsappColumns[6]},
+			},
+		},
+	}
 	// WorkExperienceColumns holds the columns for the "work_experience" table.
 	WorkExperienceColumns = []*schema.Column{
 		{Name: "id", Type: field.TypeUint64, Increment: true},
@@ -1327,6 +1362,7 @@ var (
 		UsageStatisticHourTable,
 		UsageStatisticMonthTable,
 		UsageTotalTable,
+		WhatsappTable,
 		WorkExperienceTable,
 		WpChatroomTable,
 		WpChatroomMemberTable,
@@ -1440,6 +1476,9 @@ func init() {
 	UsageTotalTable.Annotation = &entsql.Annotation{
 		Table: "usage_total",
 	}
+	WhatsappTable.Annotation = &entsql.Annotation{
+		Table: "whatsapp",
+	}
 	WorkExperienceTable.ForeignKeys[0].RefTable = EmployeeTable
 	WorkExperienceTable.Annotation = &entsql.Annotation{
 		Table: "work_experience",

+ 1537 - 0
ent/mutation.go

@@ -41,6 +41,7 @@ import (
 	"wechat-api/ent/usagestatistichour"
 	"wechat-api/ent/usagestatisticmonth"
 	"wechat-api/ent/usagetotal"
+	"wechat-api/ent/whatsapp"
 	"wechat-api/ent/workexperience"
 	"wechat-api/ent/wpchatroom"
 	"wechat-api/ent/wpchatroommember"
@@ -93,6 +94,7 @@ const (
 	TypeUsageStatisticHour  = "UsageStatisticHour"
 	TypeUsageStatisticMonth = "UsageStatisticMonth"
 	TypeUsageTotal          = "UsageTotal"
+	TypeWhatsapp            = "Whatsapp"
 	TypeWorkExperience      = "WorkExperience"
 	TypeWpChatroom          = "WpChatroom"
 	TypeWpChatroomMember    = "WpChatroomMember"
@@ -36802,6 +36804,1541 @@ func (m *UsageTotalMutation) ResetEdge(name string) error {
 	return fmt.Errorf("unknown UsageTotal edge %s", name)
 }
 
+// WhatsappMutation represents an operation that mutates the Whatsapp nodes in the graph.
+type WhatsappMutation struct {
+	config
+	op                     Op
+	typ                    string
+	id                     *uint64
+	created_at             *time.Time
+	updated_at             *time.Time
+	status                 *uint8
+	addstatus              *int8
+	deleted_at             *time.Time
+	ak                     *string
+	sk                     *string
+	callback               *string
+	account                *string
+	nickname               *string
+	phone                  *string
+	organization_id        *uint64
+	addorganization_id     *int64
+	agent_id               *uint64
+	addagent_id            *int64
+	api_base               *string
+	api_key                *string
+	allow_list             *[]string
+	appendallow_list       []string
+	group_allow_list       *[]string
+	appendgroup_allow_list []string
+	block_list             *[]string
+	appendblock_list       []string
+	group_block_list       *[]string
+	appendgroup_block_list []string
+	clearedFields          map[string]struct{}
+	done                   bool
+	oldValue               func(context.Context) (*Whatsapp, error)
+	predicates             []predicate.Whatsapp
+}
+
+var _ ent.Mutation = (*WhatsappMutation)(nil)
+
+// whatsappOption allows management of the mutation configuration using functional options.
+type whatsappOption func(*WhatsappMutation)
+
+// newWhatsappMutation creates new mutation for the Whatsapp entity.
+func newWhatsappMutation(c config, op Op, opts ...whatsappOption) *WhatsappMutation {
+	m := &WhatsappMutation{
+		config:        c,
+		op:            op,
+		typ:           TypeWhatsapp,
+		clearedFields: make(map[string]struct{}),
+	}
+	for _, opt := range opts {
+		opt(m)
+	}
+	return m
+}
+
+// withWhatsappID sets the ID field of the mutation.
+func withWhatsappID(id uint64) whatsappOption {
+	return func(m *WhatsappMutation) {
+		var (
+			err   error
+			once  sync.Once
+			value *Whatsapp
+		)
+		m.oldValue = func(ctx context.Context) (*Whatsapp, error) {
+			once.Do(func() {
+				if m.done {
+					err = errors.New("querying old values post mutation is not allowed")
+				} else {
+					value, err = m.Client().Whatsapp.Get(ctx, id)
+				}
+			})
+			return value, err
+		}
+		m.id = &id
+	}
+}
+
+// withWhatsapp sets the old Whatsapp of the mutation.
+func withWhatsapp(node *Whatsapp) whatsappOption {
+	return func(m *WhatsappMutation) {
+		m.oldValue = func(context.Context) (*Whatsapp, error) {
+			return node, nil
+		}
+		m.id = &node.ID
+	}
+}
+
+// Client returns a new `ent.Client` from the mutation. If the mutation was
+// executed in a transaction (ent.Tx), a transactional client is returned.
+func (m WhatsappMutation) Client() *Client {
+	client := &Client{config: m.config}
+	client.init()
+	return client
+}
+
+// Tx returns an `ent.Tx` for mutations that were executed in transactions;
+// it returns an error otherwise.
+func (m WhatsappMutation) Tx() (*Tx, error) {
+	if _, ok := m.driver.(*txDriver); !ok {
+		return nil, errors.New("ent: mutation is not running in a transaction")
+	}
+	tx := &Tx{config: m.config}
+	tx.init()
+	return tx, nil
+}
+
+// SetID sets the value of the id field. Note that this
+// operation is only accepted on creation of Whatsapp entities.
+func (m *WhatsappMutation) SetID(id uint64) {
+	m.id = &id
+}
+
+// ID returns the ID value in the mutation. Note that the ID is only available
+// if it was provided to the builder or after it was returned from the database.
+func (m *WhatsappMutation) ID() (id uint64, exists bool) {
+	if m.id == nil {
+		return
+	}
+	return *m.id, true
+}
+
+// IDs queries the database and returns the entity ids that match the mutation's predicate.
+// That means, if the mutation is applied within a transaction with an isolation level such
+// as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
+// or updated by the mutation.
+func (m *WhatsappMutation) IDs(ctx context.Context) ([]uint64, error) {
+	switch {
+	case m.op.Is(OpUpdateOne | OpDeleteOne):
+		id, exists := m.ID()
+		if exists {
+			return []uint64{id}, nil
+		}
+		fallthrough
+	case m.op.Is(OpUpdate | OpDelete):
+		return m.Client().Whatsapp.Query().Where(m.predicates...).IDs(ctx)
+	default:
+		return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
+	}
+}
+
+// SetCreatedAt sets the "created_at" field.
+func (m *WhatsappMutation) SetCreatedAt(t time.Time) {
+	m.created_at = &t
+}
+
+// CreatedAt returns the value of the "created_at" field in the mutation.
+func (m *WhatsappMutation) CreatedAt() (r time.Time, exists bool) {
+	v := m.created_at
+	if v == nil {
+		return
+	}
+	return *v, true
+}
+
+// OldCreatedAt returns the old "created_at" 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) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
+	if !m.op.Is(OpUpdateOne) {
+		return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
+	}
+	if m.id == nil || m.oldValue == nil {
+		return v, errors.New("OldCreatedAt requires an ID field in the mutation")
+	}
+	oldValue, err := m.oldValue(ctx)
+	if err != nil {
+		return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
+	}
+	return oldValue.CreatedAt, nil
+}
+
+// ResetCreatedAt resets all changes to the "created_at" field.
+func (m *WhatsappMutation) ResetCreatedAt() {
+	m.created_at = nil
+}
+
+// SetUpdatedAt sets the "updated_at" field.
+func (m *WhatsappMutation) SetUpdatedAt(t time.Time) {
+	m.updated_at = &t
+}
+
+// UpdatedAt returns the value of the "updated_at" field in the mutation.
+func (m *WhatsappMutation) UpdatedAt() (r time.Time, exists bool) {
+	v := m.updated_at
+	if v == nil {
+		return
+	}
+	return *v, true
+}
+
+// OldUpdatedAt returns the old "updated_at" 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) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
+	if !m.op.Is(OpUpdateOne) {
+		return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
+	}
+	if m.id == nil || m.oldValue == nil {
+		return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
+	}
+	oldValue, err := m.oldValue(ctx)
+	if err != nil {
+		return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
+	}
+	return oldValue.UpdatedAt, nil
+}
+
+// ResetUpdatedAt resets all changes to the "updated_at" field.
+func (m *WhatsappMutation) ResetUpdatedAt() {
+	m.updated_at = nil
+}
+
+// SetStatus sets the "status" field.
+func (m *WhatsappMutation) SetStatus(u uint8) {
+	m.status = &u
+	m.addstatus = nil
+}
+
+// Status returns the value of the "status" field in the mutation.
+func (m *WhatsappMutation) Status() (r uint8, exists bool) {
+	v := m.status
+	if v == nil {
+		return
+	}
+	return *v, true
+}
+
+// OldStatus returns the old "status" 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) OldStatus(ctx context.Context) (v uint8, err error) {
+	if !m.op.Is(OpUpdateOne) {
+		return v, errors.New("OldStatus is only allowed on UpdateOne operations")
+	}
+	if m.id == nil || m.oldValue == nil {
+		return v, errors.New("OldStatus requires an ID field in the mutation")
+	}
+	oldValue, err := m.oldValue(ctx)
+	if err != nil {
+		return v, fmt.Errorf("querying old value for OldStatus: %w", err)
+	}
+	return oldValue.Status, nil
+}
+
+// AddStatus adds u to the "status" field.
+func (m *WhatsappMutation) AddStatus(u int8) {
+	if m.addstatus != nil {
+		*m.addstatus += u
+	} else {
+		m.addstatus = &u
+	}
+}
+
+// AddedStatus returns the value that was added to the "status" field in this mutation.
+func (m *WhatsappMutation) AddedStatus() (r int8, exists bool) {
+	v := m.addstatus
+	if v == nil {
+		return
+	}
+	return *v, true
+}
+
+// ClearStatus clears the value of the "status" field.
+func (m *WhatsappMutation) ClearStatus() {
+	m.status = nil
+	m.addstatus = nil
+	m.clearedFields[whatsapp.FieldStatus] = struct{}{}
+}
+
+// StatusCleared returns if the "status" field was cleared in this mutation.
+func (m *WhatsappMutation) StatusCleared() bool {
+	_, ok := m.clearedFields[whatsapp.FieldStatus]
+	return ok
+}
+
+// ResetStatus resets all changes to the "status" field.
+func (m *WhatsappMutation) ResetStatus() {
+	m.status = nil
+	m.addstatus = nil
+	delete(m.clearedFields, whatsapp.FieldStatus)
+}
+
+// SetDeletedAt sets the "deleted_at" field.
+func (m *WhatsappMutation) SetDeletedAt(t time.Time) {
+	m.deleted_at = &t
+}
+
+// DeletedAt returns the value of the "deleted_at" field in the mutation.
+func (m *WhatsappMutation) DeletedAt() (r time.Time, exists bool) {
+	v := m.deleted_at
+	if v == nil {
+		return
+	}
+	return *v, true
+}
+
+// OldDeletedAt returns the old "deleted_at" 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) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
+	if !m.op.Is(OpUpdateOne) {
+		return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
+	}
+	if m.id == nil || m.oldValue == nil {
+		return v, errors.New("OldDeletedAt requires an ID field in the mutation")
+	}
+	oldValue, err := m.oldValue(ctx)
+	if err != nil {
+		return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
+	}
+	return oldValue.DeletedAt, nil
+}
+
+// ClearDeletedAt clears the value of the "deleted_at" field.
+func (m *WhatsappMutation) ClearDeletedAt() {
+	m.deleted_at = nil
+	m.clearedFields[whatsapp.FieldDeletedAt] = struct{}{}
+}
+
+// DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
+func (m *WhatsappMutation) DeletedAtCleared() bool {
+	_, ok := m.clearedFields[whatsapp.FieldDeletedAt]
+	return ok
+}
+
+// ResetDeletedAt resets all changes to the "deleted_at" field.
+func (m *WhatsappMutation) ResetDeletedAt() {
+	m.deleted_at = nil
+	delete(m.clearedFields, whatsapp.FieldDeletedAt)
+}
+
+// SetAk sets the "ak" field.
+func (m *WhatsappMutation) SetAk(s string) {
+	m.ak = &s
+}
+
+// Ak returns the value of the "ak" field in the mutation.
+func (m *WhatsappMutation) Ak() (r string, exists bool) {
+	v := m.ak
+	if v == nil {
+		return
+	}
+	return *v, true
+}
+
+// OldAk returns the old "ak" 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) OldAk(ctx context.Context) (v string, err error) {
+	if !m.op.Is(OpUpdateOne) {
+		return v, errors.New("OldAk is only allowed on UpdateOne operations")
+	}
+	if m.id == nil || m.oldValue == nil {
+		return v, errors.New("OldAk requires an ID field in the mutation")
+	}
+	oldValue, err := m.oldValue(ctx)
+	if err != nil {
+		return v, fmt.Errorf("querying old value for OldAk: %w", err)
+	}
+	return oldValue.Ak, nil
+}
+
+// ClearAk clears the value of the "ak" field.
+func (m *WhatsappMutation) ClearAk() {
+	m.ak = nil
+	m.clearedFields[whatsapp.FieldAk] = struct{}{}
+}
+
+// AkCleared returns if the "ak" field was cleared in this mutation.
+func (m *WhatsappMutation) AkCleared() bool {
+	_, ok := m.clearedFields[whatsapp.FieldAk]
+	return ok
+}
+
+// ResetAk resets all changes to the "ak" field.
+func (m *WhatsappMutation) ResetAk() {
+	m.ak = nil
+	delete(m.clearedFields, whatsapp.FieldAk)
+}
+
+// SetSk sets the "sk" field.
+func (m *WhatsappMutation) SetSk(s string) {
+	m.sk = &s
+}
+
+// Sk returns the value of the "sk" field in the mutation.
+func (m *WhatsappMutation) Sk() (r string, exists bool) {
+	v := m.sk
+	if v == nil {
+		return
+	}
+	return *v, true
+}
+
+// OldSk returns the old "sk" 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) OldSk(ctx context.Context) (v string, err error) {
+	if !m.op.Is(OpUpdateOne) {
+		return v, errors.New("OldSk is only allowed on UpdateOne operations")
+	}
+	if m.id == nil || m.oldValue == nil {
+		return v, errors.New("OldSk requires an ID field in the mutation")
+	}
+	oldValue, err := m.oldValue(ctx)
+	if err != nil {
+		return v, fmt.Errorf("querying old value for OldSk: %w", err)
+	}
+	return oldValue.Sk, nil
+}
+
+// ResetSk resets all changes to the "sk" field.
+func (m *WhatsappMutation) ResetSk() {
+	m.sk = nil
+}
+
+// SetCallback sets the "callback" field.
+func (m *WhatsappMutation) SetCallback(s string) {
+	m.callback = &s
+}
+
+// Callback returns the value of the "callback" field in the mutation.
+func (m *WhatsappMutation) Callback() (r string, exists bool) {
+	v := m.callback
+	if v == nil {
+		return
+	}
+	return *v, true
+}
+
+// OldCallback returns the old "callback" 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) OldCallback(ctx context.Context) (v string, err error) {
+	if !m.op.Is(OpUpdateOne) {
+		return v, errors.New("OldCallback is only allowed on UpdateOne operations")
+	}
+	if m.id == nil || m.oldValue == nil {
+		return v, errors.New("OldCallback requires an ID field in the mutation")
+	}
+	oldValue, err := m.oldValue(ctx)
+	if err != nil {
+		return v, fmt.Errorf("querying old value for OldCallback: %w", err)
+	}
+	return oldValue.Callback, nil
+}
+
+// ResetCallback resets all changes to the "callback" field.
+func (m *WhatsappMutation) ResetCallback() {
+	m.callback = nil
+}
+
+// SetAccount sets the "account" field.
+func (m *WhatsappMutation) SetAccount(s string) {
+	m.account = &s
+}
+
+// Account returns the value of the "account" field in the mutation.
+func (m *WhatsappMutation) Account() (r string, exists bool) {
+	v := m.account
+	if v == nil {
+		return
+	}
+	return *v, true
+}
+
+// OldAccount returns the old "account" 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) OldAccount(ctx context.Context) (v string, err error) {
+	if !m.op.Is(OpUpdateOne) {
+		return v, errors.New("OldAccount is only allowed on UpdateOne operations")
+	}
+	if m.id == nil || m.oldValue == nil {
+		return v, errors.New("OldAccount requires an ID field in the mutation")
+	}
+	oldValue, err := m.oldValue(ctx)
+	if err != nil {
+		return v, fmt.Errorf("querying old value for OldAccount: %w", err)
+	}
+	return oldValue.Account, nil
+}
+
+// ResetAccount resets all changes to the "account" field.
+func (m *WhatsappMutation) ResetAccount() {
+	m.account = nil
+}
+
+// SetNickname sets the "nickname" field.
+func (m *WhatsappMutation) SetNickname(s string) {
+	m.nickname = &s
+}
+
+// Nickname returns the value of the "nickname" field in the mutation.
+func (m *WhatsappMutation) Nickname() (r string, exists bool) {
+	v := m.nickname
+	if v == nil {
+		return
+	}
+	return *v, true
+}
+
+// OldNickname returns the old "nickname" 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) OldNickname(ctx context.Context) (v string, err error) {
+	if !m.op.Is(OpUpdateOne) {
+		return v, errors.New("OldNickname is only allowed on UpdateOne operations")
+	}
+	if m.id == nil || m.oldValue == nil {
+		return v, errors.New("OldNickname requires an ID field in the mutation")
+	}
+	oldValue, err := m.oldValue(ctx)
+	if err != nil {
+		return v, fmt.Errorf("querying old value for OldNickname: %w", err)
+	}
+	return oldValue.Nickname, nil
+}
+
+// ResetNickname resets all changes to the "nickname" field.
+func (m *WhatsappMutation) ResetNickname() {
+	m.nickname = nil
+}
+
+// SetPhone sets the "phone" field.
+func (m *WhatsappMutation) SetPhone(s string) {
+	m.phone = &s
+}
+
+// Phone returns the value of the "phone" field in the mutation.
+func (m *WhatsappMutation) Phone() (r string, exists bool) {
+	v := m.phone
+	if v == nil {
+		return
+	}
+	return *v, true
+}
+
+// OldPhone returns the old "phone" 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) OldPhone(ctx context.Context) (v string, err error) {
+	if !m.op.Is(OpUpdateOne) {
+		return v, errors.New("OldPhone is only allowed on UpdateOne operations")
+	}
+	if m.id == nil || m.oldValue == nil {
+		return v, errors.New("OldPhone requires an ID field in the mutation")
+	}
+	oldValue, err := m.oldValue(ctx)
+	if err != nil {
+		return v, fmt.Errorf("querying old value for OldPhone: %w", err)
+	}
+	return oldValue.Phone, nil
+}
+
+// ResetPhone resets all changes to the "phone" field.
+func (m *WhatsappMutation) ResetPhone() {
+	m.phone = nil
+}
+
+// SetOrganizationID sets the "organization_id" field.
+func (m *WhatsappMutation) SetOrganizationID(u uint64) {
+	m.organization_id = &u
+	m.addorganization_id = nil
+}
+
+// OrganizationID returns the value of the "organization_id" field in the mutation.
+func (m *WhatsappMutation) OrganizationID() (r uint64, exists bool) {
+	v := m.organization_id
+	if v == nil {
+		return
+	}
+	return *v, true
+}
+
+// OldOrganizationID returns the old "organization_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) OldOrganizationID(ctx context.Context) (v uint64, err error) {
+	if !m.op.Is(OpUpdateOne) {
+		return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
+	}
+	if m.id == nil || m.oldValue == nil {
+		return v, errors.New("OldOrganizationID requires an ID field in the mutation")
+	}
+	oldValue, err := m.oldValue(ctx)
+	if err != nil {
+		return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
+	}
+	return oldValue.OrganizationID, nil
+}
+
+// AddOrganizationID adds u to the "organization_id" field.
+func (m *WhatsappMutation) AddOrganizationID(u int64) {
+	if m.addorganization_id != nil {
+		*m.addorganization_id += u
+	} else {
+		m.addorganization_id = &u
+	}
+}
+
+// AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
+func (m *WhatsappMutation) AddedOrganizationID() (r int64, exists bool) {
+	v := m.addorganization_id
+	if v == nil {
+		return
+	}
+	return *v, true
+}
+
+// ClearOrganizationID clears the value of the "organization_id" field.
+func (m *WhatsappMutation) ClearOrganizationID() {
+	m.organization_id = nil
+	m.addorganization_id = nil
+	m.clearedFields[whatsapp.FieldOrganizationID] = struct{}{}
+}
+
+// OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
+func (m *WhatsappMutation) OrganizationIDCleared() bool {
+	_, ok := m.clearedFields[whatsapp.FieldOrganizationID]
+	return ok
+}
+
+// ResetOrganizationID resets all changes to the "organization_id" field.
+func (m *WhatsappMutation) ResetOrganizationID() {
+	m.organization_id = nil
+	m.addorganization_id = nil
+	delete(m.clearedFields, whatsapp.FieldOrganizationID)
+}
+
+// SetAgentID sets the "agent_id" field.
+func (m *WhatsappMutation) SetAgentID(u uint64) {
+	m.agent_id = &u
+	m.addagent_id = nil
+}
+
+// AgentID returns the value of the "agent_id" field in the mutation.
+func (m *WhatsappMutation) AgentID() (r uint64, exists bool) {
+	v := m.agent_id
+	if v == nil {
+		return
+	}
+	return *v, true
+}
+
+// OldAgentID returns the old "agent_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) OldAgentID(ctx context.Context) (v uint64, err error) {
+	if !m.op.Is(OpUpdateOne) {
+		return v, errors.New("OldAgentID is only allowed on UpdateOne operations")
+	}
+	if m.id == nil || m.oldValue == nil {
+		return v, errors.New("OldAgentID requires an ID field in the mutation")
+	}
+	oldValue, err := m.oldValue(ctx)
+	if err != nil {
+		return v, fmt.Errorf("querying old value for OldAgentID: %w", err)
+	}
+	return oldValue.AgentID, nil
+}
+
+// AddAgentID adds u to the "agent_id" field.
+func (m *WhatsappMutation) AddAgentID(u int64) {
+	if m.addagent_id != nil {
+		*m.addagent_id += u
+	} else {
+		m.addagent_id = &u
+	}
+}
+
+// AddedAgentID returns the value that was added to the "agent_id" field in this mutation.
+func (m *WhatsappMutation) AddedAgentID() (r int64, exists bool) {
+	v := m.addagent_id
+	if v == nil {
+		return
+	}
+	return *v, true
+}
+
+// ResetAgentID resets all changes to the "agent_id" field.
+func (m *WhatsappMutation) ResetAgentID() {
+	m.agent_id = nil
+	m.addagent_id = nil
+}
+
+// SetAPIBase sets the "api_base" field.
+func (m *WhatsappMutation) SetAPIBase(s string) {
+	m.api_base = &s
+}
+
+// APIBase returns the value of the "api_base" field in the mutation.
+func (m *WhatsappMutation) APIBase() (r string, exists bool) {
+	v := m.api_base
+	if v == nil {
+		return
+	}
+	return *v, true
+}
+
+// OldAPIBase returns the old "api_base" 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) OldAPIBase(ctx context.Context) (v string, err error) {
+	if !m.op.Is(OpUpdateOne) {
+		return v, errors.New("OldAPIBase is only allowed on UpdateOne operations")
+	}
+	if m.id == nil || m.oldValue == nil {
+		return v, errors.New("OldAPIBase requires an ID field in the mutation")
+	}
+	oldValue, err := m.oldValue(ctx)
+	if err != nil {
+		return v, fmt.Errorf("querying old value for OldAPIBase: %w", err)
+	}
+	return oldValue.APIBase, nil
+}
+
+// ClearAPIBase clears the value of the "api_base" field.
+func (m *WhatsappMutation) ClearAPIBase() {
+	m.api_base = nil
+	m.clearedFields[whatsapp.FieldAPIBase] = struct{}{}
+}
+
+// APIBaseCleared returns if the "api_base" field was cleared in this mutation.
+func (m *WhatsappMutation) APIBaseCleared() bool {
+	_, ok := m.clearedFields[whatsapp.FieldAPIBase]
+	return ok
+}
+
+// ResetAPIBase resets all changes to the "api_base" field.
+func (m *WhatsappMutation) ResetAPIBase() {
+	m.api_base = nil
+	delete(m.clearedFields, whatsapp.FieldAPIBase)
+}
+
+// SetAPIKey sets the "api_key" field.
+func (m *WhatsappMutation) SetAPIKey(s string) {
+	m.api_key = &s
+}
+
+// APIKey returns the value of the "api_key" field in the mutation.
+func (m *WhatsappMutation) APIKey() (r string, exists bool) {
+	v := m.api_key
+	if v == nil {
+		return
+	}
+	return *v, true
+}
+
+// OldAPIKey returns the old "api_key" 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) OldAPIKey(ctx context.Context) (v string, err error) {
+	if !m.op.Is(OpUpdateOne) {
+		return v, errors.New("OldAPIKey is only allowed on UpdateOne operations")
+	}
+	if m.id == nil || m.oldValue == nil {
+		return v, errors.New("OldAPIKey requires an ID field in the mutation")
+	}
+	oldValue, err := m.oldValue(ctx)
+	if err != nil {
+		return v, fmt.Errorf("querying old value for OldAPIKey: %w", err)
+	}
+	return oldValue.APIKey, nil
+}
+
+// ClearAPIKey clears the value of the "api_key" field.
+func (m *WhatsappMutation) ClearAPIKey() {
+	m.api_key = nil
+	m.clearedFields[whatsapp.FieldAPIKey] = struct{}{}
+}
+
+// APIKeyCleared returns if the "api_key" field was cleared in this mutation.
+func (m *WhatsappMutation) APIKeyCleared() bool {
+	_, ok := m.clearedFields[whatsapp.FieldAPIKey]
+	return ok
+}
+
+// ResetAPIKey resets all changes to the "api_key" field.
+func (m *WhatsappMutation) ResetAPIKey() {
+	m.api_key = nil
+	delete(m.clearedFields, whatsapp.FieldAPIKey)
+}
+
+// SetAllowList sets the "allow_list" field.
+func (m *WhatsappMutation) SetAllowList(s []string) {
+	m.allow_list = &s
+	m.appendallow_list = nil
+}
+
+// AllowList returns the value of the "allow_list" field in the mutation.
+func (m *WhatsappMutation) AllowList() (r []string, exists bool) {
+	v := m.allow_list
+	if v == nil {
+		return
+	}
+	return *v, true
+}
+
+// OldAllowList returns the old "allow_list" 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) OldAllowList(ctx context.Context) (v []string, err error) {
+	if !m.op.Is(OpUpdateOne) {
+		return v, errors.New("OldAllowList is only allowed on UpdateOne operations")
+	}
+	if m.id == nil || m.oldValue == nil {
+		return v, errors.New("OldAllowList requires an ID field in the mutation")
+	}
+	oldValue, err := m.oldValue(ctx)
+	if err != nil {
+		return v, fmt.Errorf("querying old value for OldAllowList: %w", err)
+	}
+	return oldValue.AllowList, nil
+}
+
+// AppendAllowList adds s to the "allow_list" field.
+func (m *WhatsappMutation) AppendAllowList(s []string) {
+	m.appendallow_list = append(m.appendallow_list, s...)
+}
+
+// AppendedAllowList returns the list of values that were appended to the "allow_list" field in this mutation.
+func (m *WhatsappMutation) AppendedAllowList() ([]string, bool) {
+	if len(m.appendallow_list) == 0 {
+		return nil, false
+	}
+	return m.appendallow_list, true
+}
+
+// ResetAllowList resets all changes to the "allow_list" field.
+func (m *WhatsappMutation) ResetAllowList() {
+	m.allow_list = nil
+	m.appendallow_list = nil
+}
+
+// SetGroupAllowList sets the "group_allow_list" field.
+func (m *WhatsappMutation) SetGroupAllowList(s []string) {
+	m.group_allow_list = &s
+	m.appendgroup_allow_list = nil
+}
+
+// GroupAllowList returns the value of the "group_allow_list" field in the mutation.
+func (m *WhatsappMutation) GroupAllowList() (r []string, exists bool) {
+	v := m.group_allow_list
+	if v == nil {
+		return
+	}
+	return *v, true
+}
+
+// OldGroupAllowList returns the old "group_allow_list" 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) OldGroupAllowList(ctx context.Context) (v []string, err error) {
+	if !m.op.Is(OpUpdateOne) {
+		return v, errors.New("OldGroupAllowList is only allowed on UpdateOne operations")
+	}
+	if m.id == nil || m.oldValue == nil {
+		return v, errors.New("OldGroupAllowList requires an ID field in the mutation")
+	}
+	oldValue, err := m.oldValue(ctx)
+	if err != nil {
+		return v, fmt.Errorf("querying old value for OldGroupAllowList: %w", err)
+	}
+	return oldValue.GroupAllowList, nil
+}
+
+// AppendGroupAllowList adds s to the "group_allow_list" field.
+func (m *WhatsappMutation) AppendGroupAllowList(s []string) {
+	m.appendgroup_allow_list = append(m.appendgroup_allow_list, s...)
+}
+
+// AppendedGroupAllowList returns the list of values that were appended to the "group_allow_list" field in this mutation.
+func (m *WhatsappMutation) AppendedGroupAllowList() ([]string, bool) {
+	if len(m.appendgroup_allow_list) == 0 {
+		return nil, false
+	}
+	return m.appendgroup_allow_list, true
+}
+
+// ResetGroupAllowList resets all changes to the "group_allow_list" field.
+func (m *WhatsappMutation) ResetGroupAllowList() {
+	m.group_allow_list = nil
+	m.appendgroup_allow_list = nil
+}
+
+// SetBlockList sets the "block_list" field.
+func (m *WhatsappMutation) SetBlockList(s []string) {
+	m.block_list = &s
+	m.appendblock_list = nil
+}
+
+// BlockList returns the value of the "block_list" field in the mutation.
+func (m *WhatsappMutation) BlockList() (r []string, exists bool) {
+	v := m.block_list
+	if v == nil {
+		return
+	}
+	return *v, true
+}
+
+// OldBlockList returns the old "block_list" 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) OldBlockList(ctx context.Context) (v []string, err error) {
+	if !m.op.Is(OpUpdateOne) {
+		return v, errors.New("OldBlockList is only allowed on UpdateOne operations")
+	}
+	if m.id == nil || m.oldValue == nil {
+		return v, errors.New("OldBlockList requires an ID field in the mutation")
+	}
+	oldValue, err := m.oldValue(ctx)
+	if err != nil {
+		return v, fmt.Errorf("querying old value for OldBlockList: %w", err)
+	}
+	return oldValue.BlockList, nil
+}
+
+// AppendBlockList adds s to the "block_list" field.
+func (m *WhatsappMutation) AppendBlockList(s []string) {
+	m.appendblock_list = append(m.appendblock_list, s...)
+}
+
+// AppendedBlockList returns the list of values that were appended to the "block_list" field in this mutation.
+func (m *WhatsappMutation) AppendedBlockList() ([]string, bool) {
+	if len(m.appendblock_list) == 0 {
+		return nil, false
+	}
+	return m.appendblock_list, true
+}
+
+// ResetBlockList resets all changes to the "block_list" field.
+func (m *WhatsappMutation) ResetBlockList() {
+	m.block_list = nil
+	m.appendblock_list = nil
+}
+
+// SetGroupBlockList sets the "group_block_list" field.
+func (m *WhatsappMutation) SetGroupBlockList(s []string) {
+	m.group_block_list = &s
+	m.appendgroup_block_list = nil
+}
+
+// GroupBlockList returns the value of the "group_block_list" field in the mutation.
+func (m *WhatsappMutation) GroupBlockList() (r []string, exists bool) {
+	v := m.group_block_list
+	if v == nil {
+		return
+	}
+	return *v, true
+}
+
+// OldGroupBlockList returns the old "group_block_list" 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) OldGroupBlockList(ctx context.Context) (v []string, err error) {
+	if !m.op.Is(OpUpdateOne) {
+		return v, errors.New("OldGroupBlockList is only allowed on UpdateOne operations")
+	}
+	if m.id == nil || m.oldValue == nil {
+		return v, errors.New("OldGroupBlockList requires an ID field in the mutation")
+	}
+	oldValue, err := m.oldValue(ctx)
+	if err != nil {
+		return v, fmt.Errorf("querying old value for OldGroupBlockList: %w", err)
+	}
+	return oldValue.GroupBlockList, nil
+}
+
+// AppendGroupBlockList adds s to the "group_block_list" field.
+func (m *WhatsappMutation) AppendGroupBlockList(s []string) {
+	m.appendgroup_block_list = append(m.appendgroup_block_list, s...)
+}
+
+// AppendedGroupBlockList returns the list of values that were appended to the "group_block_list" field in this mutation.
+func (m *WhatsappMutation) AppendedGroupBlockList() ([]string, bool) {
+	if len(m.appendgroup_block_list) == 0 {
+		return nil, false
+	}
+	return m.appendgroup_block_list, true
+}
+
+// ResetGroupBlockList resets all changes to the "group_block_list" field.
+func (m *WhatsappMutation) ResetGroupBlockList() {
+	m.group_block_list = nil
+	m.appendgroup_block_list = nil
+}
+
+// Where appends a list predicates to the WhatsappMutation builder.
+func (m *WhatsappMutation) Where(ps ...predicate.Whatsapp) {
+	m.predicates = append(m.predicates, ps...)
+}
+
+// WhereP appends storage-level predicates to the WhatsappMutation builder. Using this method,
+// users can use type-assertion to append predicates that do not depend on any generated package.
+func (m *WhatsappMutation) WhereP(ps ...func(*sql.Selector)) {
+	p := make([]predicate.Whatsapp, len(ps))
+	for i := range ps {
+		p[i] = ps[i]
+	}
+	m.Where(p...)
+}
+
+// Op returns the operation name.
+func (m *WhatsappMutation) Op() Op {
+	return m.op
+}
+
+// SetOp allows setting the mutation operation.
+func (m *WhatsappMutation) SetOp(op Op) {
+	m.op = op
+}
+
+// Type returns the node type of this mutation (Whatsapp).
+func (m *WhatsappMutation) Type() string {
+	return m.typ
+}
+
+// Fields returns all fields that were changed during this mutation. Note that in
+// order to get all numeric fields that were incremented/decremented, call
+// AddedFields().
+func (m *WhatsappMutation) Fields() []string {
+	fields := make([]string, 0, 18)
+	if m.created_at != nil {
+		fields = append(fields, whatsapp.FieldCreatedAt)
+	}
+	if m.updated_at != nil {
+		fields = append(fields, whatsapp.FieldUpdatedAt)
+	}
+	if m.status != nil {
+		fields = append(fields, whatsapp.FieldStatus)
+	}
+	if m.deleted_at != nil {
+		fields = append(fields, whatsapp.FieldDeletedAt)
+	}
+	if m.ak != nil {
+		fields = append(fields, whatsapp.FieldAk)
+	}
+	if m.sk != nil {
+		fields = append(fields, whatsapp.FieldSk)
+	}
+	if m.callback != nil {
+		fields = append(fields, whatsapp.FieldCallback)
+	}
+	if m.account != nil {
+		fields = append(fields, whatsapp.FieldAccount)
+	}
+	if m.nickname != nil {
+		fields = append(fields, whatsapp.FieldNickname)
+	}
+	if m.phone != nil {
+		fields = append(fields, whatsapp.FieldPhone)
+	}
+	if m.organization_id != nil {
+		fields = append(fields, whatsapp.FieldOrganizationID)
+	}
+	if m.agent_id != nil {
+		fields = append(fields, whatsapp.FieldAgentID)
+	}
+	if m.api_base != nil {
+		fields = append(fields, whatsapp.FieldAPIBase)
+	}
+	if m.api_key != nil {
+		fields = append(fields, whatsapp.FieldAPIKey)
+	}
+	if m.allow_list != nil {
+		fields = append(fields, whatsapp.FieldAllowList)
+	}
+	if m.group_allow_list != nil {
+		fields = append(fields, whatsapp.FieldGroupAllowList)
+	}
+	if m.block_list != nil {
+		fields = append(fields, whatsapp.FieldBlockList)
+	}
+	if m.group_block_list != nil {
+		fields = append(fields, whatsapp.FieldGroupBlockList)
+	}
+	return fields
+}
+
+// Field returns the value of a field with the given name. The second boolean
+// return value indicates that this field was not set, or was not defined in the
+// schema.
+func (m *WhatsappMutation) Field(name string) (ent.Value, bool) {
+	switch name {
+	case whatsapp.FieldCreatedAt:
+		return m.CreatedAt()
+	case whatsapp.FieldUpdatedAt:
+		return m.UpdatedAt()
+	case whatsapp.FieldStatus:
+		return m.Status()
+	case whatsapp.FieldDeletedAt:
+		return m.DeletedAt()
+	case whatsapp.FieldAk:
+		return m.Ak()
+	case whatsapp.FieldSk:
+		return m.Sk()
+	case whatsapp.FieldCallback:
+		return m.Callback()
+	case whatsapp.FieldAccount:
+		return m.Account()
+	case whatsapp.FieldNickname:
+		return m.Nickname()
+	case whatsapp.FieldPhone:
+		return m.Phone()
+	case whatsapp.FieldOrganizationID:
+		return m.OrganizationID()
+	case whatsapp.FieldAgentID:
+		return m.AgentID()
+	case whatsapp.FieldAPIBase:
+		return m.APIBase()
+	case whatsapp.FieldAPIKey:
+		return m.APIKey()
+	case whatsapp.FieldAllowList:
+		return m.AllowList()
+	case whatsapp.FieldGroupAllowList:
+		return m.GroupAllowList()
+	case whatsapp.FieldBlockList:
+		return m.BlockList()
+	case whatsapp.FieldGroupBlockList:
+		return m.GroupBlockList()
+	}
+	return nil, false
+}
+
+// OldField returns the old value of the field from the database. An error is
+// returned if the mutation operation is not UpdateOne, or the query to the
+// database failed.
+func (m *WhatsappMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
+	switch name {
+	case whatsapp.FieldCreatedAt:
+		return m.OldCreatedAt(ctx)
+	case whatsapp.FieldUpdatedAt:
+		return m.OldUpdatedAt(ctx)
+	case whatsapp.FieldStatus:
+		return m.OldStatus(ctx)
+	case whatsapp.FieldDeletedAt:
+		return m.OldDeletedAt(ctx)
+	case whatsapp.FieldAk:
+		return m.OldAk(ctx)
+	case whatsapp.FieldSk:
+		return m.OldSk(ctx)
+	case whatsapp.FieldCallback:
+		return m.OldCallback(ctx)
+	case whatsapp.FieldAccount:
+		return m.OldAccount(ctx)
+	case whatsapp.FieldNickname:
+		return m.OldNickname(ctx)
+	case whatsapp.FieldPhone:
+		return m.OldPhone(ctx)
+	case whatsapp.FieldOrganizationID:
+		return m.OldOrganizationID(ctx)
+	case whatsapp.FieldAgentID:
+		return m.OldAgentID(ctx)
+	case whatsapp.FieldAPIBase:
+		return m.OldAPIBase(ctx)
+	case whatsapp.FieldAPIKey:
+		return m.OldAPIKey(ctx)
+	case whatsapp.FieldAllowList:
+		return m.OldAllowList(ctx)
+	case whatsapp.FieldGroupAllowList:
+		return m.OldGroupAllowList(ctx)
+	case whatsapp.FieldBlockList:
+		return m.OldBlockList(ctx)
+	case whatsapp.FieldGroupBlockList:
+		return m.OldGroupBlockList(ctx)
+	}
+	return nil, fmt.Errorf("unknown Whatsapp field %s", name)
+}
+
+// SetField sets the value of a field with the given name. It returns an error if
+// the field is not defined in the schema, or if the type mismatched the field
+// type.
+func (m *WhatsappMutation) SetField(name string, value ent.Value) error {
+	switch name {
+	case whatsapp.FieldCreatedAt:
+		v, ok := value.(time.Time)
+		if !ok {
+			return fmt.Errorf("unexpected type %T for field %s", value, name)
+		}
+		m.SetCreatedAt(v)
+		return nil
+	case whatsapp.FieldUpdatedAt:
+		v, ok := value.(time.Time)
+		if !ok {
+			return fmt.Errorf("unexpected type %T for field %s", value, name)
+		}
+		m.SetUpdatedAt(v)
+		return nil
+	case whatsapp.FieldStatus:
+		v, ok := value.(uint8)
+		if !ok {
+			return fmt.Errorf("unexpected type %T for field %s", value, name)
+		}
+		m.SetStatus(v)
+		return nil
+	case whatsapp.FieldDeletedAt:
+		v, ok := value.(time.Time)
+		if !ok {
+			return fmt.Errorf("unexpected type %T for field %s", value, name)
+		}
+		m.SetDeletedAt(v)
+		return nil
+	case whatsapp.FieldAk:
+		v, ok := value.(string)
+		if !ok {
+			return fmt.Errorf("unexpected type %T for field %s", value, name)
+		}
+		m.SetAk(v)
+		return nil
+	case whatsapp.FieldSk:
+		v, ok := value.(string)
+		if !ok {
+			return fmt.Errorf("unexpected type %T for field %s", value, name)
+		}
+		m.SetSk(v)
+		return nil
+	case whatsapp.FieldCallback:
+		v, ok := value.(string)
+		if !ok {
+			return fmt.Errorf("unexpected type %T for field %s", value, name)
+		}
+		m.SetCallback(v)
+		return nil
+	case whatsapp.FieldAccount:
+		v, ok := value.(string)
+		if !ok {
+			return fmt.Errorf("unexpected type %T for field %s", value, name)
+		}
+		m.SetAccount(v)
+		return nil
+	case whatsapp.FieldNickname:
+		v, ok := value.(string)
+		if !ok {
+			return fmt.Errorf("unexpected type %T for field %s", value, name)
+		}
+		m.SetNickname(v)
+		return nil
+	case whatsapp.FieldPhone:
+		v, ok := value.(string)
+		if !ok {
+			return fmt.Errorf("unexpected type %T for field %s", value, name)
+		}
+		m.SetPhone(v)
+		return nil
+	case whatsapp.FieldOrganizationID:
+		v, ok := value.(uint64)
+		if !ok {
+			return fmt.Errorf("unexpected type %T for field %s", value, name)
+		}
+		m.SetOrganizationID(v)
+		return nil
+	case whatsapp.FieldAgentID:
+		v, ok := value.(uint64)
+		if !ok {
+			return fmt.Errorf("unexpected type %T for field %s", value, name)
+		}
+		m.SetAgentID(v)
+		return nil
+	case whatsapp.FieldAPIBase:
+		v, ok := value.(string)
+		if !ok {
+			return fmt.Errorf("unexpected type %T for field %s", value, name)
+		}
+		m.SetAPIBase(v)
+		return nil
+	case whatsapp.FieldAPIKey:
+		v, ok := value.(string)
+		if !ok {
+			return fmt.Errorf("unexpected type %T for field %s", value, name)
+		}
+		m.SetAPIKey(v)
+		return nil
+	case whatsapp.FieldAllowList:
+		v, ok := value.([]string)
+		if !ok {
+			return fmt.Errorf("unexpected type %T for field %s", value, name)
+		}
+		m.SetAllowList(v)
+		return nil
+	case whatsapp.FieldGroupAllowList:
+		v, ok := value.([]string)
+		if !ok {
+			return fmt.Errorf("unexpected type %T for field %s", value, name)
+		}
+		m.SetGroupAllowList(v)
+		return nil
+	case whatsapp.FieldBlockList:
+		v, ok := value.([]string)
+		if !ok {
+			return fmt.Errorf("unexpected type %T for field %s", value, name)
+		}
+		m.SetBlockList(v)
+		return nil
+	case whatsapp.FieldGroupBlockList:
+		v, ok := value.([]string)
+		if !ok {
+			return fmt.Errorf("unexpected type %T for field %s", value, name)
+		}
+		m.SetGroupBlockList(v)
+		return nil
+	}
+	return fmt.Errorf("unknown Whatsapp field %s", name)
+}
+
+// AddedFields returns all numeric fields that were incremented/decremented during
+// this mutation.
+func (m *WhatsappMutation) AddedFields() []string {
+	var fields []string
+	if m.addstatus != nil {
+		fields = append(fields, whatsapp.FieldStatus)
+	}
+	if m.addorganization_id != nil {
+		fields = append(fields, whatsapp.FieldOrganizationID)
+	}
+	if m.addagent_id != nil {
+		fields = append(fields, whatsapp.FieldAgentID)
+	}
+	return fields
+}
+
+// AddedField returns the numeric value that was incremented/decremented on a field
+// with the given name. The second boolean return value indicates that this field
+// was not set, or was not defined in the schema.
+func (m *WhatsappMutation) AddedField(name string) (ent.Value, bool) {
+	switch name {
+	case whatsapp.FieldStatus:
+		return m.AddedStatus()
+	case whatsapp.FieldOrganizationID:
+		return m.AddedOrganizationID()
+	case whatsapp.FieldAgentID:
+		return m.AddedAgentID()
+	}
+	return nil, false
+}
+
+// AddField adds the value to the field with the given name. It returns an error if
+// the field is not defined in the schema, or if the type mismatched the field
+// type.
+func (m *WhatsappMutation) AddField(name string, value ent.Value) error {
+	switch name {
+	case whatsapp.FieldStatus:
+		v, ok := value.(int8)
+		if !ok {
+			return fmt.Errorf("unexpected type %T for field %s", value, name)
+		}
+		m.AddStatus(v)
+		return nil
+	case whatsapp.FieldOrganizationID:
+		v, ok := value.(int64)
+		if !ok {
+			return fmt.Errorf("unexpected type %T for field %s", value, name)
+		}
+		m.AddOrganizationID(v)
+		return nil
+	case whatsapp.FieldAgentID:
+		v, ok := value.(int64)
+		if !ok {
+			return fmt.Errorf("unexpected type %T for field %s", value, name)
+		}
+		m.AddAgentID(v)
+		return nil
+	}
+	return fmt.Errorf("unknown Whatsapp numeric field %s", name)
+}
+
+// ClearedFields returns all nullable fields that were cleared during this
+// mutation.
+func (m *WhatsappMutation) ClearedFields() []string {
+	var fields []string
+	if m.FieldCleared(whatsapp.FieldStatus) {
+		fields = append(fields, whatsapp.FieldStatus)
+	}
+	if m.FieldCleared(whatsapp.FieldDeletedAt) {
+		fields = append(fields, whatsapp.FieldDeletedAt)
+	}
+	if m.FieldCleared(whatsapp.FieldAk) {
+		fields = append(fields, whatsapp.FieldAk)
+	}
+	if m.FieldCleared(whatsapp.FieldOrganizationID) {
+		fields = append(fields, whatsapp.FieldOrganizationID)
+	}
+	if m.FieldCleared(whatsapp.FieldAPIBase) {
+		fields = append(fields, whatsapp.FieldAPIBase)
+	}
+	if m.FieldCleared(whatsapp.FieldAPIKey) {
+		fields = append(fields, whatsapp.FieldAPIKey)
+	}
+	return fields
+}
+
+// FieldCleared returns a boolean indicating if a field with the given name was
+// cleared in this mutation.
+func (m *WhatsappMutation) FieldCleared(name string) bool {
+	_, ok := m.clearedFields[name]
+	return ok
+}
+
+// ClearField clears the value of the field with the given name. It returns an
+// error if the field is not defined in the schema.
+func (m *WhatsappMutation) ClearField(name string) error {
+	switch name {
+	case whatsapp.FieldStatus:
+		m.ClearStatus()
+		return nil
+	case whatsapp.FieldDeletedAt:
+		m.ClearDeletedAt()
+		return nil
+	case whatsapp.FieldAk:
+		m.ClearAk()
+		return nil
+	case whatsapp.FieldOrganizationID:
+		m.ClearOrganizationID()
+		return nil
+	case whatsapp.FieldAPIBase:
+		m.ClearAPIBase()
+		return nil
+	case whatsapp.FieldAPIKey:
+		m.ClearAPIKey()
+		return nil
+	}
+	return fmt.Errorf("unknown Whatsapp nullable field %s", name)
+}
+
+// ResetField resets all changes in the mutation for the field with the given name.
+// It returns an error if the field is not defined in the schema.
+func (m *WhatsappMutation) ResetField(name string) error {
+	switch name {
+	case whatsapp.FieldCreatedAt:
+		m.ResetCreatedAt()
+		return nil
+	case whatsapp.FieldUpdatedAt:
+		m.ResetUpdatedAt()
+		return nil
+	case whatsapp.FieldStatus:
+		m.ResetStatus()
+		return nil
+	case whatsapp.FieldDeletedAt:
+		m.ResetDeletedAt()
+		return nil
+	case whatsapp.FieldAk:
+		m.ResetAk()
+		return nil
+	case whatsapp.FieldSk:
+		m.ResetSk()
+		return nil
+	case whatsapp.FieldCallback:
+		m.ResetCallback()
+		return nil
+	case whatsapp.FieldAccount:
+		m.ResetAccount()
+		return nil
+	case whatsapp.FieldNickname:
+		m.ResetNickname()
+		return nil
+	case whatsapp.FieldPhone:
+		m.ResetPhone()
+		return nil
+	case whatsapp.FieldOrganizationID:
+		m.ResetOrganizationID()
+		return nil
+	case whatsapp.FieldAgentID:
+		m.ResetAgentID()
+		return nil
+	case whatsapp.FieldAPIBase:
+		m.ResetAPIBase()
+		return nil
+	case whatsapp.FieldAPIKey:
+		m.ResetAPIKey()
+		return nil
+	case whatsapp.FieldAllowList:
+		m.ResetAllowList()
+		return nil
+	case whatsapp.FieldGroupAllowList:
+		m.ResetGroupAllowList()
+		return nil
+	case whatsapp.FieldBlockList:
+		m.ResetBlockList()
+		return nil
+	case whatsapp.FieldGroupBlockList:
+		m.ResetGroupBlockList()
+		return nil
+	}
+	return fmt.Errorf("unknown Whatsapp field %s", name)
+}
+
+// AddedEdges returns all edge names that were set/added in this mutation.
+func (m *WhatsappMutation) AddedEdges() []string {
+	edges := make([]string, 0, 0)
+	return edges
+}
+
+// AddedIDs returns all IDs (to other nodes) that were added for the given edge
+// name in this mutation.
+func (m *WhatsappMutation) AddedIDs(name string) []ent.Value {
+	return nil
+}
+
+// RemovedEdges returns all edge names that were removed in this mutation.
+func (m *WhatsappMutation) RemovedEdges() []string {
+	edges := make([]string, 0, 0)
+	return edges
+}
+
+// RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
+// the given name in this mutation.
+func (m *WhatsappMutation) RemovedIDs(name string) []ent.Value {
+	return nil
+}
+
+// ClearedEdges returns all edge names that were cleared in this mutation.
+func (m *WhatsappMutation) ClearedEdges() []string {
+	edges := make([]string, 0, 0)
+	return edges
+}
+
+// EdgeCleared returns a boolean which indicates if the edge with the given name
+// was cleared in this mutation.
+func (m *WhatsappMutation) EdgeCleared(name string) bool {
+	return false
+}
+
+// ClearEdge clears the value of the edge with the given name. It returns an error
+// if that edge is not defined in the schema.
+func (m *WhatsappMutation) ClearEdge(name string) error {
+	return fmt.Errorf("unknown Whatsapp unique edge %s", name)
+}
+
+// ResetEdge resets all changes to the edge with the given name in this mutation.
+// It returns an error if the edge is not defined in the schema.
+func (m *WhatsappMutation) ResetEdge(name string) error {
+	return fmt.Errorf("unknown Whatsapp edge %s", name)
+}
+
 // WorkExperienceMutation represents an operation that mutates the WorkExperience nodes in the graph.
 type WorkExperienceMutation struct {
 	config

+ 82 - 0
ent/pagination.go

@@ -36,6 +36,7 @@ import (
 	"wechat-api/ent/usagestatistichour"
 	"wechat-api/ent/usagestatisticmonth"
 	"wechat-api/ent/usagetotal"
+	"wechat-api/ent/whatsapp"
 	"wechat-api/ent/workexperience"
 	"wechat-api/ent/wpchatroom"
 	"wechat-api/ent/wpchatroommember"
@@ -2602,6 +2603,87 @@ func (ut *UsageTotalQuery) Page(
 	return ret, nil
 }
 
+type WhatsappPager struct {
+	Order  whatsapp.OrderOption
+	Filter func(*WhatsappQuery) (*WhatsappQuery, error)
+}
+
+// WhatsappPaginateOption enables pagination customization.
+type WhatsappPaginateOption func(*WhatsappPager)
+
+// DefaultWhatsappOrder is the default ordering of Whatsapp.
+var DefaultWhatsappOrder = Desc(whatsapp.FieldID)
+
+func newWhatsappPager(opts []WhatsappPaginateOption) (*WhatsappPager, error) {
+	pager := &WhatsappPager{}
+	for _, opt := range opts {
+		opt(pager)
+	}
+	if pager.Order == nil {
+		pager.Order = DefaultWhatsappOrder
+	}
+	return pager, nil
+}
+
+func (p *WhatsappPager) ApplyFilter(query *WhatsappQuery) (*WhatsappQuery, error) {
+	if p.Filter != nil {
+		return p.Filter(query)
+	}
+	return query, nil
+}
+
+// WhatsappPageList is Whatsapp PageList result.
+type WhatsappPageList struct {
+	List        []*Whatsapp  `json:"list"`
+	PageDetails *PageDetails `json:"pageDetails"`
+}
+
+func (w *WhatsappQuery) Page(
+	ctx context.Context, pageNum uint64, pageSize uint64, opts ...WhatsappPaginateOption,
+) (*WhatsappPageList, error) {
+
+	pager, err := newWhatsappPager(opts)
+	if err != nil {
+		return nil, err
+	}
+
+	if w, err = pager.ApplyFilter(w); err != nil {
+		return nil, err
+	}
+
+	ret := &WhatsappPageList{}
+
+	ret.PageDetails = &PageDetails{
+		Page: pageNum,
+		Size: pageSize,
+	}
+
+	query := w.Clone()
+	query.ctx.Fields = nil
+	count, err := query.Count(ctx)
+
+	if err != nil {
+		return nil, err
+	}
+
+	ret.PageDetails.Total = uint64(count)
+
+	if pager.Order != nil {
+		w = w.Order(pager.Order)
+	} else {
+		w = w.Order(DefaultWhatsappOrder)
+	}
+
+	w = w.Offset(int((pageNum - 1) * pageSize)).Limit(int(pageSize))
+	list, err := w.All(ctx)
+	if err != nil {
+		return nil, err
+	}
+	ret.List = list
+
+	return ret, nil
+}
+
 type WorkExperiencePager struct {
 	Order  workexperience.OrderOption
 	Filter func(*WorkExperienceQuery) (*WorkExperienceQuery, error)

+ 2 - 0
ent/payrecharge/payrecharge.go

@@ -86,6 +86,8 @@ var (
 	DefaultMoney float32
 	// DefaultOutTradeNo holds the default value on creation for the "out_trade_no" field.
 	DefaultOutTradeNo string
+	// DefaultOrganizationID holds the default value on creation for the "organization_id" field.
+	DefaultOrganizationID uint64
 	// OrganizationIDValidator is a validator for the "organization_id" field. It is called by the builders before save.
 	OrganizationIDValidator func(uint64) error
 )

+ 12 - 0
ent/payrecharge_create.go

@@ -132,6 +132,14 @@ func (prc *PayRechargeCreate) SetOrganizationID(u uint64) *PayRechargeCreate {
 	return prc
 }
 
+// SetNillableOrganizationID sets the "organization_id" field if the given value is not nil.
+func (prc *PayRechargeCreate) SetNillableOrganizationID(u *uint64) *PayRechargeCreate {
+	if u != nil {
+		prc.SetOrganizationID(*u)
+	}
+	return prc
+}
+
 // SetID sets the "id" field.
 func (prc *PayRechargeCreate) SetID(u uint64) *PayRechargeCreate {
 	prc.mutation.SetID(u)
@@ -205,6 +213,10 @@ func (prc *PayRechargeCreate) defaults() error {
 		v := payrecharge.DefaultOutTradeNo
 		prc.mutation.SetOutTradeNo(v)
 	}
+	if _, ok := prc.mutation.OrganizationID(); !ok {
+		v := payrecharge.DefaultOrganizationID
+		prc.mutation.SetOrganizationID(v)
+	}
 	return nil
 }
 

+ 3 - 0
ent/predicate/predicate.go

@@ -99,6 +99,9 @@ type UsageStatisticMonth func(*sql.Selector)
 // UsageTotal is the predicate function for usagetotal builders.
 type UsageTotal func(*sql.Selector)
 
+// Whatsapp is the predicate function for whatsapp builders.
+type Whatsapp func(*sql.Selector)
+
 // WorkExperience is the predicate function for workexperience builders.
 type WorkExperience func(*sql.Selector)
 

+ 72 - 0
ent/runtime/runtime.go

@@ -36,6 +36,7 @@ import (
 	"wechat-api/ent/usagestatistichour"
 	"wechat-api/ent/usagestatisticmonth"
 	"wechat-api/ent/usagetotal"
+	"wechat-api/ent/whatsapp"
 	"wechat-api/ent/workexperience"
 	"wechat-api/ent/wpchatroom"
 	"wechat-api/ent/wpchatroommember"
@@ -440,6 +441,8 @@ func init() {
 	creditbalance.StatusValidator = creditbalanceDescStatus.Validators[0].(func(int) error)
 	// creditbalanceDescOrganizationID is the schema descriptor for organization_id field.
 	creditbalanceDescOrganizationID := creditbalanceFields[3].Descriptor()
+	// creditbalance.DefaultOrganizationID holds the default value on creation for the organization_id field.
+	creditbalance.DefaultOrganizationID = creditbalanceDescOrganizationID.Default.(uint64)
 	// creditbalance.OrganizationIDValidator is a validator for the "organization_id" field. It is called by the builders before save.
 	creditbalance.OrganizationIDValidator = creditbalanceDescOrganizationID.Validators[0].(func(uint64) error)
 	creditusageMixin := schema.CreditUsage{}.Mixin()
@@ -481,6 +484,8 @@ func init() {
 	creditusage.DefaultTable = creditusageDescTable.Default.(string)
 	// creditusageDescOrganizationID is the schema descriptor for organization_id field.
 	creditusageDescOrganizationID := creditusageFields[5].Descriptor()
+	// creditusage.DefaultOrganizationID holds the default value on creation for the organization_id field.
+	creditusage.DefaultOrganizationID = creditusageDescOrganizationID.Default.(uint64)
 	// creditusage.OrganizationIDValidator is a validator for the "organization_id" field. It is called by the builders before save.
 	creditusage.OrganizationIDValidator = creditusageDescOrganizationID.Validators[0].(func(uint64) error)
 	// creditusageDescNid is the schema descriptor for nid field.
@@ -871,6 +876,8 @@ func init() {
 	payrecharge.DefaultOutTradeNo = payrechargeDescOutTradeNo.Default.(string)
 	// payrechargeDescOrganizationID is the schema descriptor for organization_id field.
 	payrechargeDescOrganizationID := payrechargeFields[5].Descriptor()
+	// payrecharge.DefaultOrganizationID holds the default value on creation for the organization_id field.
+	payrecharge.DefaultOrganizationID = payrechargeDescOrganizationID.Default.(uint64)
 	// payrecharge.OrganizationIDValidator is a validator for the "organization_id" field. It is called by the builders before save.
 	payrecharge.OrganizationIDValidator = payrechargeDescOrganizationID.Validators[0].(func(uint64) error)
 	serverMixin := schema.Server{}.Mixin()
@@ -1280,6 +1287,71 @@ func init() {
 	usagetotalDescOrganizationID := usagetotalFields[5].Descriptor()
 	// usagetotal.DefaultOrganizationID holds the default value on creation for the organization_id field.
 	usagetotal.DefaultOrganizationID = usagetotalDescOrganizationID.Default.(uint64)
+	whatsappMixin := schema.Whatsapp{}.Mixin()
+	whatsappMixinHooks2 := whatsappMixin[2].Hooks()
+	whatsapp.Hooks[0] = whatsappMixinHooks2[0]
+	whatsappMixinInters2 := whatsappMixin[2].Interceptors()
+	whatsapp.Interceptors[0] = whatsappMixinInters2[0]
+	whatsappMixinFields0 := whatsappMixin[0].Fields()
+	_ = whatsappMixinFields0
+	whatsappMixinFields1 := whatsappMixin[1].Fields()
+	_ = whatsappMixinFields1
+	whatsappFields := schema.Whatsapp{}.Fields()
+	_ = whatsappFields
+	// whatsappDescCreatedAt is the schema descriptor for created_at field.
+	whatsappDescCreatedAt := whatsappMixinFields0[1].Descriptor()
+	// whatsapp.DefaultCreatedAt holds the default value on creation for the created_at field.
+	whatsapp.DefaultCreatedAt = whatsappDescCreatedAt.Default.(func() time.Time)
+	// whatsappDescUpdatedAt is the schema descriptor for updated_at field.
+	whatsappDescUpdatedAt := whatsappMixinFields0[2].Descriptor()
+	// whatsapp.DefaultUpdatedAt holds the default value on creation for the updated_at field.
+	whatsapp.DefaultUpdatedAt = whatsappDescUpdatedAt.Default.(func() time.Time)
+	// whatsapp.UpdateDefaultUpdatedAt holds the default value on update for the updated_at field.
+	whatsapp.UpdateDefaultUpdatedAt = whatsappDescUpdatedAt.UpdateDefault.(func() time.Time)
+	// whatsappDescStatus is the schema descriptor for status field.
+	whatsappDescStatus := whatsappMixinFields1[0].Descriptor()
+	// whatsapp.DefaultStatus holds the default value on creation for the status field.
+	whatsapp.DefaultStatus = whatsappDescStatus.Default.(uint8)
+	// whatsappDescAk is the schema descriptor for ak field.
+	whatsappDescAk := whatsappFields[0].Descriptor()
+	// whatsapp.DefaultAk holds the default value on creation for the ak field.
+	whatsapp.DefaultAk = whatsappDescAk.Default.(string)
+	// whatsappDescSk is the schema descriptor for sk field.
+	whatsappDescSk := whatsappFields[1].Descriptor()
+	// whatsapp.DefaultSk holds the default value on creation for the sk field.
+	whatsapp.DefaultSk = whatsappDescSk.Default.(string)
+	// whatsappDescCallback is the schema descriptor for callback field.
+	whatsappDescCallback := whatsappFields[2].Descriptor()
+	// whatsapp.DefaultCallback holds the default value on creation for the callback field.
+	whatsapp.DefaultCallback = whatsappDescCallback.Default.(string)
+	// whatsappDescAccount is the schema descriptor for account field.
+	whatsappDescAccount := whatsappFields[3].Descriptor()
+	// whatsapp.DefaultAccount holds the default value on creation for the account field.
+	whatsapp.DefaultAccount = whatsappDescAccount.Default.(string)
+	// whatsappDescNickname is the schema descriptor for nickname field.
+	whatsappDescNickname := whatsappFields[4].Descriptor()
+	// whatsapp.DefaultNickname holds the default value on creation for the nickname field.
+	whatsapp.DefaultNickname = whatsappDescNickname.Default.(string)
+	// whatsappDescPhone is the schema descriptor for phone field.
+	whatsappDescPhone := whatsappFields[5].Descriptor()
+	// whatsapp.DefaultPhone holds the default value on creation for the phone field.
+	whatsapp.DefaultPhone = whatsappDescPhone.Default.(string)
+	// whatsappDescOrganizationID is the schema descriptor for organization_id field.
+	whatsappDescOrganizationID := whatsappFields[6].Descriptor()
+	// whatsapp.DefaultOrganizationID holds the default value on creation for the organization_id field.
+	whatsapp.DefaultOrganizationID = whatsappDescOrganizationID.Default.(uint64)
+	// whatsappDescAgentID is the schema descriptor for agent_id field.
+	whatsappDescAgentID := whatsappFields[7].Descriptor()
+	// whatsapp.DefaultAgentID holds the default value on creation for the agent_id field.
+	whatsapp.DefaultAgentID = whatsappDescAgentID.Default.(uint64)
+	// whatsappDescAPIBase is the schema descriptor for api_base field.
+	whatsappDescAPIBase := whatsappFields[8].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()
+	// whatsapp.DefaultAPIKey holds the default value on creation for the api_key field.
+	whatsapp.DefaultAPIKey = whatsappDescAPIKey.Default.(string)
 	workexperienceMixin := schema.WorkExperience{}.Mixin()
 	workexperienceMixinHooks1 := workexperienceMixin[1].Hooks()
 	workexperience.Hooks[0] = workexperienceMixinHooks1[0]

+ 1 - 1
ent/schema/credit_balance.go

@@ -20,7 +20,7 @@ func (CreditBalance) Fields() []ent.Field {
 		field.String("user_id").MaxLen(255).Comment("user_id | 用户ID"),
 		field.Float32("balance").Comment("role | 角色设定"),
 		field.Int("status").Optional().Range(1, 2).Default(1).Comment("status | 状态 1-正常 2-禁用"),
-		field.Uint64("organization_id").Positive().Comment("organization_id | 租户ID"),
+		field.Uint64("organization_id").Positive().Default(1).Comment("organization_id | 租户ID"),
 	}
 }
 

+ 1 - 1
ent/schema/credit_usage.go

@@ -22,7 +22,7 @@ func (CreditUsage) Fields() []ent.Field {
 		field.Int("status").Optional().Range(1, 2).Default(1).Comment("status | 状态 1-正常 2-禁用"),
 		field.Int("ntype").Default(1).Comment("ntype | 积分变化类型:1-消耗 2-增加"),
 		field.String("table").Default("").Comment("table | 积分变化表名"),
-		field.Uint64("organization_id").Positive().Comment("organization_id | 租户ID"),
+		field.Uint64("organization_id").Positive().Default(1).Comment("organization_id | 租户ID"),
 		field.Uint64("nid").Default(0).Comment("nid | 积分变化关联信息ID"),
 		field.String("reason").Default("").MaxLen(255).Comment("reason | 积分变动原因"),
 		field.String("operator").Default("").MaxLen(255).Comment("operator | 积分变动人"),

+ 1 - 1
ent/schema/pay_recharge.go

@@ -22,7 +22,7 @@ func (PayRecharge) Fields() []ent.Field {
 		field.Int("status").Optional().Range(1, 2).Default(1).Comment("status | 状态 1-正常 2-禁用"),
 		field.Float32("money").Optional().Default(0.0).Comment("money | 充值钱数"),
 		field.String("out_trade_no").Optional().Default("").Comment("out_trade_no | 外部订单号"),
-		field.Uint64("organization_id").Positive().Comment("organization_id | 租户ID"),
+		field.Uint64("organization_id").Positive().Default(1).Comment("organization_id | 租户ID"),
 	}
 }
 

+ 59 - 0
ent/schema/whatsapp.go

@@ -0,0 +1,59 @@
+package schema
+
+import (
+	"wechat-api/ent/schema/localmixin"
+
+	"entgo.io/ent"
+	"entgo.io/ent/dialect/entsql"
+	"entgo.io/ent/schema"
+	"entgo.io/ent/schema/field"
+	"entgo.io/ent/schema/index"
+	"github.com/suyuan32/simple-admin-common/orm/ent/mixins"
+)
+
+type Whatsapp struct {
+	ent.Schema
+}
+
+func (Whatsapp) Fields() []ent.Field {
+	return []ent.Field{
+		field.String("ak").Optional().Default("").Comment("ak"),
+		field.String("sk").Default("").Comment("端口号"),
+		field.String("callback").Default("").Comment("回调地址"),
+		field.String("account").Default("").Comment("微信账号"),
+		field.String("nickname").Default("").Comment("昵称"),
+		field.String("phone").Default("").Comment("手机号"),
+		field.Uint64("organization_id").Optional().Default(1).Comment("机构 ID"),
+		field.Uint64("agent_id").Default(0).Comment("模式ID"),
+		field.String("api_base").Optional().Default("").Comment("大模型服务地址"),
+		field.String("api_key").Optional().Default("").Comment("大模型服务密钥"),
+		field.JSON("allow_list", []string{}).Comment("白名单"),
+		field.JSON("group_allow_list", []string{}).Comment("群白名单"),
+		field.JSON("block_list", []string{}).Comment("黑名单"),
+		field.JSON("group_block_list", []string{}).Comment("群黑名单"),
+	}
+}
+
+func (Whatsapp) Mixin() []ent.Mixin {
+	return []ent.Mixin{
+		mixins.IDMixin{},
+		mixins.StatusMixin{},
+		localmixin.SoftDeleteMixin{},
+	}
+}
+
+func (Whatsapp) Indexes() []ent.Index {
+	return []ent.Index{
+		index.Fields("ak", "sk"),
+	}
+}
+
+func (Whatsapp) Edges() []ent.Edge {
+	return nil
+}
+
+func (Whatsapp) Annotations() []schema.Annotation {
+	return []schema.Annotation{
+		entsql.Annotation{Table: "whatsapp"},
+	}
+}

+ 408 - 0
ent/set_not_nil.go

@@ -7760,6 +7760,414 @@ func (ut *UsageTotalCreate) SetNotNilOrganizationID(value *uint64) *UsageTotalCr
 }
 
 // set field if value's pointer is not nil.
+func (w *WhatsappUpdate) SetNotNilUpdatedAt(value *time.Time) *WhatsappUpdate {
+	if value != nil {
+		return w.SetUpdatedAt(*value)
+	}
+	return w
+}
+
+// set field if value's pointer is not nil.
+func (w *WhatsappUpdateOne) SetNotNilUpdatedAt(value *time.Time) *WhatsappUpdateOne {
+	if value != nil {
+		return w.SetUpdatedAt(*value)
+	}
+	return w
+}
+
+// set field if value's pointer is not nil.
+func (w *WhatsappCreate) SetNotNilUpdatedAt(value *time.Time) *WhatsappCreate {
+	if value != nil {
+		return w.SetUpdatedAt(*value)
+	}
+	return w
+}
+
+// set field if value's pointer is not nil.
+func (w *WhatsappUpdate) SetNotNilStatus(value *uint8) *WhatsappUpdate {
+	if value != nil {
+		return w.SetStatus(*value)
+	}
+	return w
+}
+
+// set field if value's pointer is not nil.
+func (w *WhatsappUpdateOne) SetNotNilStatus(value *uint8) *WhatsappUpdateOne {
+	if value != nil {
+		return w.SetStatus(*value)
+	}
+	return w
+}
+
+// set field if value's pointer is not nil.
+func (w *WhatsappCreate) SetNotNilStatus(value *uint8) *WhatsappCreate {
+	if value != nil {
+		return w.SetStatus(*value)
+	}
+	return w
+}
+
+// set field if value's pointer is not nil.
+func (w *WhatsappUpdate) SetNotNilDeletedAt(value *time.Time) *WhatsappUpdate {
+	if value != nil {
+		return w.SetDeletedAt(*value)
+	}
+	return w
+}
+
+// set field if value's pointer is not nil.
+func (w *WhatsappUpdateOne) SetNotNilDeletedAt(value *time.Time) *WhatsappUpdateOne {
+	if value != nil {
+		return w.SetDeletedAt(*value)
+	}
+	return w
+}
+
+// set field if value's pointer is not nil.
+func (w *WhatsappCreate) SetNotNilDeletedAt(value *time.Time) *WhatsappCreate {
+	if value != nil {
+		return w.SetDeletedAt(*value)
+	}
+	return w
+}
+
+// set field if value's pointer is not nil.
+func (w *WhatsappUpdate) SetNotNilAk(value *string) *WhatsappUpdate {
+	if value != nil {
+		return w.SetAk(*value)
+	}
+	return w
+}
+
+// set field if value's pointer is not nil.
+func (w *WhatsappUpdateOne) SetNotNilAk(value *string) *WhatsappUpdateOne {
+	if value != nil {
+		return w.SetAk(*value)
+	}
+	return w
+}
+
+// set field if value's pointer is not nil.
+func (w *WhatsappCreate) SetNotNilAk(value *string) *WhatsappCreate {
+	if value != nil {
+		return w.SetAk(*value)
+	}
+	return w
+}
+
+// set field if value's pointer is not nil.
+func (w *WhatsappUpdate) SetNotNilSk(value *string) *WhatsappUpdate {
+	if value != nil {
+		return w.SetSk(*value)
+	}
+	return w
+}
+
+// set field if value's pointer is not nil.
+func (w *WhatsappUpdateOne) SetNotNilSk(value *string) *WhatsappUpdateOne {
+	if value != nil {
+		return w.SetSk(*value)
+	}
+	return w
+}
+
+// set field if value's pointer is not nil.
+func (w *WhatsappCreate) SetNotNilSk(value *string) *WhatsappCreate {
+	if value != nil {
+		return w.SetSk(*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)
+	}
+	return w
+}
+
+// set field if value's pointer is not nil.
+func (w *WhatsappUpdateOne) SetNotNilCallback(value *string) *WhatsappUpdateOne {
+	if value != nil {
+		return w.SetCallback(*value)
+	}
+	return w
+}
+
+// set field if value's pointer is not nil.
+func (w *WhatsappCreate) SetNotNilCallback(value *string) *WhatsappCreate {
+	if value != nil {
+		return w.SetCallback(*value)
+	}
+	return w
+}
+
+// set field if value's pointer is not nil.
+func (w *WhatsappUpdate) SetNotNilAccount(value *string) *WhatsappUpdate {
+	if value != nil {
+		return w.SetAccount(*value)
+	}
+	return w
+}
+
+// set field if value's pointer is not nil.
+func (w *WhatsappUpdateOne) SetNotNilAccount(value *string) *WhatsappUpdateOne {
+	if value != nil {
+		return w.SetAccount(*value)
+	}
+	return w
+}
+
+// set field if value's pointer is not nil.
+func (w *WhatsappCreate) SetNotNilAccount(value *string) *WhatsappCreate {
+	if value != nil {
+		return w.SetAccount(*value)
+	}
+	return w
+}
+
+// set field if value's pointer is not nil.
+func (w *WhatsappUpdate) SetNotNilNickname(value *string) *WhatsappUpdate {
+	if value != nil {
+		return w.SetNickname(*value)
+	}
+	return w
+}
+
+// set field if value's pointer is not nil.
+func (w *WhatsappUpdateOne) SetNotNilNickname(value *string) *WhatsappUpdateOne {
+	if value != nil {
+		return w.SetNickname(*value)
+	}
+	return w
+}
+
+// set field if value's pointer is not nil.
+func (w *WhatsappCreate) SetNotNilNickname(value *string) *WhatsappCreate {
+	if value != nil {
+		return w.SetNickname(*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)
+	}
+	return w
+}
+
+// set field if value's pointer is not nil.
+func (w *WhatsappUpdateOne) SetNotNilPhone(value *string) *WhatsappUpdateOne {
+	if value != nil {
+		return w.SetPhone(*value)
+	}
+	return w
+}
+
+// set field if value's pointer is not nil.
+func (w *WhatsappCreate) SetNotNilPhone(value *string) *WhatsappCreate {
+	if value != nil {
+		return w.SetPhone(*value)
+	}
+	return w
+}
+
+// set field if value's pointer is not nil.
+func (w *WhatsappUpdate) SetNotNilOrganizationID(value *uint64) *WhatsappUpdate {
+	if value != nil {
+		return w.SetOrganizationID(*value)
+	}
+	return w
+}
+
+// set field if value's pointer is not nil.
+func (w *WhatsappUpdateOne) SetNotNilOrganizationID(value *uint64) *WhatsappUpdateOne {
+	if value != nil {
+		return w.SetOrganizationID(*value)
+	}
+	return w
+}
+
+// set field if value's pointer is not nil.
+func (w *WhatsappCreate) SetNotNilOrganizationID(value *uint64) *WhatsappCreate {
+	if value != nil {
+		return w.SetOrganizationID(*value)
+	}
+	return w
+}
+
+// set field if value's pointer is not nil.
+func (w *WhatsappUpdate) SetNotNilAgentID(value *uint64) *WhatsappUpdate {
+	if value != nil {
+		return w.SetAgentID(*value)
+	}
+	return w
+}
+
+// set field if value's pointer is not nil.
+func (w *WhatsappUpdateOne) SetNotNilAgentID(value *uint64) *WhatsappUpdateOne {
+	if value != nil {
+		return w.SetAgentID(*value)
+	}
+	return w
+}
+
+// set field if value's pointer is not nil.
+func (w *WhatsappCreate) SetNotNilAgentID(value *uint64) *WhatsappCreate {
+	if value != nil {
+		return w.SetAgentID(*value)
+	}
+	return w
+}
+
+// set field if value's pointer is not nil.
+func (w *WhatsappUpdate) SetNotNilAPIBase(value *string) *WhatsappUpdate {
+	if value != nil {
+		return w.SetAPIBase(*value)
+	}
+	return w
+}
+
+// set field if value's pointer is not nil.
+func (w *WhatsappUpdateOne) SetNotNilAPIBase(value *string) *WhatsappUpdateOne {
+	if value != nil {
+		return w.SetAPIBase(*value)
+	}
+	return w
+}
+
+// set field if value's pointer is not nil.
+func (w *WhatsappCreate) SetNotNilAPIBase(value *string) *WhatsappCreate {
+	if value != nil {
+		return w.SetAPIBase(*value)
+	}
+	return w
+}
+
+// set field if value's pointer is not nil.
+func (w *WhatsappUpdate) SetNotNilAPIKey(value *string) *WhatsappUpdate {
+	if value != nil {
+		return w.SetAPIKey(*value)
+	}
+	return w
+}
+
+// set field if value's pointer is not nil.
+func (w *WhatsappUpdateOne) SetNotNilAPIKey(value *string) *WhatsappUpdateOne {
+	if value != nil {
+		return w.SetAPIKey(*value)
+	}
+	return w
+}
+
+// set field if value's pointer is not nil.
+func (w *WhatsappCreate) SetNotNilAPIKey(value *string) *WhatsappCreate {
+	if value != nil {
+		return w.SetAPIKey(*value)
+	}
+	return w
+}
+
+// set field if value's pointer is not nil.
+func (w *WhatsappUpdate) SetNotNilAllowList(value []string) *WhatsappUpdate {
+	if value != nil {
+		return w.SetAllowList(value)
+	}
+	return w
+}
+
+// set field if value's pointer is not nil.
+func (w *WhatsappUpdateOne) SetNotNilAllowList(value []string) *WhatsappUpdateOne {
+	if value != nil {
+		return w.SetAllowList(value)
+	}
+	return w
+}
+
+// set field if value's pointer is not nil.
+func (w *WhatsappCreate) SetNotNilAllowList(value []string) *WhatsappCreate {
+	if value != nil {
+		return w.SetAllowList(value)
+	}
+	return w
+}
+
+// set field if value's pointer is not nil.
+func (w *WhatsappUpdate) SetNotNilGroupAllowList(value []string) *WhatsappUpdate {
+	if value != nil {
+		return w.SetGroupAllowList(value)
+	}
+	return w
+}
+
+// set field if value's pointer is not nil.
+func (w *WhatsappUpdateOne) SetNotNilGroupAllowList(value []string) *WhatsappUpdateOne {
+	if value != nil {
+		return w.SetGroupAllowList(value)
+	}
+	return w
+}
+
+// set field if value's pointer is not nil.
+func (w *WhatsappCreate) SetNotNilGroupAllowList(value []string) *WhatsappCreate {
+	if value != nil {
+		return w.SetGroupAllowList(value)
+	}
+	return w
+}
+
+// set field if value's pointer is not nil.
+func (w *WhatsappUpdate) SetNotNilBlockList(value []string) *WhatsappUpdate {
+	if value != nil {
+		return w.SetBlockList(value)
+	}
+	return w
+}
+
+// set field if value's pointer is not nil.
+func (w *WhatsappUpdateOne) SetNotNilBlockList(value []string) *WhatsappUpdateOne {
+	if value != nil {
+		return w.SetBlockList(value)
+	}
+	return w
+}
+
+// set field if value's pointer is not nil.
+func (w *WhatsappCreate) SetNotNilBlockList(value []string) *WhatsappCreate {
+	if value != nil {
+		return w.SetBlockList(value)
+	}
+	return w
+}
+
+// set field if value's pointer is not nil.
+func (w *WhatsappUpdate) SetNotNilGroupBlockList(value []string) *WhatsappUpdate {
+	if value != nil {
+		return w.SetGroupBlockList(value)
+	}
+	return w
+}
+
+// set field if value's pointer is not nil.
+func (w *WhatsappUpdateOne) SetNotNilGroupBlockList(value []string) *WhatsappUpdateOne {
+	if value != nil {
+		return w.SetGroupBlockList(value)
+	}
+	return w
+}
+
+// set field if value's pointer is not nil.
+func (w *WhatsappCreate) SetNotNilGroupBlockList(value []string) *WhatsappCreate {
+	if value != nil {
+		return w.SetGroupBlockList(value)
+	}
+	return w
+}
+
+// set field if value's pointer is not nil.
 func (we *WorkExperienceUpdate) SetNotNilUpdatedAt(value *time.Time) *WorkExperienceUpdate {
 	if value != nil {
 		return we.SetUpdatedAt(*value)

+ 3 - 0
ent/tx.go

@@ -76,6 +76,8 @@ type Tx struct {
 	UsageStatisticMonth *UsageStatisticMonthClient
 	// UsageTotal is the client for interacting with the UsageTotal builders.
 	UsageTotal *UsageTotalClient
+	// Whatsapp is the client for interacting with the Whatsapp builders.
+	Whatsapp *WhatsappClient
 	// WorkExperience is the client for interacting with the WorkExperience builders.
 	WorkExperience *WorkExperienceClient
 	// WpChatroom is the client for interacting with the WpChatroom builders.
@@ -252,6 +254,7 @@ func (tx *Tx) init() {
 	tx.UsageStatisticHour = NewUsageStatisticHourClient(tx.config)
 	tx.UsageStatisticMonth = NewUsageStatisticMonthClient(tx.config)
 	tx.UsageTotal = NewUsageTotalClient(tx.config)
+	tx.Whatsapp = NewWhatsappClient(tx.config)
 	tx.WorkExperience = NewWorkExperienceClient(tx.config)
 	tx.WpChatroom = NewWpChatroomClient(tx.config)
 	tx.WpChatroomMember = NewWpChatroomMemberClient(tx.config)

+ 304 - 0
ent/whatsapp.go

@@ -0,0 +1,304 @@
+// Code generated by ent, DO NOT EDIT.
+
+package ent
+
+import (
+	"encoding/json"
+	"fmt"
+	"strings"
+	"time"
+	"wechat-api/ent/whatsapp"
+
+	"entgo.io/ent"
+	"entgo.io/ent/dialect/sql"
+)
+
+// Whatsapp is the model entity for the Whatsapp schema.
+type Whatsapp struct {
+	config `json:"-"`
+	// ID of the ent.
+	ID uint64 `json:"id,omitempty"`
+	// Create Time | 创建日期
+	CreatedAt time.Time `json:"created_at,omitempty"`
+	// Update Time | 修改日期
+	UpdatedAt time.Time `json:"updated_at,omitempty"`
+	// Status 1: normal 2: ban | 状态 1 正常 2 禁用
+	Status uint8 `json:"status,omitempty"`
+	// Delete Time | 删除日期
+	DeletedAt time.Time `json:"deleted_at,omitempty"`
+	// ak
+	Ak string `json:"ak,omitempty"`
+	// 端口号
+	Sk string `json:"sk,omitempty"`
+	// 回调地址
+	Callback string `json:"callback,omitempty"`
+	// 微信账号
+	Account string `json:"account,omitempty"`
+	// 昵称
+	Nickname string `json:"nickname,omitempty"`
+	// 手机号
+	Phone string `json:"phone,omitempty"`
+	// 机构 ID
+	OrganizationID uint64 `json:"organization_id,omitempty"`
+	// 模式ID
+	AgentID uint64 `json:"agent_id,omitempty"`
+	// 大模型服务地址
+	APIBase string `json:"api_base,omitempty"`
+	// 大模型服务密钥
+	APIKey string `json:"api_key,omitempty"`
+	// 白名单
+	AllowList []string `json:"allow_list,omitempty"`
+	// 群白名单
+	GroupAllowList []string `json:"group_allow_list,omitempty"`
+	// 黑名单
+	BlockList []string `json:"block_list,omitempty"`
+	// 群黑名单
+	GroupBlockList []string `json:"group_block_list,omitempty"`
+	selectValues   sql.SelectValues
+}
+
+// scanValues returns the types for scanning values from sql.Rows.
+func (*Whatsapp) scanValues(columns []string) ([]any, error) {
+	values := make([]any, len(columns))
+	for i := range columns {
+		switch columns[i] {
+		case whatsapp.FieldAllowList, whatsapp.FieldGroupAllowList, whatsapp.FieldBlockList, whatsapp.FieldGroupBlockList:
+			values[i] = new([]byte)
+		case whatsapp.FieldID, whatsapp.FieldStatus, whatsapp.FieldOrganizationID, whatsapp.FieldAgentID:
+			values[i] = new(sql.NullInt64)
+		case whatsapp.FieldAk, whatsapp.FieldSk, whatsapp.FieldCallback, whatsapp.FieldAccount, whatsapp.FieldNickname, whatsapp.FieldPhone, whatsapp.FieldAPIBase, whatsapp.FieldAPIKey:
+			values[i] = new(sql.NullString)
+		case whatsapp.FieldCreatedAt, whatsapp.FieldUpdatedAt, whatsapp.FieldDeletedAt:
+			values[i] = new(sql.NullTime)
+		default:
+			values[i] = new(sql.UnknownType)
+		}
+	}
+	return values, nil
+}
+
+// assignValues assigns the values that were returned from sql.Rows (after scanning)
+// to the Whatsapp fields.
+func (w *Whatsapp) assignValues(columns []string, values []any) error {
+	if m, n := len(values), len(columns); m < n {
+		return fmt.Errorf("mismatch number of scan values: %d != %d", m, n)
+	}
+	for i := range columns {
+		switch columns[i] {
+		case whatsapp.FieldID:
+			value, ok := values[i].(*sql.NullInt64)
+			if !ok {
+				return fmt.Errorf("unexpected type %T for field id", value)
+			}
+			w.ID = uint64(value.Int64)
+		case whatsapp.FieldCreatedAt:
+			if value, ok := values[i].(*sql.NullTime); !ok {
+				return fmt.Errorf("unexpected type %T for field created_at", values[i])
+			} else if value.Valid {
+				w.CreatedAt = value.Time
+			}
+		case whatsapp.FieldUpdatedAt:
+			if value, ok := values[i].(*sql.NullTime); !ok {
+				return fmt.Errorf("unexpected type %T for field updated_at", values[i])
+			} else if value.Valid {
+				w.UpdatedAt = value.Time
+			}
+		case whatsapp.FieldStatus:
+			if value, ok := values[i].(*sql.NullInt64); !ok {
+				return fmt.Errorf("unexpected type %T for field status", values[i])
+			} else if value.Valid {
+				w.Status = uint8(value.Int64)
+			}
+		case whatsapp.FieldDeletedAt:
+			if value, ok := values[i].(*sql.NullTime); !ok {
+				return fmt.Errorf("unexpected type %T for field deleted_at", values[i])
+			} else if value.Valid {
+				w.DeletedAt = value.Time
+			}
+		case whatsapp.FieldAk:
+			if value, ok := values[i].(*sql.NullString); !ok {
+				return fmt.Errorf("unexpected type %T for field ak", values[i])
+			} else if value.Valid {
+				w.Ak = value.String
+			}
+		case whatsapp.FieldSk:
+			if value, ok := values[i].(*sql.NullString); !ok {
+				return fmt.Errorf("unexpected type %T for field sk", values[i])
+			} else if value.Valid {
+				w.Sk = value.String
+			}
+		case whatsapp.FieldCallback:
+			if value, ok := values[i].(*sql.NullString); !ok {
+				return fmt.Errorf("unexpected type %T for field callback", values[i])
+			} else if value.Valid {
+				w.Callback = value.String
+			}
+		case whatsapp.FieldAccount:
+			if value, ok := values[i].(*sql.NullString); !ok {
+				return fmt.Errorf("unexpected type %T for field account", values[i])
+			} else if value.Valid {
+				w.Account = value.String
+			}
+		case whatsapp.FieldNickname:
+			if value, ok := values[i].(*sql.NullString); !ok {
+				return fmt.Errorf("unexpected type %T for field nickname", values[i])
+			} else if value.Valid {
+				w.Nickname = value.String
+			}
+		case whatsapp.FieldPhone:
+			if value, ok := values[i].(*sql.NullString); !ok {
+				return fmt.Errorf("unexpected type %T for field phone", values[i])
+			} else if value.Valid {
+				w.Phone = value.String
+			}
+		case whatsapp.FieldOrganizationID:
+			if value, ok := values[i].(*sql.NullInt64); !ok {
+				return fmt.Errorf("unexpected type %T for field organization_id", values[i])
+			} else if value.Valid {
+				w.OrganizationID = uint64(value.Int64)
+			}
+		case whatsapp.FieldAgentID:
+			if value, ok := values[i].(*sql.NullInt64); !ok {
+				return fmt.Errorf("unexpected type %T for field agent_id", values[i])
+			} else if value.Valid {
+				w.AgentID = uint64(value.Int64)
+			}
+		case whatsapp.FieldAPIBase:
+			if value, ok := values[i].(*sql.NullString); !ok {
+				return fmt.Errorf("unexpected type %T for field api_base", values[i])
+			} else if value.Valid {
+				w.APIBase = value.String
+			}
+		case whatsapp.FieldAPIKey:
+			if value, ok := values[i].(*sql.NullString); !ok {
+				return fmt.Errorf("unexpected type %T for field api_key", values[i])
+			} else if value.Valid {
+				w.APIKey = value.String
+			}
+		case whatsapp.FieldAllowList:
+			if value, ok := values[i].(*[]byte); !ok {
+				return fmt.Errorf("unexpected type %T for field allow_list", values[i])
+			} else if value != nil && len(*value) > 0 {
+				if err := json.Unmarshal(*value, &w.AllowList); err != nil {
+					return fmt.Errorf("unmarshal field allow_list: %w", err)
+				}
+			}
+		case whatsapp.FieldGroupAllowList:
+			if value, ok := values[i].(*[]byte); !ok {
+				return fmt.Errorf("unexpected type %T for field group_allow_list", values[i])
+			} else if value != nil && len(*value) > 0 {
+				if err := json.Unmarshal(*value, &w.GroupAllowList); err != nil {
+					return fmt.Errorf("unmarshal field group_allow_list: %w", err)
+				}
+			}
+		case whatsapp.FieldBlockList:
+			if value, ok := values[i].(*[]byte); !ok {
+				return fmt.Errorf("unexpected type %T for field block_list", values[i])
+			} else if value != nil && len(*value) > 0 {
+				if err := json.Unmarshal(*value, &w.BlockList); err != nil {
+					return fmt.Errorf("unmarshal field block_list: %w", err)
+				}
+			}
+		case whatsapp.FieldGroupBlockList:
+			if value, ok := values[i].(*[]byte); !ok {
+				return fmt.Errorf("unexpected type %T for field group_block_list", values[i])
+			} else if value != nil && len(*value) > 0 {
+				if err := json.Unmarshal(*value, &w.GroupBlockList); err != nil {
+					return fmt.Errorf("unmarshal field group_block_list: %w", err)
+				}
+			}
+		default:
+			w.selectValues.Set(columns[i], values[i])
+		}
+	}
+	return nil
+}
+
+// Value returns the ent.Value that was dynamically selected and assigned to the Whatsapp.
+// This includes values selected through modifiers, order, etc.
+func (w *Whatsapp) Value(name string) (ent.Value, error) {
+	return w.selectValues.Get(name)
+}
+
+// Update returns a builder for updating this Whatsapp.
+// Note that you need to call Whatsapp.Unwrap() before calling this method if this Whatsapp
+// was returned from a transaction, and the transaction was committed or rolled back.
+func (w *Whatsapp) Update() *WhatsappUpdateOne {
+	return NewWhatsappClient(w.config).UpdateOne(w)
+}
+
+// Unwrap unwraps the Whatsapp entity that was returned from a transaction after it was closed,
+// so that all future queries will be executed through the driver which created the transaction.
+func (w *Whatsapp) Unwrap() *Whatsapp {
+	_tx, ok := w.config.driver.(*txDriver)
+	if !ok {
+		panic("ent: Whatsapp is not a transactional entity")
+	}
+	w.config.driver = _tx.drv
+	return w
+}
+
+// String implements the fmt.Stringer.
+func (w *Whatsapp) String() string {
+	var builder strings.Builder
+	builder.WriteString("Whatsapp(")
+	builder.WriteString(fmt.Sprintf("id=%v, ", w.ID))
+	builder.WriteString("created_at=")
+	builder.WriteString(w.CreatedAt.Format(time.ANSIC))
+	builder.WriteString(", ")
+	builder.WriteString("updated_at=")
+	builder.WriteString(w.UpdatedAt.Format(time.ANSIC))
+	builder.WriteString(", ")
+	builder.WriteString("status=")
+	builder.WriteString(fmt.Sprintf("%v", w.Status))
+	builder.WriteString(", ")
+	builder.WriteString("deleted_at=")
+	builder.WriteString(w.DeletedAt.Format(time.ANSIC))
+	builder.WriteString(", ")
+	builder.WriteString("ak=")
+	builder.WriteString(w.Ak)
+	builder.WriteString(", ")
+	builder.WriteString("sk=")
+	builder.WriteString(w.Sk)
+	builder.WriteString(", ")
+	builder.WriteString("callback=")
+	builder.WriteString(w.Callback)
+	builder.WriteString(", ")
+	builder.WriteString("account=")
+	builder.WriteString(w.Account)
+	builder.WriteString(", ")
+	builder.WriteString("nickname=")
+	builder.WriteString(w.Nickname)
+	builder.WriteString(", ")
+	builder.WriteString("phone=")
+	builder.WriteString(w.Phone)
+	builder.WriteString(", ")
+	builder.WriteString("organization_id=")
+	builder.WriteString(fmt.Sprintf("%v", w.OrganizationID))
+	builder.WriteString(", ")
+	builder.WriteString("agent_id=")
+	builder.WriteString(fmt.Sprintf("%v", w.AgentID))
+	builder.WriteString(", ")
+	builder.WriteString("api_base=")
+	builder.WriteString(w.APIBase)
+	builder.WriteString(", ")
+	builder.WriteString("api_key=")
+	builder.WriteString(w.APIKey)
+	builder.WriteString(", ")
+	builder.WriteString("allow_list=")
+	builder.WriteString(fmt.Sprintf("%v", w.AllowList))
+	builder.WriteString(", ")
+	builder.WriteString("group_allow_list=")
+	builder.WriteString(fmt.Sprintf("%v", w.GroupAllowList))
+	builder.WriteString(", ")
+	builder.WriteString("block_list=")
+	builder.WriteString(fmt.Sprintf("%v", w.BlockList))
+	builder.WriteString(", ")
+	builder.WriteString("group_block_list=")
+	builder.WriteString(fmt.Sprintf("%v", w.GroupBlockList))
+	builder.WriteByte(')')
+	return builder.String()
+}
+
+// Whatsapps is a parsable slice of Whatsapp.
+type Whatsapps []*Whatsapp

+ 204 - 0
ent/whatsapp/whatsapp.go

@@ -0,0 +1,204 @@
+// Code generated by ent, DO NOT EDIT.
+
+package whatsapp
+
+import (
+	"time"
+
+	"entgo.io/ent"
+	"entgo.io/ent/dialect/sql"
+)
+
+const (
+	// Label holds the string label denoting the whatsapp type in the database.
+	Label = "whatsapp"
+	// FieldID holds the string denoting the id field in the database.
+	FieldID = "id"
+	// FieldCreatedAt holds the string denoting the created_at field in the database.
+	FieldCreatedAt = "created_at"
+	// FieldUpdatedAt holds the string denoting the updated_at field in the database.
+	FieldUpdatedAt = "updated_at"
+	// FieldStatus holds the string denoting the status field in the database.
+	FieldStatus = "status"
+	// FieldDeletedAt holds the string denoting the deleted_at field in the database.
+	FieldDeletedAt = "deleted_at"
+	// FieldAk holds the string denoting the ak field in the database.
+	FieldAk = "ak"
+	// FieldSk holds the string denoting the sk field in the database.
+	FieldSk = "sk"
+	// FieldCallback holds the string denoting the callback field in the database.
+	FieldCallback = "callback"
+	// FieldAccount holds the string denoting the account field in the database.
+	FieldAccount = "account"
+	// FieldNickname holds the string denoting the nickname field in the database.
+	FieldNickname = "nickname"
+	// FieldPhone holds the string denoting the phone field in the database.
+	FieldPhone = "phone"
+	// FieldOrganizationID holds the string denoting the organization_id field in the database.
+	FieldOrganizationID = "organization_id"
+	// FieldAgentID holds the string denoting the agent_id field in the database.
+	FieldAgentID = "agent_id"
+	// FieldAPIBase holds the string denoting the api_base field in the database.
+	FieldAPIBase = "api_base"
+	// FieldAPIKey holds the string denoting the api_key field in the database.
+	FieldAPIKey = "api_key"
+	// FieldAllowList holds the string denoting the allow_list field in the database.
+	FieldAllowList = "allow_list"
+	// FieldGroupAllowList holds the string denoting the group_allow_list field in the database.
+	FieldGroupAllowList = "group_allow_list"
+	// FieldBlockList holds the string denoting the block_list field in the database.
+	FieldBlockList = "block_list"
+	// FieldGroupBlockList holds the string denoting the group_block_list field in the database.
+	FieldGroupBlockList = "group_block_list"
+	// Table holds the table name of the whatsapp in the database.
+	Table = "whatsapp"
+)
+
+// Columns holds all SQL columns for whatsapp fields.
+var Columns = []string{
+	FieldID,
+	FieldCreatedAt,
+	FieldUpdatedAt,
+	FieldStatus,
+	FieldDeletedAt,
+	FieldAk,
+	FieldSk,
+	FieldCallback,
+	FieldAccount,
+	FieldNickname,
+	FieldPhone,
+	FieldOrganizationID,
+	FieldAgentID,
+	FieldAPIBase,
+	FieldAPIKey,
+	FieldAllowList,
+	FieldGroupAllowList,
+	FieldBlockList,
+	FieldGroupBlockList,
+}
+
+// ValidColumn reports if the column name is valid (part of the table columns).
+func ValidColumn(column string) bool {
+	for i := range Columns {
+		if column == Columns[i] {
+			return true
+		}
+	}
+	return false
+}
+
+// Note that the variables below are initialized by the runtime
+// package on the initialization of the application. Therefore,
+// it should be imported in the main as follows:
+//
+//	import _ "wechat-api/ent/runtime"
+var (
+	Hooks        [1]ent.Hook
+	Interceptors [1]ent.Interceptor
+	// DefaultCreatedAt holds the default value on creation for the "created_at" field.
+	DefaultCreatedAt func() time.Time
+	// DefaultUpdatedAt holds the default value on creation for the "updated_at" field.
+	DefaultUpdatedAt func() time.Time
+	// UpdateDefaultUpdatedAt holds the default value on update for the "updated_at" field.
+	UpdateDefaultUpdatedAt func() time.Time
+	// DefaultStatus holds the default value on creation for the "status" field.
+	DefaultStatus uint8
+	// DefaultAk holds the default value on creation for the "ak" field.
+	DefaultAk string
+	// DefaultSk holds the default value on creation for the "sk" field.
+	DefaultSk string
+	// DefaultCallback holds the default value on creation for the "callback" field.
+	DefaultCallback string
+	// DefaultAccount holds the default value on creation for the "account" field.
+	DefaultAccount string
+	// DefaultNickname holds the default value on creation for the "nickname" field.
+	DefaultNickname string
+	// DefaultPhone holds the default value on creation for the "phone" field.
+	DefaultPhone string
+	// DefaultOrganizationID holds the default value on creation for the "organization_id" field.
+	DefaultOrganizationID uint64
+	// DefaultAgentID holds the default value on creation for the "agent_id" field.
+	DefaultAgentID uint64
+	// DefaultAPIBase holds the default value on creation for the "api_base" field.
+	DefaultAPIBase string
+	// DefaultAPIKey holds the default value on creation for the "api_key" field.
+	DefaultAPIKey string
+)
+
+// OrderOption defines the ordering options for the Whatsapp queries.
+type OrderOption func(*sql.Selector)
+
+// ByID orders the results by the id field.
+func ByID(opts ...sql.OrderTermOption) OrderOption {
+	return sql.OrderByField(FieldID, opts...).ToFunc()
+}
+
+// ByCreatedAt orders the results by the created_at field.
+func ByCreatedAt(opts ...sql.OrderTermOption) OrderOption {
+	return sql.OrderByField(FieldCreatedAt, opts...).ToFunc()
+}
+
+// ByUpdatedAt orders the results by the updated_at field.
+func ByUpdatedAt(opts ...sql.OrderTermOption) OrderOption {
+	return sql.OrderByField(FieldUpdatedAt, opts...).ToFunc()
+}
+
+// ByStatus orders the results by the status field.
+func ByStatus(opts ...sql.OrderTermOption) OrderOption {
+	return sql.OrderByField(FieldStatus, opts...).ToFunc()
+}
+
+// ByDeletedAt orders the results by the deleted_at field.
+func ByDeletedAt(opts ...sql.OrderTermOption) OrderOption {
+	return sql.OrderByField(FieldDeletedAt, opts...).ToFunc()
+}
+
+// ByAk orders the results by the ak field.
+func ByAk(opts ...sql.OrderTermOption) OrderOption {
+	return sql.OrderByField(FieldAk, opts...).ToFunc()
+}
+
+// BySk orders the results by the sk field.
+func BySk(opts ...sql.OrderTermOption) OrderOption {
+	return sql.OrderByField(FieldSk, opts...).ToFunc()
+}
+
+// ByCallback orders the results by the callback field.
+func ByCallback(opts ...sql.OrderTermOption) OrderOption {
+	return sql.OrderByField(FieldCallback, opts...).ToFunc()
+}
+
+// ByAccount orders the results by the account field.
+func ByAccount(opts ...sql.OrderTermOption) OrderOption {
+	return sql.OrderByField(FieldAccount, opts...).ToFunc()
+}
+
+// ByNickname orders the results by the nickname field.
+func ByNickname(opts ...sql.OrderTermOption) OrderOption {
+	return sql.OrderByField(FieldNickname, opts...).ToFunc()
+}
+
+// ByPhone orders the results by the phone field.
+func ByPhone(opts ...sql.OrderTermOption) OrderOption {
+	return sql.OrderByField(FieldPhone, opts...).ToFunc()
+}
+
+// ByOrganizationID orders the results by the organization_id field.
+func ByOrganizationID(opts ...sql.OrderTermOption) OrderOption {
+	return sql.OrderByField(FieldOrganizationID, opts...).ToFunc()
+}
+
+// ByAgentID orders the results by the agent_id field.
+func ByAgentID(opts ...sql.OrderTermOption) OrderOption {
+	return sql.OrderByField(FieldAgentID, opts...).ToFunc()
+}
+
+// ByAPIBase orders the results by the api_base field.
+func ByAPIBase(opts ...sql.OrderTermOption) OrderOption {
+	return sql.OrderByField(FieldAPIBase, opts...).ToFunc()
+}
+
+// ByAPIKey orders the results by the api_key field.
+func ByAPIKey(opts ...sql.OrderTermOption) OrderOption {
+	return sql.OrderByField(FieldAPIKey, opts...).ToFunc()
+}

+ 960 - 0
ent/whatsapp/where.go

@@ -0,0 +1,960 @@
+// Code generated by ent, DO NOT EDIT.
+
+package whatsapp
+
+import (
+	"time"
+	"wechat-api/ent/predicate"
+
+	"entgo.io/ent/dialect/sql"
+)
+
+// ID filters vertices based on their ID field.
+func ID(id uint64) predicate.Whatsapp {
+	return predicate.Whatsapp(sql.FieldEQ(FieldID, id))
+}
+
+// IDEQ applies the EQ predicate on the ID field.
+func IDEQ(id uint64) predicate.Whatsapp {
+	return predicate.Whatsapp(sql.FieldEQ(FieldID, id))
+}
+
+// IDNEQ applies the NEQ predicate on the ID field.
+func IDNEQ(id uint64) predicate.Whatsapp {
+	return predicate.Whatsapp(sql.FieldNEQ(FieldID, id))
+}
+
+// IDIn applies the In predicate on the ID field.
+func IDIn(ids ...uint64) predicate.Whatsapp {
+	return predicate.Whatsapp(sql.FieldIn(FieldID, ids...))
+}
+
+// IDNotIn applies the NotIn predicate on the ID field.
+func IDNotIn(ids ...uint64) predicate.Whatsapp {
+	return predicate.Whatsapp(sql.FieldNotIn(FieldID, ids...))
+}
+
+// IDGT applies the GT predicate on the ID field.
+func IDGT(id uint64) predicate.Whatsapp {
+	return predicate.Whatsapp(sql.FieldGT(FieldID, id))
+}
+
+// IDGTE applies the GTE predicate on the ID field.
+func IDGTE(id uint64) predicate.Whatsapp {
+	return predicate.Whatsapp(sql.FieldGTE(FieldID, id))
+}
+
+// IDLT applies the LT predicate on the ID field.
+func IDLT(id uint64) predicate.Whatsapp {
+	return predicate.Whatsapp(sql.FieldLT(FieldID, id))
+}
+
+// IDLTE applies the LTE predicate on the ID field.
+func IDLTE(id uint64) predicate.Whatsapp {
+	return predicate.Whatsapp(sql.FieldLTE(FieldID, id))
+}
+
+// CreatedAt applies equality check predicate on the "created_at" field. It's identical to CreatedAtEQ.
+func CreatedAt(v time.Time) predicate.Whatsapp {
+	return predicate.Whatsapp(sql.FieldEQ(FieldCreatedAt, v))
+}
+
+// UpdatedAt applies equality check predicate on the "updated_at" field. It's identical to UpdatedAtEQ.
+func UpdatedAt(v time.Time) predicate.Whatsapp {
+	return predicate.Whatsapp(sql.FieldEQ(FieldUpdatedAt, v))
+}
+
+// Status applies equality check predicate on the "status" field. It's identical to StatusEQ.
+func Status(v uint8) predicate.Whatsapp {
+	return predicate.Whatsapp(sql.FieldEQ(FieldStatus, v))
+}
+
+// DeletedAt applies equality check predicate on the "deleted_at" field. It's identical to DeletedAtEQ.
+func DeletedAt(v time.Time) predicate.Whatsapp {
+	return predicate.Whatsapp(sql.FieldEQ(FieldDeletedAt, v))
+}
+
+// Ak applies equality check predicate on the "ak" field. It's identical to AkEQ.
+func Ak(v string) predicate.Whatsapp {
+	return predicate.Whatsapp(sql.FieldEQ(FieldAk, v))
+}
+
+// Sk applies equality check predicate on the "sk" field. It's identical to SkEQ.
+func Sk(v string) predicate.Whatsapp {
+	return predicate.Whatsapp(sql.FieldEQ(FieldSk, 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))
+}
+
+// Account applies equality check predicate on the "account" field. It's identical to AccountEQ.
+func Account(v string) predicate.Whatsapp {
+	return predicate.Whatsapp(sql.FieldEQ(FieldAccount, v))
+}
+
+// Nickname applies equality check predicate on the "nickname" field. It's identical to NicknameEQ.
+func Nickname(v string) predicate.Whatsapp {
+	return predicate.Whatsapp(sql.FieldEQ(FieldNickname, 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))
+}
+
+// OrganizationID applies equality check predicate on the "organization_id" field. It's identical to OrganizationIDEQ.
+func OrganizationID(v uint64) predicate.Whatsapp {
+	return predicate.Whatsapp(sql.FieldEQ(FieldOrganizationID, v))
+}
+
+// AgentID applies equality check predicate on the "agent_id" field. It's identical to AgentIDEQ.
+func AgentID(v uint64) predicate.Whatsapp {
+	return predicate.Whatsapp(sql.FieldEQ(FieldAgentID, v))
+}
+
+// APIBase applies equality check predicate on the "api_base" field. It's identical to APIBaseEQ.
+func APIBase(v string) predicate.Whatsapp {
+	return predicate.Whatsapp(sql.FieldEQ(FieldAPIBase, v))
+}
+
+// APIKey applies equality check predicate on the "api_key" field. It's identical to APIKeyEQ.
+func APIKey(v string) predicate.Whatsapp {
+	return predicate.Whatsapp(sql.FieldEQ(FieldAPIKey, v))
+}
+
+// CreatedAtEQ applies the EQ predicate on the "created_at" field.
+func CreatedAtEQ(v time.Time) predicate.Whatsapp {
+	return predicate.Whatsapp(sql.FieldEQ(FieldCreatedAt, v))
+}
+
+// CreatedAtNEQ applies the NEQ predicate on the "created_at" field.
+func CreatedAtNEQ(v time.Time) predicate.Whatsapp {
+	return predicate.Whatsapp(sql.FieldNEQ(FieldCreatedAt, v))
+}
+
+// CreatedAtIn applies the In predicate on the "created_at" field.
+func CreatedAtIn(vs ...time.Time) predicate.Whatsapp {
+	return predicate.Whatsapp(sql.FieldIn(FieldCreatedAt, vs...))
+}
+
+// CreatedAtNotIn applies the NotIn predicate on the "created_at" field.
+func CreatedAtNotIn(vs ...time.Time) predicate.Whatsapp {
+	return predicate.Whatsapp(sql.FieldNotIn(FieldCreatedAt, vs...))
+}
+
+// CreatedAtGT applies the GT predicate on the "created_at" field.
+func CreatedAtGT(v time.Time) predicate.Whatsapp {
+	return predicate.Whatsapp(sql.FieldGT(FieldCreatedAt, v))
+}
+
+// CreatedAtGTE applies the GTE predicate on the "created_at" field.
+func CreatedAtGTE(v time.Time) predicate.Whatsapp {
+	return predicate.Whatsapp(sql.FieldGTE(FieldCreatedAt, v))
+}
+
+// CreatedAtLT applies the LT predicate on the "created_at" field.
+func CreatedAtLT(v time.Time) predicate.Whatsapp {
+	return predicate.Whatsapp(sql.FieldLT(FieldCreatedAt, v))
+}
+
+// CreatedAtLTE applies the LTE predicate on the "created_at" field.
+func CreatedAtLTE(v time.Time) predicate.Whatsapp {
+	return predicate.Whatsapp(sql.FieldLTE(FieldCreatedAt, v))
+}
+
+// UpdatedAtEQ applies the EQ predicate on the "updated_at" field.
+func UpdatedAtEQ(v time.Time) predicate.Whatsapp {
+	return predicate.Whatsapp(sql.FieldEQ(FieldUpdatedAt, v))
+}
+
+// UpdatedAtNEQ applies the NEQ predicate on the "updated_at" field.
+func UpdatedAtNEQ(v time.Time) predicate.Whatsapp {
+	return predicate.Whatsapp(sql.FieldNEQ(FieldUpdatedAt, v))
+}
+
+// UpdatedAtIn applies the In predicate on the "updated_at" field.
+func UpdatedAtIn(vs ...time.Time) predicate.Whatsapp {
+	return predicate.Whatsapp(sql.FieldIn(FieldUpdatedAt, vs...))
+}
+
+// UpdatedAtNotIn applies the NotIn predicate on the "updated_at" field.
+func UpdatedAtNotIn(vs ...time.Time) predicate.Whatsapp {
+	return predicate.Whatsapp(sql.FieldNotIn(FieldUpdatedAt, vs...))
+}
+
+// UpdatedAtGT applies the GT predicate on the "updated_at" field.
+func UpdatedAtGT(v time.Time) predicate.Whatsapp {
+	return predicate.Whatsapp(sql.FieldGT(FieldUpdatedAt, v))
+}
+
+// UpdatedAtGTE applies the GTE predicate on the "updated_at" field.
+func UpdatedAtGTE(v time.Time) predicate.Whatsapp {
+	return predicate.Whatsapp(sql.FieldGTE(FieldUpdatedAt, v))
+}
+
+// UpdatedAtLT applies the LT predicate on the "updated_at" field.
+func UpdatedAtLT(v time.Time) predicate.Whatsapp {
+	return predicate.Whatsapp(sql.FieldLT(FieldUpdatedAt, v))
+}
+
+// UpdatedAtLTE applies the LTE predicate on the "updated_at" field.
+func UpdatedAtLTE(v time.Time) predicate.Whatsapp {
+	return predicate.Whatsapp(sql.FieldLTE(FieldUpdatedAt, v))
+}
+
+// StatusEQ applies the EQ predicate on the "status" field.
+func StatusEQ(v uint8) predicate.Whatsapp {
+	return predicate.Whatsapp(sql.FieldEQ(FieldStatus, v))
+}
+
+// StatusNEQ applies the NEQ predicate on the "status" field.
+func StatusNEQ(v uint8) predicate.Whatsapp {
+	return predicate.Whatsapp(sql.FieldNEQ(FieldStatus, v))
+}
+
+// StatusIn applies the In predicate on the "status" field.
+func StatusIn(vs ...uint8) predicate.Whatsapp {
+	return predicate.Whatsapp(sql.FieldIn(FieldStatus, vs...))
+}
+
+// StatusNotIn applies the NotIn predicate on the "status" field.
+func StatusNotIn(vs ...uint8) predicate.Whatsapp {
+	return predicate.Whatsapp(sql.FieldNotIn(FieldStatus, vs...))
+}
+
+// StatusGT applies the GT predicate on the "status" field.
+func StatusGT(v uint8) predicate.Whatsapp {
+	return predicate.Whatsapp(sql.FieldGT(FieldStatus, v))
+}
+
+// StatusGTE applies the GTE predicate on the "status" field.
+func StatusGTE(v uint8) predicate.Whatsapp {
+	return predicate.Whatsapp(sql.FieldGTE(FieldStatus, v))
+}
+
+// StatusLT applies the LT predicate on the "status" field.
+func StatusLT(v uint8) predicate.Whatsapp {
+	return predicate.Whatsapp(sql.FieldLT(FieldStatus, v))
+}
+
+// StatusLTE applies the LTE predicate on the "status" field.
+func StatusLTE(v uint8) predicate.Whatsapp {
+	return predicate.Whatsapp(sql.FieldLTE(FieldStatus, v))
+}
+
+// StatusIsNil applies the IsNil predicate on the "status" field.
+func StatusIsNil() predicate.Whatsapp {
+	return predicate.Whatsapp(sql.FieldIsNull(FieldStatus))
+}
+
+// StatusNotNil applies the NotNil predicate on the "status" field.
+func StatusNotNil() predicate.Whatsapp {
+	return predicate.Whatsapp(sql.FieldNotNull(FieldStatus))
+}
+
+// DeletedAtEQ applies the EQ predicate on the "deleted_at" field.
+func DeletedAtEQ(v time.Time) predicate.Whatsapp {
+	return predicate.Whatsapp(sql.FieldEQ(FieldDeletedAt, v))
+}
+
+// DeletedAtNEQ applies the NEQ predicate on the "deleted_at" field.
+func DeletedAtNEQ(v time.Time) predicate.Whatsapp {
+	return predicate.Whatsapp(sql.FieldNEQ(FieldDeletedAt, v))
+}
+
+// DeletedAtIn applies the In predicate on the "deleted_at" field.
+func DeletedAtIn(vs ...time.Time) predicate.Whatsapp {
+	return predicate.Whatsapp(sql.FieldIn(FieldDeletedAt, vs...))
+}
+
+// DeletedAtNotIn applies the NotIn predicate on the "deleted_at" field.
+func DeletedAtNotIn(vs ...time.Time) predicate.Whatsapp {
+	return predicate.Whatsapp(sql.FieldNotIn(FieldDeletedAt, vs...))
+}
+
+// DeletedAtGT applies the GT predicate on the "deleted_at" field.
+func DeletedAtGT(v time.Time) predicate.Whatsapp {
+	return predicate.Whatsapp(sql.FieldGT(FieldDeletedAt, v))
+}
+
+// DeletedAtGTE applies the GTE predicate on the "deleted_at" field.
+func DeletedAtGTE(v time.Time) predicate.Whatsapp {
+	return predicate.Whatsapp(sql.FieldGTE(FieldDeletedAt, v))
+}
+
+// DeletedAtLT applies the LT predicate on the "deleted_at" field.
+func DeletedAtLT(v time.Time) predicate.Whatsapp {
+	return predicate.Whatsapp(sql.FieldLT(FieldDeletedAt, v))
+}
+
+// DeletedAtLTE applies the LTE predicate on the "deleted_at" field.
+func DeletedAtLTE(v time.Time) predicate.Whatsapp {
+	return predicate.Whatsapp(sql.FieldLTE(FieldDeletedAt, v))
+}
+
+// DeletedAtIsNil applies the IsNil predicate on the "deleted_at" field.
+func DeletedAtIsNil() predicate.Whatsapp {
+	return predicate.Whatsapp(sql.FieldIsNull(FieldDeletedAt))
+}
+
+// DeletedAtNotNil applies the NotNil predicate on the "deleted_at" field.
+func DeletedAtNotNil() predicate.Whatsapp {
+	return predicate.Whatsapp(sql.FieldNotNull(FieldDeletedAt))
+}
+
+// AkEQ applies the EQ predicate on the "ak" field.
+func AkEQ(v string) predicate.Whatsapp {
+	return predicate.Whatsapp(sql.FieldEQ(FieldAk, v))
+}
+
+// AkNEQ applies the NEQ predicate on the "ak" field.
+func AkNEQ(v string) predicate.Whatsapp {
+	return predicate.Whatsapp(sql.FieldNEQ(FieldAk, v))
+}
+
+// AkIn applies the In predicate on the "ak" field.
+func AkIn(vs ...string) predicate.Whatsapp {
+	return predicate.Whatsapp(sql.FieldIn(FieldAk, vs...))
+}
+
+// AkNotIn applies the NotIn predicate on the "ak" field.
+func AkNotIn(vs ...string) predicate.Whatsapp {
+	return predicate.Whatsapp(sql.FieldNotIn(FieldAk, vs...))
+}
+
+// AkGT applies the GT predicate on the "ak" field.
+func AkGT(v string) predicate.Whatsapp {
+	return predicate.Whatsapp(sql.FieldGT(FieldAk, v))
+}
+
+// AkGTE applies the GTE predicate on the "ak" field.
+func AkGTE(v string) predicate.Whatsapp {
+	return predicate.Whatsapp(sql.FieldGTE(FieldAk, v))
+}
+
+// AkLT applies the LT predicate on the "ak" field.
+func AkLT(v string) predicate.Whatsapp {
+	return predicate.Whatsapp(sql.FieldLT(FieldAk, v))
+}
+
+// AkLTE applies the LTE predicate on the "ak" field.
+func AkLTE(v string) predicate.Whatsapp {
+	return predicate.Whatsapp(sql.FieldLTE(FieldAk, v))
+}
+
+// AkContains applies the Contains predicate on the "ak" field.
+func AkContains(v string) predicate.Whatsapp {
+	return predicate.Whatsapp(sql.FieldContains(FieldAk, v))
+}
+
+// AkHasPrefix applies the HasPrefix predicate on the "ak" field.
+func AkHasPrefix(v string) predicate.Whatsapp {
+	return predicate.Whatsapp(sql.FieldHasPrefix(FieldAk, v))
+}
+
+// AkHasSuffix applies the HasSuffix predicate on the "ak" field.
+func AkHasSuffix(v string) predicate.Whatsapp {
+	return predicate.Whatsapp(sql.FieldHasSuffix(FieldAk, v))
+}
+
+// AkIsNil applies the IsNil predicate on the "ak" field.
+func AkIsNil() predicate.Whatsapp {
+	return predicate.Whatsapp(sql.FieldIsNull(FieldAk))
+}
+
+// AkNotNil applies the NotNil predicate on the "ak" field.
+func AkNotNil() predicate.Whatsapp {
+	return predicate.Whatsapp(sql.FieldNotNull(FieldAk))
+}
+
+// AkEqualFold applies the EqualFold predicate on the "ak" field.
+func AkEqualFold(v string) predicate.Whatsapp {
+	return predicate.Whatsapp(sql.FieldEqualFold(FieldAk, v))
+}
+
+// AkContainsFold applies the ContainsFold predicate on the "ak" field.
+func AkContainsFold(v string) predicate.Whatsapp {
+	return predicate.Whatsapp(sql.FieldContainsFold(FieldAk, v))
+}
+
+// SkEQ applies the EQ predicate on the "sk" field.
+func SkEQ(v string) predicate.Whatsapp {
+	return predicate.Whatsapp(sql.FieldEQ(FieldSk, v))
+}
+
+// SkNEQ applies the NEQ predicate on the "sk" field.
+func SkNEQ(v string) predicate.Whatsapp {
+	return predicate.Whatsapp(sql.FieldNEQ(FieldSk, v))
+}
+
+// SkIn applies the In predicate on the "sk" field.
+func SkIn(vs ...string) predicate.Whatsapp {
+	return predicate.Whatsapp(sql.FieldIn(FieldSk, vs...))
+}
+
+// SkNotIn applies the NotIn predicate on the "sk" field.
+func SkNotIn(vs ...string) predicate.Whatsapp {
+	return predicate.Whatsapp(sql.FieldNotIn(FieldSk, vs...))
+}
+
+// SkGT applies the GT predicate on the "sk" field.
+func SkGT(v string) predicate.Whatsapp {
+	return predicate.Whatsapp(sql.FieldGT(FieldSk, v))
+}
+
+// SkGTE applies the GTE predicate on the "sk" field.
+func SkGTE(v string) predicate.Whatsapp {
+	return predicate.Whatsapp(sql.FieldGTE(FieldSk, v))
+}
+
+// SkLT applies the LT predicate on the "sk" field.
+func SkLT(v string) predicate.Whatsapp {
+	return predicate.Whatsapp(sql.FieldLT(FieldSk, v))
+}
+
+// SkLTE applies the LTE predicate on the "sk" field.
+func SkLTE(v string) predicate.Whatsapp {
+	return predicate.Whatsapp(sql.FieldLTE(FieldSk, v))
+}
+
+// SkContains applies the Contains predicate on the "sk" field.
+func SkContains(v string) predicate.Whatsapp {
+	return predicate.Whatsapp(sql.FieldContains(FieldSk, v))
+}
+
+// SkHasPrefix applies the HasPrefix predicate on the "sk" field.
+func SkHasPrefix(v string) predicate.Whatsapp {
+	return predicate.Whatsapp(sql.FieldHasPrefix(FieldSk, v))
+}
+
+// SkHasSuffix applies the HasSuffix predicate on the "sk" field.
+func SkHasSuffix(v string) predicate.Whatsapp {
+	return predicate.Whatsapp(sql.FieldHasSuffix(FieldSk, v))
+}
+
+// SkEqualFold applies the EqualFold predicate on the "sk" field.
+func SkEqualFold(v string) predicate.Whatsapp {
+	return predicate.Whatsapp(sql.FieldEqualFold(FieldSk, v))
+}
+
+// SkContainsFold applies the ContainsFold predicate on the "sk" field.
+func SkContainsFold(v string) predicate.Whatsapp {
+	return predicate.Whatsapp(sql.FieldContainsFold(FieldSk, v))
+}
+
+// CallbackEQ applies the EQ predicate on the "callback" field.
+func CallbackEQ(v string) predicate.Whatsapp {
+	return predicate.Whatsapp(sql.FieldEQ(FieldCallback, v))
+}
+
+// CallbackNEQ applies the NEQ predicate on the "callback" field.
+func CallbackNEQ(v string) predicate.Whatsapp {
+	return predicate.Whatsapp(sql.FieldNEQ(FieldCallback, v))
+}
+
+// CallbackIn applies the In predicate on the "callback" field.
+func CallbackIn(vs ...string) predicate.Whatsapp {
+	return predicate.Whatsapp(sql.FieldIn(FieldCallback, vs...))
+}
+
+// CallbackNotIn applies the NotIn predicate on the "callback" field.
+func CallbackNotIn(vs ...string) predicate.Whatsapp {
+	return predicate.Whatsapp(sql.FieldNotIn(FieldCallback, vs...))
+}
+
+// CallbackGT applies the GT predicate on the "callback" field.
+func CallbackGT(v string) predicate.Whatsapp {
+	return predicate.Whatsapp(sql.FieldGT(FieldCallback, v))
+}
+
+// CallbackGTE applies the GTE predicate on the "callback" field.
+func CallbackGTE(v string) predicate.Whatsapp {
+	return predicate.Whatsapp(sql.FieldGTE(FieldCallback, v))
+}
+
+// CallbackLT applies the LT predicate on the "callback" field.
+func CallbackLT(v string) predicate.Whatsapp {
+	return predicate.Whatsapp(sql.FieldLT(FieldCallback, v))
+}
+
+// CallbackLTE applies the LTE predicate on the "callback" field.
+func CallbackLTE(v string) predicate.Whatsapp {
+	return predicate.Whatsapp(sql.FieldLTE(FieldCallback, v))
+}
+
+// CallbackContains applies the Contains predicate on the "callback" field.
+func CallbackContains(v string) predicate.Whatsapp {
+	return predicate.Whatsapp(sql.FieldContains(FieldCallback, v))
+}
+
+// CallbackHasPrefix applies the HasPrefix predicate on the "callback" field.
+func CallbackHasPrefix(v string) predicate.Whatsapp {
+	return predicate.Whatsapp(sql.FieldHasPrefix(FieldCallback, v))
+}
+
+// CallbackHasSuffix applies the HasSuffix predicate on the "callback" field.
+func CallbackHasSuffix(v string) predicate.Whatsapp {
+	return predicate.Whatsapp(sql.FieldHasSuffix(FieldCallback, v))
+}
+
+// CallbackEqualFold applies the EqualFold predicate on the "callback" field.
+func CallbackEqualFold(v string) predicate.Whatsapp {
+	return predicate.Whatsapp(sql.FieldEqualFold(FieldCallback, v))
+}
+
+// CallbackContainsFold applies the ContainsFold predicate on the "callback" field.
+func CallbackContainsFold(v string) predicate.Whatsapp {
+	return predicate.Whatsapp(sql.FieldContainsFold(FieldCallback, v))
+}
+
+// AccountEQ applies the EQ predicate on the "account" field.
+func AccountEQ(v string) predicate.Whatsapp {
+	return predicate.Whatsapp(sql.FieldEQ(FieldAccount, v))
+}
+
+// AccountNEQ applies the NEQ predicate on the "account" field.
+func AccountNEQ(v string) predicate.Whatsapp {
+	return predicate.Whatsapp(sql.FieldNEQ(FieldAccount, v))
+}
+
+// AccountIn applies the In predicate on the "account" field.
+func AccountIn(vs ...string) predicate.Whatsapp {
+	return predicate.Whatsapp(sql.FieldIn(FieldAccount, vs...))
+}
+
+// AccountNotIn applies the NotIn predicate on the "account" field.
+func AccountNotIn(vs ...string) predicate.Whatsapp {
+	return predicate.Whatsapp(sql.FieldNotIn(FieldAccount, vs...))
+}
+
+// AccountGT applies the GT predicate on the "account" field.
+func AccountGT(v string) predicate.Whatsapp {
+	return predicate.Whatsapp(sql.FieldGT(FieldAccount, v))
+}
+
+// AccountGTE applies the GTE predicate on the "account" field.
+func AccountGTE(v string) predicate.Whatsapp {
+	return predicate.Whatsapp(sql.FieldGTE(FieldAccount, v))
+}
+
+// AccountLT applies the LT predicate on the "account" field.
+func AccountLT(v string) predicate.Whatsapp {
+	return predicate.Whatsapp(sql.FieldLT(FieldAccount, v))
+}
+
+// AccountLTE applies the LTE predicate on the "account" field.
+func AccountLTE(v string) predicate.Whatsapp {
+	return predicate.Whatsapp(sql.FieldLTE(FieldAccount, v))
+}
+
+// AccountContains applies the Contains predicate on the "account" field.
+func AccountContains(v string) predicate.Whatsapp {
+	return predicate.Whatsapp(sql.FieldContains(FieldAccount, v))
+}
+
+// AccountHasPrefix applies the HasPrefix predicate on the "account" field.
+func AccountHasPrefix(v string) predicate.Whatsapp {
+	return predicate.Whatsapp(sql.FieldHasPrefix(FieldAccount, v))
+}
+
+// AccountHasSuffix applies the HasSuffix predicate on the "account" field.
+func AccountHasSuffix(v string) predicate.Whatsapp {
+	return predicate.Whatsapp(sql.FieldHasSuffix(FieldAccount, v))
+}
+
+// AccountEqualFold applies the EqualFold predicate on the "account" field.
+func AccountEqualFold(v string) predicate.Whatsapp {
+	return predicate.Whatsapp(sql.FieldEqualFold(FieldAccount, v))
+}
+
+// AccountContainsFold applies the ContainsFold predicate on the "account" field.
+func AccountContainsFold(v string) predicate.Whatsapp {
+	return predicate.Whatsapp(sql.FieldContainsFold(FieldAccount, v))
+}
+
+// NicknameEQ applies the EQ predicate on the "nickname" field.
+func NicknameEQ(v string) predicate.Whatsapp {
+	return predicate.Whatsapp(sql.FieldEQ(FieldNickname, v))
+}
+
+// NicknameNEQ applies the NEQ predicate on the "nickname" field.
+func NicknameNEQ(v string) predicate.Whatsapp {
+	return predicate.Whatsapp(sql.FieldNEQ(FieldNickname, v))
+}
+
+// NicknameIn applies the In predicate on the "nickname" field.
+func NicknameIn(vs ...string) predicate.Whatsapp {
+	return predicate.Whatsapp(sql.FieldIn(FieldNickname, vs...))
+}
+
+// NicknameNotIn applies the NotIn predicate on the "nickname" field.
+func NicknameNotIn(vs ...string) predicate.Whatsapp {
+	return predicate.Whatsapp(sql.FieldNotIn(FieldNickname, vs...))
+}
+
+// NicknameGT applies the GT predicate on the "nickname" field.
+func NicknameGT(v string) predicate.Whatsapp {
+	return predicate.Whatsapp(sql.FieldGT(FieldNickname, v))
+}
+
+// NicknameGTE applies the GTE predicate on the "nickname" field.
+func NicknameGTE(v string) predicate.Whatsapp {
+	return predicate.Whatsapp(sql.FieldGTE(FieldNickname, v))
+}
+
+// NicknameLT applies the LT predicate on the "nickname" field.
+func NicknameLT(v string) predicate.Whatsapp {
+	return predicate.Whatsapp(sql.FieldLT(FieldNickname, v))
+}
+
+// NicknameLTE applies the LTE predicate on the "nickname" field.
+func NicknameLTE(v string) predicate.Whatsapp {
+	return predicate.Whatsapp(sql.FieldLTE(FieldNickname, v))
+}
+
+// NicknameContains applies the Contains predicate on the "nickname" field.
+func NicknameContains(v string) predicate.Whatsapp {
+	return predicate.Whatsapp(sql.FieldContains(FieldNickname, v))
+}
+
+// NicknameHasPrefix applies the HasPrefix predicate on the "nickname" field.
+func NicknameHasPrefix(v string) predicate.Whatsapp {
+	return predicate.Whatsapp(sql.FieldHasPrefix(FieldNickname, v))
+}
+
+// NicknameHasSuffix applies the HasSuffix predicate on the "nickname" field.
+func NicknameHasSuffix(v string) predicate.Whatsapp {
+	return predicate.Whatsapp(sql.FieldHasSuffix(FieldNickname, v))
+}
+
+// NicknameEqualFold applies the EqualFold predicate on the "nickname" field.
+func NicknameEqualFold(v string) predicate.Whatsapp {
+	return predicate.Whatsapp(sql.FieldEqualFold(FieldNickname, v))
+}
+
+// NicknameContainsFold applies the ContainsFold predicate on the "nickname" field.
+func NicknameContainsFold(v string) predicate.Whatsapp {
+	return predicate.Whatsapp(sql.FieldContainsFold(FieldNickname, v))
+}
+
+// PhoneEQ applies the EQ predicate on the "phone" field.
+func PhoneEQ(v string) predicate.Whatsapp {
+	return predicate.Whatsapp(sql.FieldEQ(FieldPhone, v))
+}
+
+// PhoneNEQ applies the NEQ predicate on the "phone" field.
+func PhoneNEQ(v string) predicate.Whatsapp {
+	return predicate.Whatsapp(sql.FieldNEQ(FieldPhone, v))
+}
+
+// PhoneIn applies the In predicate on the "phone" field.
+func PhoneIn(vs ...string) predicate.Whatsapp {
+	return predicate.Whatsapp(sql.FieldIn(FieldPhone, vs...))
+}
+
+// PhoneNotIn applies the NotIn predicate on the "phone" field.
+func PhoneNotIn(vs ...string) predicate.Whatsapp {
+	return predicate.Whatsapp(sql.FieldNotIn(FieldPhone, vs...))
+}
+
+// PhoneGT applies the GT predicate on the "phone" field.
+func PhoneGT(v string) predicate.Whatsapp {
+	return predicate.Whatsapp(sql.FieldGT(FieldPhone, v))
+}
+
+// PhoneGTE applies the GTE predicate on the "phone" field.
+func PhoneGTE(v string) predicate.Whatsapp {
+	return predicate.Whatsapp(sql.FieldGTE(FieldPhone, v))
+}
+
+// PhoneLT applies the LT predicate on the "phone" field.
+func PhoneLT(v string) predicate.Whatsapp {
+	return predicate.Whatsapp(sql.FieldLT(FieldPhone, v))
+}
+
+// PhoneLTE applies the LTE predicate on the "phone" field.
+func PhoneLTE(v string) predicate.Whatsapp {
+	return predicate.Whatsapp(sql.FieldLTE(FieldPhone, v))
+}
+
+// PhoneContains applies the Contains predicate on the "phone" field.
+func PhoneContains(v string) predicate.Whatsapp {
+	return predicate.Whatsapp(sql.FieldContains(FieldPhone, v))
+}
+
+// PhoneHasPrefix applies the HasPrefix predicate on the "phone" field.
+func PhoneHasPrefix(v string) predicate.Whatsapp {
+	return predicate.Whatsapp(sql.FieldHasPrefix(FieldPhone, v))
+}
+
+// PhoneHasSuffix applies the HasSuffix predicate on the "phone" field.
+func PhoneHasSuffix(v string) predicate.Whatsapp {
+	return predicate.Whatsapp(sql.FieldHasSuffix(FieldPhone, v))
+}
+
+// PhoneEqualFold applies the EqualFold predicate on the "phone" field.
+func PhoneEqualFold(v string) predicate.Whatsapp {
+	return predicate.Whatsapp(sql.FieldEqualFold(FieldPhone, v))
+}
+
+// PhoneContainsFold applies the ContainsFold predicate on the "phone" field.
+func PhoneContainsFold(v string) predicate.Whatsapp {
+	return predicate.Whatsapp(sql.FieldContainsFold(FieldPhone, v))
+}
+
+// OrganizationIDEQ applies the EQ predicate on the "organization_id" field.
+func OrganizationIDEQ(v uint64) predicate.Whatsapp {
+	return predicate.Whatsapp(sql.FieldEQ(FieldOrganizationID, v))
+}
+
+// OrganizationIDNEQ applies the NEQ predicate on the "organization_id" field.
+func OrganizationIDNEQ(v uint64) predicate.Whatsapp {
+	return predicate.Whatsapp(sql.FieldNEQ(FieldOrganizationID, v))
+}
+
+// OrganizationIDIn applies the In predicate on the "organization_id" field.
+func OrganizationIDIn(vs ...uint64) predicate.Whatsapp {
+	return predicate.Whatsapp(sql.FieldIn(FieldOrganizationID, vs...))
+}
+
+// OrganizationIDNotIn applies the NotIn predicate on the "organization_id" field.
+func OrganizationIDNotIn(vs ...uint64) predicate.Whatsapp {
+	return predicate.Whatsapp(sql.FieldNotIn(FieldOrganizationID, vs...))
+}
+
+// OrganizationIDGT applies the GT predicate on the "organization_id" field.
+func OrganizationIDGT(v uint64) predicate.Whatsapp {
+	return predicate.Whatsapp(sql.FieldGT(FieldOrganizationID, v))
+}
+
+// OrganizationIDGTE applies the GTE predicate on the "organization_id" field.
+func OrganizationIDGTE(v uint64) predicate.Whatsapp {
+	return predicate.Whatsapp(sql.FieldGTE(FieldOrganizationID, v))
+}
+
+// OrganizationIDLT applies the LT predicate on the "organization_id" field.
+func OrganizationIDLT(v uint64) predicate.Whatsapp {
+	return predicate.Whatsapp(sql.FieldLT(FieldOrganizationID, v))
+}
+
+// OrganizationIDLTE applies the LTE predicate on the "organization_id" field.
+func OrganizationIDLTE(v uint64) predicate.Whatsapp {
+	return predicate.Whatsapp(sql.FieldLTE(FieldOrganizationID, v))
+}
+
+// OrganizationIDIsNil applies the IsNil predicate on the "organization_id" field.
+func OrganizationIDIsNil() predicate.Whatsapp {
+	return predicate.Whatsapp(sql.FieldIsNull(FieldOrganizationID))
+}
+
+// OrganizationIDNotNil applies the NotNil predicate on the "organization_id" field.
+func OrganizationIDNotNil() predicate.Whatsapp {
+	return predicate.Whatsapp(sql.FieldNotNull(FieldOrganizationID))
+}
+
+// AgentIDEQ applies the EQ predicate on the "agent_id" field.
+func AgentIDEQ(v uint64) predicate.Whatsapp {
+	return predicate.Whatsapp(sql.FieldEQ(FieldAgentID, v))
+}
+
+// AgentIDNEQ applies the NEQ predicate on the "agent_id" field.
+func AgentIDNEQ(v uint64) predicate.Whatsapp {
+	return predicate.Whatsapp(sql.FieldNEQ(FieldAgentID, v))
+}
+
+// AgentIDIn applies the In predicate on the "agent_id" field.
+func AgentIDIn(vs ...uint64) predicate.Whatsapp {
+	return predicate.Whatsapp(sql.FieldIn(FieldAgentID, vs...))
+}
+
+// AgentIDNotIn applies the NotIn predicate on the "agent_id" field.
+func AgentIDNotIn(vs ...uint64) predicate.Whatsapp {
+	return predicate.Whatsapp(sql.FieldNotIn(FieldAgentID, vs...))
+}
+
+// AgentIDGT applies the GT predicate on the "agent_id" field.
+func AgentIDGT(v uint64) predicate.Whatsapp {
+	return predicate.Whatsapp(sql.FieldGT(FieldAgentID, v))
+}
+
+// AgentIDGTE applies the GTE predicate on the "agent_id" field.
+func AgentIDGTE(v uint64) predicate.Whatsapp {
+	return predicate.Whatsapp(sql.FieldGTE(FieldAgentID, v))
+}
+
+// AgentIDLT applies the LT predicate on the "agent_id" field.
+func AgentIDLT(v uint64) predicate.Whatsapp {
+	return predicate.Whatsapp(sql.FieldLT(FieldAgentID, v))
+}
+
+// AgentIDLTE applies the LTE predicate on the "agent_id" field.
+func AgentIDLTE(v uint64) predicate.Whatsapp {
+	return predicate.Whatsapp(sql.FieldLTE(FieldAgentID, v))
+}
+
+// APIBaseEQ applies the EQ predicate on the "api_base" field.
+func APIBaseEQ(v string) predicate.Whatsapp {
+	return predicate.Whatsapp(sql.FieldEQ(FieldAPIBase, v))
+}
+
+// APIBaseNEQ applies the NEQ predicate on the "api_base" field.
+func APIBaseNEQ(v string) predicate.Whatsapp {
+	return predicate.Whatsapp(sql.FieldNEQ(FieldAPIBase, v))
+}
+
+// APIBaseIn applies the In predicate on the "api_base" field.
+func APIBaseIn(vs ...string) predicate.Whatsapp {
+	return predicate.Whatsapp(sql.FieldIn(FieldAPIBase, vs...))
+}
+
+// APIBaseNotIn applies the NotIn predicate on the "api_base" field.
+func APIBaseNotIn(vs ...string) predicate.Whatsapp {
+	return predicate.Whatsapp(sql.FieldNotIn(FieldAPIBase, vs...))
+}
+
+// APIBaseGT applies the GT predicate on the "api_base" field.
+func APIBaseGT(v string) predicate.Whatsapp {
+	return predicate.Whatsapp(sql.FieldGT(FieldAPIBase, v))
+}
+
+// APIBaseGTE applies the GTE predicate on the "api_base" field.
+func APIBaseGTE(v string) predicate.Whatsapp {
+	return predicate.Whatsapp(sql.FieldGTE(FieldAPIBase, v))
+}
+
+// APIBaseLT applies the LT predicate on the "api_base" field.
+func APIBaseLT(v string) predicate.Whatsapp {
+	return predicate.Whatsapp(sql.FieldLT(FieldAPIBase, v))
+}
+
+// APIBaseLTE applies the LTE predicate on the "api_base" field.
+func APIBaseLTE(v string) predicate.Whatsapp {
+	return predicate.Whatsapp(sql.FieldLTE(FieldAPIBase, v))
+}
+
+// APIBaseContains applies the Contains predicate on the "api_base" field.
+func APIBaseContains(v string) predicate.Whatsapp {
+	return predicate.Whatsapp(sql.FieldContains(FieldAPIBase, v))
+}
+
+// APIBaseHasPrefix applies the HasPrefix predicate on the "api_base" field.
+func APIBaseHasPrefix(v string) predicate.Whatsapp {
+	return predicate.Whatsapp(sql.FieldHasPrefix(FieldAPIBase, v))
+}
+
+// APIBaseHasSuffix applies the HasSuffix predicate on the "api_base" field.
+func APIBaseHasSuffix(v string) predicate.Whatsapp {
+	return predicate.Whatsapp(sql.FieldHasSuffix(FieldAPIBase, v))
+}
+
+// APIBaseIsNil applies the IsNil predicate on the "api_base" field.
+func APIBaseIsNil() predicate.Whatsapp {
+	return predicate.Whatsapp(sql.FieldIsNull(FieldAPIBase))
+}
+
+// APIBaseNotNil applies the NotNil predicate on the "api_base" field.
+func APIBaseNotNil() predicate.Whatsapp {
+	return predicate.Whatsapp(sql.FieldNotNull(FieldAPIBase))
+}
+
+// APIBaseEqualFold applies the EqualFold predicate on the "api_base" field.
+func APIBaseEqualFold(v string) predicate.Whatsapp {
+	return predicate.Whatsapp(sql.FieldEqualFold(FieldAPIBase, v))
+}
+
+// APIBaseContainsFold applies the ContainsFold predicate on the "api_base" field.
+func APIBaseContainsFold(v string) predicate.Whatsapp {
+	return predicate.Whatsapp(sql.FieldContainsFold(FieldAPIBase, v))
+}
+
+// APIKeyEQ applies the EQ predicate on the "api_key" field.
+func APIKeyEQ(v string) predicate.Whatsapp {
+	return predicate.Whatsapp(sql.FieldEQ(FieldAPIKey, v))
+}
+
+// APIKeyNEQ applies the NEQ predicate on the "api_key" field.
+func APIKeyNEQ(v string) predicate.Whatsapp {
+	return predicate.Whatsapp(sql.FieldNEQ(FieldAPIKey, v))
+}
+
+// APIKeyIn applies the In predicate on the "api_key" field.
+func APIKeyIn(vs ...string) predicate.Whatsapp {
+	return predicate.Whatsapp(sql.FieldIn(FieldAPIKey, vs...))
+}
+
+// APIKeyNotIn applies the NotIn predicate on the "api_key" field.
+func APIKeyNotIn(vs ...string) predicate.Whatsapp {
+	return predicate.Whatsapp(sql.FieldNotIn(FieldAPIKey, vs...))
+}
+
+// APIKeyGT applies the GT predicate on the "api_key" field.
+func APIKeyGT(v string) predicate.Whatsapp {
+	return predicate.Whatsapp(sql.FieldGT(FieldAPIKey, v))
+}
+
+// APIKeyGTE applies the GTE predicate on the "api_key" field.
+func APIKeyGTE(v string) predicate.Whatsapp {
+	return predicate.Whatsapp(sql.FieldGTE(FieldAPIKey, v))
+}
+
+// APIKeyLT applies the LT predicate on the "api_key" field.
+func APIKeyLT(v string) predicate.Whatsapp {
+	return predicate.Whatsapp(sql.FieldLT(FieldAPIKey, v))
+}
+
+// APIKeyLTE applies the LTE predicate on the "api_key" field.
+func APIKeyLTE(v string) predicate.Whatsapp {
+	return predicate.Whatsapp(sql.FieldLTE(FieldAPIKey, v))
+}
+
+// APIKeyContains applies the Contains predicate on the "api_key" field.
+func APIKeyContains(v string) predicate.Whatsapp {
+	return predicate.Whatsapp(sql.FieldContains(FieldAPIKey, v))
+}
+
+// APIKeyHasPrefix applies the HasPrefix predicate on the "api_key" field.
+func APIKeyHasPrefix(v string) predicate.Whatsapp {
+	return predicate.Whatsapp(sql.FieldHasPrefix(FieldAPIKey, v))
+}
+
+// APIKeyHasSuffix applies the HasSuffix predicate on the "api_key" field.
+func APIKeyHasSuffix(v string) predicate.Whatsapp {
+	return predicate.Whatsapp(sql.FieldHasSuffix(FieldAPIKey, v))
+}
+
+// APIKeyIsNil applies the IsNil predicate on the "api_key" field.
+func APIKeyIsNil() predicate.Whatsapp {
+	return predicate.Whatsapp(sql.FieldIsNull(FieldAPIKey))
+}
+
+// APIKeyNotNil applies the NotNil predicate on the "api_key" field.
+func APIKeyNotNil() predicate.Whatsapp {
+	return predicate.Whatsapp(sql.FieldNotNull(FieldAPIKey))
+}
+
+// APIKeyEqualFold applies the EqualFold predicate on the "api_key" field.
+func APIKeyEqualFold(v string) predicate.Whatsapp {
+	return predicate.Whatsapp(sql.FieldEqualFold(FieldAPIKey, v))
+}
+
+// APIKeyContainsFold applies the ContainsFold predicate on the "api_key" field.
+func APIKeyContainsFold(v string) predicate.Whatsapp {
+	return predicate.Whatsapp(sql.FieldContainsFold(FieldAPIKey, v))
+}
+
+// And groups predicates with the AND operator between them.
+func And(predicates ...predicate.Whatsapp) predicate.Whatsapp {
+	return predicate.Whatsapp(sql.AndPredicates(predicates...))
+}
+
+// Or groups predicates with the OR operator between them.
+func Or(predicates ...predicate.Whatsapp) predicate.Whatsapp {
+	return predicate.Whatsapp(sql.OrPredicates(predicates...))
+}
+
+// Not applies the not operator on the given predicate.
+func Not(p predicate.Whatsapp) predicate.Whatsapp {
+	return predicate.Whatsapp(sql.NotPredicates(p))
+}

+ 1693 - 0
ent/whatsapp_create.go

@@ -0,0 +1,1693 @@
+// Code generated by ent, DO NOT EDIT.
+
+package ent
+
+import (
+	"context"
+	"errors"
+	"fmt"
+	"time"
+	"wechat-api/ent/whatsapp"
+
+	"entgo.io/ent/dialect/sql"
+	"entgo.io/ent/dialect/sql/sqlgraph"
+	"entgo.io/ent/schema/field"
+)
+
+// WhatsappCreate is the builder for creating a Whatsapp entity.
+type WhatsappCreate struct {
+	config
+	mutation *WhatsappMutation
+	hooks    []Hook
+	conflict []sql.ConflictOption
+}
+
+// SetCreatedAt sets the "created_at" field.
+func (wc *WhatsappCreate) SetCreatedAt(t time.Time) *WhatsappCreate {
+	wc.mutation.SetCreatedAt(t)
+	return wc
+}
+
+// SetNillableCreatedAt sets the "created_at" field if the given value is not nil.
+func (wc *WhatsappCreate) SetNillableCreatedAt(t *time.Time) *WhatsappCreate {
+	if t != nil {
+		wc.SetCreatedAt(*t)
+	}
+	return wc
+}
+
+// SetUpdatedAt sets the "updated_at" field.
+func (wc *WhatsappCreate) SetUpdatedAt(t time.Time) *WhatsappCreate {
+	wc.mutation.SetUpdatedAt(t)
+	return wc
+}
+
+// SetNillableUpdatedAt sets the "updated_at" field if the given value is not nil.
+func (wc *WhatsappCreate) SetNillableUpdatedAt(t *time.Time) *WhatsappCreate {
+	if t != nil {
+		wc.SetUpdatedAt(*t)
+	}
+	return wc
+}
+
+// SetStatus sets the "status" field.
+func (wc *WhatsappCreate) SetStatus(u uint8) *WhatsappCreate {
+	wc.mutation.SetStatus(u)
+	return wc
+}
+
+// SetNillableStatus sets the "status" field if the given value is not nil.
+func (wc *WhatsappCreate) SetNillableStatus(u *uint8) *WhatsappCreate {
+	if u != nil {
+		wc.SetStatus(*u)
+	}
+	return wc
+}
+
+// SetDeletedAt sets the "deleted_at" field.
+func (wc *WhatsappCreate) SetDeletedAt(t time.Time) *WhatsappCreate {
+	wc.mutation.SetDeletedAt(t)
+	return wc
+}
+
+// SetNillableDeletedAt sets the "deleted_at" field if the given value is not nil.
+func (wc *WhatsappCreate) SetNillableDeletedAt(t *time.Time) *WhatsappCreate {
+	if t != nil {
+		wc.SetDeletedAt(*t)
+	}
+	return wc
+}
+
+// SetAk sets the "ak" field.
+func (wc *WhatsappCreate) SetAk(s string) *WhatsappCreate {
+	wc.mutation.SetAk(s)
+	return wc
+}
+
+// SetNillableAk sets the "ak" field if the given value is not nil.
+func (wc *WhatsappCreate) SetNillableAk(s *string) *WhatsappCreate {
+	if s != nil {
+		wc.SetAk(*s)
+	}
+	return wc
+}
+
+// SetSk sets the "sk" field.
+func (wc *WhatsappCreate) SetSk(s string) *WhatsappCreate {
+	wc.mutation.SetSk(s)
+	return wc
+}
+
+// SetNillableSk sets the "sk" field if the given value is not nil.
+func (wc *WhatsappCreate) SetNillableSk(s *string) *WhatsappCreate {
+	if s != nil {
+		wc.SetSk(*s)
+	}
+	return wc
+}
+
+// SetCallback sets the "callback" field.
+func (wc *WhatsappCreate) SetCallback(s string) *WhatsappCreate {
+	wc.mutation.SetCallback(s)
+	return wc
+}
+
+// SetNillableCallback sets the "callback" field if the given value is not nil.
+func (wc *WhatsappCreate) SetNillableCallback(s *string) *WhatsappCreate {
+	if s != nil {
+		wc.SetCallback(*s)
+	}
+	return wc
+}
+
+// SetAccount sets the "account" field.
+func (wc *WhatsappCreate) SetAccount(s string) *WhatsappCreate {
+	wc.mutation.SetAccount(s)
+	return wc
+}
+
+// SetNillableAccount sets the "account" field if the given value is not nil.
+func (wc *WhatsappCreate) SetNillableAccount(s *string) *WhatsappCreate {
+	if s != nil {
+		wc.SetAccount(*s)
+	}
+	return wc
+}
+
+// SetNickname sets the "nickname" field.
+func (wc *WhatsappCreate) SetNickname(s string) *WhatsappCreate {
+	wc.mutation.SetNickname(s)
+	return wc
+}
+
+// SetNillableNickname sets the "nickname" field if the given value is not nil.
+func (wc *WhatsappCreate) SetNillableNickname(s *string) *WhatsappCreate {
+	if s != nil {
+		wc.SetNickname(*s)
+	}
+	return wc
+}
+
+// SetPhone sets the "phone" field.
+func (wc *WhatsappCreate) SetPhone(s string) *WhatsappCreate {
+	wc.mutation.SetPhone(s)
+	return wc
+}
+
+// SetNillablePhone sets the "phone" field if the given value is not nil.
+func (wc *WhatsappCreate) SetNillablePhone(s *string) *WhatsappCreate {
+	if s != nil {
+		wc.SetPhone(*s)
+	}
+	return wc
+}
+
+// SetOrganizationID sets the "organization_id" field.
+func (wc *WhatsappCreate) SetOrganizationID(u uint64) *WhatsappCreate {
+	wc.mutation.SetOrganizationID(u)
+	return wc
+}
+
+// SetNillableOrganizationID sets the "organization_id" field if the given value is not nil.
+func (wc *WhatsappCreate) SetNillableOrganizationID(u *uint64) *WhatsappCreate {
+	if u != nil {
+		wc.SetOrganizationID(*u)
+	}
+	return wc
+}
+
+// SetAgentID sets the "agent_id" field.
+func (wc *WhatsappCreate) SetAgentID(u uint64) *WhatsappCreate {
+	wc.mutation.SetAgentID(u)
+	return wc
+}
+
+// SetNillableAgentID sets the "agent_id" field if the given value is not nil.
+func (wc *WhatsappCreate) SetNillableAgentID(u *uint64) *WhatsappCreate {
+	if u != nil {
+		wc.SetAgentID(*u)
+	}
+	return wc
+}
+
+// SetAPIBase sets the "api_base" field.
+func (wc *WhatsappCreate) SetAPIBase(s string) *WhatsappCreate {
+	wc.mutation.SetAPIBase(s)
+	return wc
+}
+
+// SetNillableAPIBase sets the "api_base" field if the given value is not nil.
+func (wc *WhatsappCreate) SetNillableAPIBase(s *string) *WhatsappCreate {
+	if s != nil {
+		wc.SetAPIBase(*s)
+	}
+	return wc
+}
+
+// SetAPIKey sets the "api_key" field.
+func (wc *WhatsappCreate) SetAPIKey(s string) *WhatsappCreate {
+	wc.mutation.SetAPIKey(s)
+	return wc
+}
+
+// SetNillableAPIKey sets the "api_key" field if the given value is not nil.
+func (wc *WhatsappCreate) SetNillableAPIKey(s *string) *WhatsappCreate {
+	if s != nil {
+		wc.SetAPIKey(*s)
+	}
+	return wc
+}
+
+// SetAllowList sets the "allow_list" field.
+func (wc *WhatsappCreate) SetAllowList(s []string) *WhatsappCreate {
+	wc.mutation.SetAllowList(s)
+	return wc
+}
+
+// SetGroupAllowList sets the "group_allow_list" field.
+func (wc *WhatsappCreate) SetGroupAllowList(s []string) *WhatsappCreate {
+	wc.mutation.SetGroupAllowList(s)
+	return wc
+}
+
+// SetBlockList sets the "block_list" field.
+func (wc *WhatsappCreate) SetBlockList(s []string) *WhatsappCreate {
+	wc.mutation.SetBlockList(s)
+	return wc
+}
+
+// SetGroupBlockList sets the "group_block_list" field.
+func (wc *WhatsappCreate) SetGroupBlockList(s []string) *WhatsappCreate {
+	wc.mutation.SetGroupBlockList(s)
+	return wc
+}
+
+// SetID sets the "id" field.
+func (wc *WhatsappCreate) SetID(u uint64) *WhatsappCreate {
+	wc.mutation.SetID(u)
+	return wc
+}
+
+// Mutation returns the WhatsappMutation object of the builder.
+func (wc *WhatsappCreate) Mutation() *WhatsappMutation {
+	return wc.mutation
+}
+
+// Save creates the Whatsapp in the database.
+func (wc *WhatsappCreate) Save(ctx context.Context) (*Whatsapp, error) {
+	if err := wc.defaults(); err != nil {
+		return nil, err
+	}
+	return withHooks(ctx, wc.sqlSave, wc.mutation, wc.hooks)
+}
+
+// SaveX calls Save and panics if Save returns an error.
+func (wc *WhatsappCreate) SaveX(ctx context.Context) *Whatsapp {
+	v, err := wc.Save(ctx)
+	if err != nil {
+		panic(err)
+	}
+	return v
+}
+
+// Exec executes the query.
+func (wc *WhatsappCreate) Exec(ctx context.Context) error {
+	_, err := wc.Save(ctx)
+	return err
+}
+
+// ExecX is like Exec, but panics if an error occurs.
+func (wc *WhatsappCreate) ExecX(ctx context.Context) {
+	if err := wc.Exec(ctx); err != nil {
+		panic(err)
+	}
+}
+
+// defaults sets the default values of the builder before save.
+func (wc *WhatsappCreate) defaults() error {
+	if _, ok := wc.mutation.CreatedAt(); !ok {
+		if whatsapp.DefaultCreatedAt == nil {
+			return fmt.Errorf("ent: uninitialized whatsapp.DefaultCreatedAt (forgotten import ent/runtime?)")
+		}
+		v := whatsapp.DefaultCreatedAt()
+		wc.mutation.SetCreatedAt(v)
+	}
+	if _, ok := wc.mutation.UpdatedAt(); !ok {
+		if whatsapp.DefaultUpdatedAt == nil {
+			return fmt.Errorf("ent: uninitialized whatsapp.DefaultUpdatedAt (forgotten import ent/runtime?)")
+		}
+		v := whatsapp.DefaultUpdatedAt()
+		wc.mutation.SetUpdatedAt(v)
+	}
+	if _, ok := wc.mutation.Status(); !ok {
+		v := whatsapp.DefaultStatus
+		wc.mutation.SetStatus(v)
+	}
+	if _, ok := wc.mutation.Ak(); !ok {
+		v := whatsapp.DefaultAk
+		wc.mutation.SetAk(v)
+	}
+	if _, ok := wc.mutation.Sk(); !ok {
+		v := whatsapp.DefaultSk
+		wc.mutation.SetSk(v)
+	}
+	if _, ok := wc.mutation.Callback(); !ok {
+		v := whatsapp.DefaultCallback
+		wc.mutation.SetCallback(v)
+	}
+	if _, ok := wc.mutation.Account(); !ok {
+		v := whatsapp.DefaultAccount
+		wc.mutation.SetAccount(v)
+	}
+	if _, ok := wc.mutation.Nickname(); !ok {
+		v := whatsapp.DefaultNickname
+		wc.mutation.SetNickname(v)
+	}
+	if _, ok := wc.mutation.Phone(); !ok {
+		v := whatsapp.DefaultPhone
+		wc.mutation.SetPhone(v)
+	}
+	if _, ok := wc.mutation.OrganizationID(); !ok {
+		v := whatsapp.DefaultOrganizationID
+		wc.mutation.SetOrganizationID(v)
+	}
+	if _, ok := wc.mutation.AgentID(); !ok {
+		v := whatsapp.DefaultAgentID
+		wc.mutation.SetAgentID(v)
+	}
+	if _, ok := wc.mutation.APIBase(); !ok {
+		v := whatsapp.DefaultAPIBase
+		wc.mutation.SetAPIBase(v)
+	}
+	if _, ok := wc.mutation.APIKey(); !ok {
+		v := whatsapp.DefaultAPIKey
+		wc.mutation.SetAPIKey(v)
+	}
+	return nil
+}
+
+// check runs all checks and user-defined validators on the builder.
+func (wc *WhatsappCreate) check() error {
+	if _, ok := wc.mutation.CreatedAt(); !ok {
+		return &ValidationError{Name: "created_at", err: errors.New(`ent: missing required field "Whatsapp.created_at"`)}
+	}
+	if _, ok := wc.mutation.UpdatedAt(); !ok {
+		return &ValidationError{Name: "updated_at", err: errors.New(`ent: missing required field "Whatsapp.updated_at"`)}
+	}
+	if _, ok := wc.mutation.Sk(); !ok {
+		return &ValidationError{Name: "sk", err: errors.New(`ent: missing required field "Whatsapp.sk"`)}
+	}
+	if _, ok := wc.mutation.Callback(); !ok {
+		return &ValidationError{Name: "callback", err: errors.New(`ent: missing required field "Whatsapp.callback"`)}
+	}
+	if _, ok := wc.mutation.Account(); !ok {
+		return &ValidationError{Name: "account", err: errors.New(`ent: missing required field "Whatsapp.account"`)}
+	}
+	if _, ok := wc.mutation.Nickname(); !ok {
+		return &ValidationError{Name: "nickname", err: errors.New(`ent: missing required field "Whatsapp.nickname"`)}
+	}
+	if _, ok := wc.mutation.Phone(); !ok {
+		return &ValidationError{Name: "phone", err: errors.New(`ent: missing required field "Whatsapp.phone"`)}
+	}
+	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.AllowList(); !ok {
+		return &ValidationError{Name: "allow_list", err: errors.New(`ent: missing required field "Whatsapp.allow_list"`)}
+	}
+	if _, ok := wc.mutation.GroupAllowList(); !ok {
+		return &ValidationError{Name: "group_allow_list", err: errors.New(`ent: missing required field "Whatsapp.group_allow_list"`)}
+	}
+	if _, ok := wc.mutation.BlockList(); !ok {
+		return &ValidationError{Name: "block_list", err: errors.New(`ent: missing required field "Whatsapp.block_list"`)}
+	}
+	if _, ok := wc.mutation.GroupBlockList(); !ok {
+		return &ValidationError{Name: "group_block_list", err: errors.New(`ent: missing required field "Whatsapp.group_block_list"`)}
+	}
+	return nil
+}
+
+func (wc *WhatsappCreate) sqlSave(ctx context.Context) (*Whatsapp, error) {
+	if err := wc.check(); err != nil {
+		return nil, err
+	}
+	_node, _spec := wc.createSpec()
+	if err := sqlgraph.CreateNode(ctx, wc.driver, _spec); err != nil {
+		if sqlgraph.IsConstraintError(err) {
+			err = &ConstraintError{msg: err.Error(), wrap: err}
+		}
+		return nil, err
+	}
+	if _spec.ID.Value != _node.ID {
+		id := _spec.ID.Value.(int64)
+		_node.ID = uint64(id)
+	}
+	wc.mutation.id = &_node.ID
+	wc.mutation.done = true
+	return _node, nil
+}
+
+func (wc *WhatsappCreate) createSpec() (*Whatsapp, *sqlgraph.CreateSpec) {
+	var (
+		_node = &Whatsapp{config: wc.config}
+		_spec = sqlgraph.NewCreateSpec(whatsapp.Table, sqlgraph.NewFieldSpec(whatsapp.FieldID, field.TypeUint64))
+	)
+	_spec.OnConflict = wc.conflict
+	if id, ok := wc.mutation.ID(); ok {
+		_node.ID = id
+		_spec.ID.Value = id
+	}
+	if value, ok := wc.mutation.CreatedAt(); ok {
+		_spec.SetField(whatsapp.FieldCreatedAt, field.TypeTime, value)
+		_node.CreatedAt = value
+	}
+	if value, ok := wc.mutation.UpdatedAt(); ok {
+		_spec.SetField(whatsapp.FieldUpdatedAt, field.TypeTime, value)
+		_node.UpdatedAt = value
+	}
+	if value, ok := wc.mutation.Status(); ok {
+		_spec.SetField(whatsapp.FieldStatus, field.TypeUint8, value)
+		_node.Status = value
+	}
+	if value, ok := wc.mutation.DeletedAt(); ok {
+		_spec.SetField(whatsapp.FieldDeletedAt, field.TypeTime, value)
+		_node.DeletedAt = value
+	}
+	if value, ok := wc.mutation.Ak(); ok {
+		_spec.SetField(whatsapp.FieldAk, field.TypeString, value)
+		_node.Ak = value
+	}
+	if value, ok := wc.mutation.Sk(); ok {
+		_spec.SetField(whatsapp.FieldSk, field.TypeString, value)
+		_node.Sk = value
+	}
+	if value, ok := wc.mutation.Callback(); ok {
+		_spec.SetField(whatsapp.FieldCallback, field.TypeString, value)
+		_node.Callback = value
+	}
+	if value, ok := wc.mutation.Account(); ok {
+		_spec.SetField(whatsapp.FieldAccount, field.TypeString, value)
+		_node.Account = value
+	}
+	if value, ok := wc.mutation.Nickname(); ok {
+		_spec.SetField(whatsapp.FieldNickname, field.TypeString, value)
+		_node.Nickname = value
+	}
+	if value, ok := wc.mutation.Phone(); ok {
+		_spec.SetField(whatsapp.FieldPhone, field.TypeString, value)
+		_node.Phone = value
+	}
+	if value, ok := wc.mutation.OrganizationID(); ok {
+		_spec.SetField(whatsapp.FieldOrganizationID, field.TypeUint64, value)
+		_node.OrganizationID = value
+	}
+	if value, ok := wc.mutation.AgentID(); ok {
+		_spec.SetField(whatsapp.FieldAgentID, field.TypeUint64, value)
+		_node.AgentID = value
+	}
+	if value, ok := wc.mutation.APIBase(); ok {
+		_spec.SetField(whatsapp.FieldAPIBase, field.TypeString, value)
+		_node.APIBase = value
+	}
+	if value, ok := wc.mutation.APIKey(); ok {
+		_spec.SetField(whatsapp.FieldAPIKey, field.TypeString, value)
+		_node.APIKey = value
+	}
+	if value, ok := wc.mutation.AllowList(); ok {
+		_spec.SetField(whatsapp.FieldAllowList, field.TypeJSON, value)
+		_node.AllowList = value
+	}
+	if value, ok := wc.mutation.GroupAllowList(); ok {
+		_spec.SetField(whatsapp.FieldGroupAllowList, field.TypeJSON, value)
+		_node.GroupAllowList = value
+	}
+	if value, ok := wc.mutation.BlockList(); ok {
+		_spec.SetField(whatsapp.FieldBlockList, field.TypeJSON, value)
+		_node.BlockList = value
+	}
+	if value, ok := wc.mutation.GroupBlockList(); ok {
+		_spec.SetField(whatsapp.FieldGroupBlockList, field.TypeJSON, value)
+		_node.GroupBlockList = value
+	}
+	return _node, _spec
+}
+
+// OnConflict allows configuring the `ON CONFLICT` / `ON DUPLICATE KEY` clause
+// of the `INSERT` statement. For example:
+//
+//	client.Whatsapp.Create().
+//		SetCreatedAt(v).
+//		OnConflict(
+//			// Update the row with the new values
+//			// the was proposed for insertion.
+//			sql.ResolveWithNewValues(),
+//		).
+//		// Override some of the fields with custom
+//		// update values.
+//		Update(func(u *ent.WhatsappUpsert) {
+//			SetCreatedAt(v+v).
+//		}).
+//		Exec(ctx)
+func (wc *WhatsappCreate) OnConflict(opts ...sql.ConflictOption) *WhatsappUpsertOne {
+	wc.conflict = opts
+	return &WhatsappUpsertOne{
+		create: wc,
+	}
+}
+
+// OnConflictColumns calls `OnConflict` and configures the columns
+// as conflict target. Using this option is equivalent to using:
+//
+//	client.Whatsapp.Create().
+//		OnConflict(sql.ConflictColumns(columns...)).
+//		Exec(ctx)
+func (wc *WhatsappCreate) OnConflictColumns(columns ...string) *WhatsappUpsertOne {
+	wc.conflict = append(wc.conflict, sql.ConflictColumns(columns...))
+	return &WhatsappUpsertOne{
+		create: wc,
+	}
+}
+
+type (
+	// WhatsappUpsertOne is the builder for "upsert"-ing
+	//  one Whatsapp node.
+	WhatsappUpsertOne struct {
+		create *WhatsappCreate
+	}
+
+	// WhatsappUpsert is the "OnConflict" setter.
+	WhatsappUpsert struct {
+		*sql.UpdateSet
+	}
+)
+
+// SetUpdatedAt sets the "updated_at" field.
+func (u *WhatsappUpsert) SetUpdatedAt(v time.Time) *WhatsappUpsert {
+	u.Set(whatsapp.FieldUpdatedAt, v)
+	return u
+}
+
+// UpdateUpdatedAt sets the "updated_at" field to the value that was provided on create.
+func (u *WhatsappUpsert) UpdateUpdatedAt() *WhatsappUpsert {
+	u.SetExcluded(whatsapp.FieldUpdatedAt)
+	return u
+}
+
+// SetStatus sets the "status" field.
+func (u *WhatsappUpsert) SetStatus(v uint8) *WhatsappUpsert {
+	u.Set(whatsapp.FieldStatus, v)
+	return u
+}
+
+// UpdateStatus sets the "status" field to the value that was provided on create.
+func (u *WhatsappUpsert) UpdateStatus() *WhatsappUpsert {
+	u.SetExcluded(whatsapp.FieldStatus)
+	return u
+}
+
+// AddStatus adds v to the "status" field.
+func (u *WhatsappUpsert) AddStatus(v uint8) *WhatsappUpsert {
+	u.Add(whatsapp.FieldStatus, v)
+	return u
+}
+
+// ClearStatus clears the value of the "status" field.
+func (u *WhatsappUpsert) ClearStatus() *WhatsappUpsert {
+	u.SetNull(whatsapp.FieldStatus)
+	return u
+}
+
+// SetDeletedAt sets the "deleted_at" field.
+func (u *WhatsappUpsert) SetDeletedAt(v time.Time) *WhatsappUpsert {
+	u.Set(whatsapp.FieldDeletedAt, v)
+	return u
+}
+
+// UpdateDeletedAt sets the "deleted_at" field to the value that was provided on create.
+func (u *WhatsappUpsert) UpdateDeletedAt() *WhatsappUpsert {
+	u.SetExcluded(whatsapp.FieldDeletedAt)
+	return u
+}
+
+// ClearDeletedAt clears the value of the "deleted_at" field.
+func (u *WhatsappUpsert) ClearDeletedAt() *WhatsappUpsert {
+	u.SetNull(whatsapp.FieldDeletedAt)
+	return u
+}
+
+// SetAk sets the "ak" field.
+func (u *WhatsappUpsert) SetAk(v string) *WhatsappUpsert {
+	u.Set(whatsapp.FieldAk, v)
+	return u
+}
+
+// UpdateAk sets the "ak" field to the value that was provided on create.
+func (u *WhatsappUpsert) UpdateAk() *WhatsappUpsert {
+	u.SetExcluded(whatsapp.FieldAk)
+	return u
+}
+
+// ClearAk clears the value of the "ak" field.
+func (u *WhatsappUpsert) ClearAk() *WhatsappUpsert {
+	u.SetNull(whatsapp.FieldAk)
+	return u
+}
+
+// SetSk sets the "sk" field.
+func (u *WhatsappUpsert) SetSk(v string) *WhatsappUpsert {
+	u.Set(whatsapp.FieldSk, v)
+	return u
+}
+
+// UpdateSk sets the "sk" field to the value that was provided on create.
+func (u *WhatsappUpsert) UpdateSk() *WhatsappUpsert {
+	u.SetExcluded(whatsapp.FieldSk)
+	return u
+}
+
+// SetCallback sets the "callback" field.
+func (u *WhatsappUpsert) SetCallback(v string) *WhatsappUpsert {
+	u.Set(whatsapp.FieldCallback, v)
+	return u
+}
+
+// UpdateCallback sets the "callback" field to the value that was provided on create.
+func (u *WhatsappUpsert) UpdateCallback() *WhatsappUpsert {
+	u.SetExcluded(whatsapp.FieldCallback)
+	return u
+}
+
+// SetAccount sets the "account" field.
+func (u *WhatsappUpsert) SetAccount(v string) *WhatsappUpsert {
+	u.Set(whatsapp.FieldAccount, v)
+	return u
+}
+
+// UpdateAccount sets the "account" field to the value that was provided on create.
+func (u *WhatsappUpsert) UpdateAccount() *WhatsappUpsert {
+	u.SetExcluded(whatsapp.FieldAccount)
+	return u
+}
+
+// SetNickname sets the "nickname" field.
+func (u *WhatsappUpsert) SetNickname(v string) *WhatsappUpsert {
+	u.Set(whatsapp.FieldNickname, v)
+	return u
+}
+
+// UpdateNickname sets the "nickname" field to the value that was provided on create.
+func (u *WhatsappUpsert) UpdateNickname() *WhatsappUpsert {
+	u.SetExcluded(whatsapp.FieldNickname)
+	return u
+}
+
+// SetPhone sets the "phone" field.
+func (u *WhatsappUpsert) SetPhone(v string) *WhatsappUpsert {
+	u.Set(whatsapp.FieldPhone, v)
+	return u
+}
+
+// UpdatePhone sets the "phone" field to the value that was provided on create.
+func (u *WhatsappUpsert) UpdatePhone() *WhatsappUpsert {
+	u.SetExcluded(whatsapp.FieldPhone)
+	return u
+}
+
+// SetOrganizationID sets the "organization_id" field.
+func (u *WhatsappUpsert) SetOrganizationID(v uint64) *WhatsappUpsert {
+	u.Set(whatsapp.FieldOrganizationID, v)
+	return u
+}
+
+// UpdateOrganizationID sets the "organization_id" field to the value that was provided on create.
+func (u *WhatsappUpsert) UpdateOrganizationID() *WhatsappUpsert {
+	u.SetExcluded(whatsapp.FieldOrganizationID)
+	return u
+}
+
+// AddOrganizationID adds v to the "organization_id" field.
+func (u *WhatsappUpsert) AddOrganizationID(v uint64) *WhatsappUpsert {
+	u.Add(whatsapp.FieldOrganizationID, v)
+	return u
+}
+
+// ClearOrganizationID clears the value of the "organization_id" field.
+func (u *WhatsappUpsert) ClearOrganizationID() *WhatsappUpsert {
+	u.SetNull(whatsapp.FieldOrganizationID)
+	return u
+}
+
+// SetAgentID sets the "agent_id" field.
+func (u *WhatsappUpsert) SetAgentID(v uint64) *WhatsappUpsert {
+	u.Set(whatsapp.FieldAgentID, v)
+	return u
+}
+
+// UpdateAgentID sets the "agent_id" field to the value that was provided on create.
+func (u *WhatsappUpsert) UpdateAgentID() *WhatsappUpsert {
+	u.SetExcluded(whatsapp.FieldAgentID)
+	return u
+}
+
+// AddAgentID adds v to the "agent_id" field.
+func (u *WhatsappUpsert) AddAgentID(v uint64) *WhatsappUpsert {
+	u.Add(whatsapp.FieldAgentID, v)
+	return u
+}
+
+// SetAPIBase sets the "api_base" field.
+func (u *WhatsappUpsert) SetAPIBase(v string) *WhatsappUpsert {
+	u.Set(whatsapp.FieldAPIBase, v)
+	return u
+}
+
+// UpdateAPIBase sets the "api_base" field to the value that was provided on create.
+func (u *WhatsappUpsert) UpdateAPIBase() *WhatsappUpsert {
+	u.SetExcluded(whatsapp.FieldAPIBase)
+	return u
+}
+
+// ClearAPIBase clears the value of the "api_base" field.
+func (u *WhatsappUpsert) ClearAPIBase() *WhatsappUpsert {
+	u.SetNull(whatsapp.FieldAPIBase)
+	return u
+}
+
+// SetAPIKey sets the "api_key" field.
+func (u *WhatsappUpsert) SetAPIKey(v string) *WhatsappUpsert {
+	u.Set(whatsapp.FieldAPIKey, v)
+	return u
+}
+
+// UpdateAPIKey sets the "api_key" field to the value that was provided on create.
+func (u *WhatsappUpsert) UpdateAPIKey() *WhatsappUpsert {
+	u.SetExcluded(whatsapp.FieldAPIKey)
+	return u
+}
+
+// ClearAPIKey clears the value of the "api_key" field.
+func (u *WhatsappUpsert) ClearAPIKey() *WhatsappUpsert {
+	u.SetNull(whatsapp.FieldAPIKey)
+	return u
+}
+
+// SetAllowList sets the "allow_list" field.
+func (u *WhatsappUpsert) SetAllowList(v []string) *WhatsappUpsert {
+	u.Set(whatsapp.FieldAllowList, v)
+	return u
+}
+
+// UpdateAllowList sets the "allow_list" field to the value that was provided on create.
+func (u *WhatsappUpsert) UpdateAllowList() *WhatsappUpsert {
+	u.SetExcluded(whatsapp.FieldAllowList)
+	return u
+}
+
+// SetGroupAllowList sets the "group_allow_list" field.
+func (u *WhatsappUpsert) SetGroupAllowList(v []string) *WhatsappUpsert {
+	u.Set(whatsapp.FieldGroupAllowList, v)
+	return u
+}
+
+// UpdateGroupAllowList sets the "group_allow_list" field to the value that was provided on create.
+func (u *WhatsappUpsert) UpdateGroupAllowList() *WhatsappUpsert {
+	u.SetExcluded(whatsapp.FieldGroupAllowList)
+	return u
+}
+
+// SetBlockList sets the "block_list" field.
+func (u *WhatsappUpsert) SetBlockList(v []string) *WhatsappUpsert {
+	u.Set(whatsapp.FieldBlockList, v)
+	return u
+}
+
+// UpdateBlockList sets the "block_list" field to the value that was provided on create.
+func (u *WhatsappUpsert) UpdateBlockList() *WhatsappUpsert {
+	u.SetExcluded(whatsapp.FieldBlockList)
+	return u
+}
+
+// SetGroupBlockList sets the "group_block_list" field.
+func (u *WhatsappUpsert) SetGroupBlockList(v []string) *WhatsappUpsert {
+	u.Set(whatsapp.FieldGroupBlockList, v)
+	return u
+}
+
+// UpdateGroupBlockList sets the "group_block_list" field to the value that was provided on create.
+func (u *WhatsappUpsert) UpdateGroupBlockList() *WhatsappUpsert {
+	u.SetExcluded(whatsapp.FieldGroupBlockList)
+	return u
+}
+
+// UpdateNewValues updates the mutable fields using the new values that were set on create except the ID field.
+// Using this option is equivalent to using:
+//
+//	client.Whatsapp.Create().
+//		OnConflict(
+//			sql.ResolveWithNewValues(),
+//			sql.ResolveWith(func(u *sql.UpdateSet) {
+//				u.SetIgnore(whatsapp.FieldID)
+//			}),
+//		).
+//		Exec(ctx)
+func (u *WhatsappUpsertOne) UpdateNewValues() *WhatsappUpsertOne {
+	u.create.conflict = append(u.create.conflict, sql.ResolveWithNewValues())
+	u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(s *sql.UpdateSet) {
+		if _, exists := u.create.mutation.ID(); exists {
+			s.SetIgnore(whatsapp.FieldID)
+		}
+		if _, exists := u.create.mutation.CreatedAt(); exists {
+			s.SetIgnore(whatsapp.FieldCreatedAt)
+		}
+	}))
+	return u
+}
+
+// Ignore sets each column to itself in case of conflict.
+// Using this option is equivalent to using:
+//
+//	client.Whatsapp.Create().
+//	    OnConflict(sql.ResolveWithIgnore()).
+//	    Exec(ctx)
+func (u *WhatsappUpsertOne) Ignore() *WhatsappUpsertOne {
+	u.create.conflict = append(u.create.conflict, sql.ResolveWithIgnore())
+	return u
+}
+
+// DoNothing configures the conflict_action to `DO NOTHING`.
+// Supported only by SQLite and PostgreSQL.
+func (u *WhatsappUpsertOne) DoNothing() *WhatsappUpsertOne {
+	u.create.conflict = append(u.create.conflict, sql.DoNothing())
+	return u
+}
+
+// Update allows overriding fields `UPDATE` values. See the WhatsappCreate.OnConflict
+// documentation for more info.
+func (u *WhatsappUpsertOne) Update(set func(*WhatsappUpsert)) *WhatsappUpsertOne {
+	u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(update *sql.UpdateSet) {
+		set(&WhatsappUpsert{UpdateSet: update})
+	}))
+	return u
+}
+
+// SetUpdatedAt sets the "updated_at" field.
+func (u *WhatsappUpsertOne) SetUpdatedAt(v time.Time) *WhatsappUpsertOne {
+	return u.Update(func(s *WhatsappUpsert) {
+		s.SetUpdatedAt(v)
+	})
+}
+
+// UpdateUpdatedAt sets the "updated_at" field to the value that was provided on create.
+func (u *WhatsappUpsertOne) UpdateUpdatedAt() *WhatsappUpsertOne {
+	return u.Update(func(s *WhatsappUpsert) {
+		s.UpdateUpdatedAt()
+	})
+}
+
+// SetStatus sets the "status" field.
+func (u *WhatsappUpsertOne) SetStatus(v uint8) *WhatsappUpsertOne {
+	return u.Update(func(s *WhatsappUpsert) {
+		s.SetStatus(v)
+	})
+}
+
+// AddStatus adds v to the "status" field.
+func (u *WhatsappUpsertOne) AddStatus(v uint8) *WhatsappUpsertOne {
+	return u.Update(func(s *WhatsappUpsert) {
+		s.AddStatus(v)
+	})
+}
+
+// UpdateStatus sets the "status" field to the value that was provided on create.
+func (u *WhatsappUpsertOne) UpdateStatus() *WhatsappUpsertOne {
+	return u.Update(func(s *WhatsappUpsert) {
+		s.UpdateStatus()
+	})
+}
+
+// ClearStatus clears the value of the "status" field.
+func (u *WhatsappUpsertOne) ClearStatus() *WhatsappUpsertOne {
+	return u.Update(func(s *WhatsappUpsert) {
+		s.ClearStatus()
+	})
+}
+
+// SetDeletedAt sets the "deleted_at" field.
+func (u *WhatsappUpsertOne) SetDeletedAt(v time.Time) *WhatsappUpsertOne {
+	return u.Update(func(s *WhatsappUpsert) {
+		s.SetDeletedAt(v)
+	})
+}
+
+// UpdateDeletedAt sets the "deleted_at" field to the value that was provided on create.
+func (u *WhatsappUpsertOne) UpdateDeletedAt() *WhatsappUpsertOne {
+	return u.Update(func(s *WhatsappUpsert) {
+		s.UpdateDeletedAt()
+	})
+}
+
+// ClearDeletedAt clears the value of the "deleted_at" field.
+func (u *WhatsappUpsertOne) ClearDeletedAt() *WhatsappUpsertOne {
+	return u.Update(func(s *WhatsappUpsert) {
+		s.ClearDeletedAt()
+	})
+}
+
+// SetAk sets the "ak" field.
+func (u *WhatsappUpsertOne) SetAk(v string) *WhatsappUpsertOne {
+	return u.Update(func(s *WhatsappUpsert) {
+		s.SetAk(v)
+	})
+}
+
+// UpdateAk sets the "ak" field to the value that was provided on create.
+func (u *WhatsappUpsertOne) UpdateAk() *WhatsappUpsertOne {
+	return u.Update(func(s *WhatsappUpsert) {
+		s.UpdateAk()
+	})
+}
+
+// ClearAk clears the value of the "ak" field.
+func (u *WhatsappUpsertOne) ClearAk() *WhatsappUpsertOne {
+	return u.Update(func(s *WhatsappUpsert) {
+		s.ClearAk()
+	})
+}
+
+// SetSk sets the "sk" field.
+func (u *WhatsappUpsertOne) SetSk(v string) *WhatsappUpsertOne {
+	return u.Update(func(s *WhatsappUpsert) {
+		s.SetSk(v)
+	})
+}
+
+// UpdateSk sets the "sk" field to the value that was provided on create.
+func (u *WhatsappUpsertOne) UpdateSk() *WhatsappUpsertOne {
+	return u.Update(func(s *WhatsappUpsert) {
+		s.UpdateSk()
+	})
+}
+
+// SetCallback sets the "callback" field.
+func (u *WhatsappUpsertOne) SetCallback(v string) *WhatsappUpsertOne {
+	return u.Update(func(s *WhatsappUpsert) {
+		s.SetCallback(v)
+	})
+}
+
+// UpdateCallback sets the "callback" field to the value that was provided on create.
+func (u *WhatsappUpsertOne) UpdateCallback() *WhatsappUpsertOne {
+	return u.Update(func(s *WhatsappUpsert) {
+		s.UpdateCallback()
+	})
+}
+
+// SetAccount sets the "account" field.
+func (u *WhatsappUpsertOne) SetAccount(v string) *WhatsappUpsertOne {
+	return u.Update(func(s *WhatsappUpsert) {
+		s.SetAccount(v)
+	})
+}
+
+// UpdateAccount sets the "account" field to the value that was provided on create.
+func (u *WhatsappUpsertOne) UpdateAccount() *WhatsappUpsertOne {
+	return u.Update(func(s *WhatsappUpsert) {
+		s.UpdateAccount()
+	})
+}
+
+// SetNickname sets the "nickname" field.
+func (u *WhatsappUpsertOne) SetNickname(v string) *WhatsappUpsertOne {
+	return u.Update(func(s *WhatsappUpsert) {
+		s.SetNickname(v)
+	})
+}
+
+// UpdateNickname sets the "nickname" field to the value that was provided on create.
+func (u *WhatsappUpsertOne) UpdateNickname() *WhatsappUpsertOne {
+	return u.Update(func(s *WhatsappUpsert) {
+		s.UpdateNickname()
+	})
+}
+
+// SetPhone sets the "phone" field.
+func (u *WhatsappUpsertOne) SetPhone(v string) *WhatsappUpsertOne {
+	return u.Update(func(s *WhatsappUpsert) {
+		s.SetPhone(v)
+	})
+}
+
+// UpdatePhone sets the "phone" field to the value that was provided on create.
+func (u *WhatsappUpsertOne) UpdatePhone() *WhatsappUpsertOne {
+	return u.Update(func(s *WhatsappUpsert) {
+		s.UpdatePhone()
+	})
+}
+
+// SetOrganizationID sets the "organization_id" field.
+func (u *WhatsappUpsertOne) SetOrganizationID(v uint64) *WhatsappUpsertOne {
+	return u.Update(func(s *WhatsappUpsert) {
+		s.SetOrganizationID(v)
+	})
+}
+
+// AddOrganizationID adds v to the "organization_id" field.
+func (u *WhatsappUpsertOne) AddOrganizationID(v uint64) *WhatsappUpsertOne {
+	return u.Update(func(s *WhatsappUpsert) {
+		s.AddOrganizationID(v)
+	})
+}
+
+// UpdateOrganizationID sets the "organization_id" field to the value that was provided on create.
+func (u *WhatsappUpsertOne) UpdateOrganizationID() *WhatsappUpsertOne {
+	return u.Update(func(s *WhatsappUpsert) {
+		s.UpdateOrganizationID()
+	})
+}
+
+// ClearOrganizationID clears the value of the "organization_id" field.
+func (u *WhatsappUpsertOne) ClearOrganizationID() *WhatsappUpsertOne {
+	return u.Update(func(s *WhatsappUpsert) {
+		s.ClearOrganizationID()
+	})
+}
+
+// SetAgentID sets the "agent_id" field.
+func (u *WhatsappUpsertOne) SetAgentID(v uint64) *WhatsappUpsertOne {
+	return u.Update(func(s *WhatsappUpsert) {
+		s.SetAgentID(v)
+	})
+}
+
+// AddAgentID adds v to the "agent_id" field.
+func (u *WhatsappUpsertOne) AddAgentID(v uint64) *WhatsappUpsertOne {
+	return u.Update(func(s *WhatsappUpsert) {
+		s.AddAgentID(v)
+	})
+}
+
+// UpdateAgentID sets the "agent_id" field to the value that was provided on create.
+func (u *WhatsappUpsertOne) UpdateAgentID() *WhatsappUpsertOne {
+	return u.Update(func(s *WhatsappUpsert) {
+		s.UpdateAgentID()
+	})
+}
+
+// SetAPIBase sets the "api_base" field.
+func (u *WhatsappUpsertOne) SetAPIBase(v string) *WhatsappUpsertOne {
+	return u.Update(func(s *WhatsappUpsert) {
+		s.SetAPIBase(v)
+	})
+}
+
+// UpdateAPIBase sets the "api_base" field to the value that was provided on create.
+func (u *WhatsappUpsertOne) UpdateAPIBase() *WhatsappUpsertOne {
+	return u.Update(func(s *WhatsappUpsert) {
+		s.UpdateAPIBase()
+	})
+}
+
+// ClearAPIBase clears the value of the "api_base" field.
+func (u *WhatsappUpsertOne) ClearAPIBase() *WhatsappUpsertOne {
+	return u.Update(func(s *WhatsappUpsert) {
+		s.ClearAPIBase()
+	})
+}
+
+// SetAPIKey sets the "api_key" field.
+func (u *WhatsappUpsertOne) SetAPIKey(v string) *WhatsappUpsertOne {
+	return u.Update(func(s *WhatsappUpsert) {
+		s.SetAPIKey(v)
+	})
+}
+
+// UpdateAPIKey sets the "api_key" field to the value that was provided on create.
+func (u *WhatsappUpsertOne) UpdateAPIKey() *WhatsappUpsertOne {
+	return u.Update(func(s *WhatsappUpsert) {
+		s.UpdateAPIKey()
+	})
+}
+
+// ClearAPIKey clears the value of the "api_key" field.
+func (u *WhatsappUpsertOne) ClearAPIKey() *WhatsappUpsertOne {
+	return u.Update(func(s *WhatsappUpsert) {
+		s.ClearAPIKey()
+	})
+}
+
+// SetAllowList sets the "allow_list" field.
+func (u *WhatsappUpsertOne) SetAllowList(v []string) *WhatsappUpsertOne {
+	return u.Update(func(s *WhatsappUpsert) {
+		s.SetAllowList(v)
+	})
+}
+
+// UpdateAllowList sets the "allow_list" field to the value that was provided on create.
+func (u *WhatsappUpsertOne) UpdateAllowList() *WhatsappUpsertOne {
+	return u.Update(func(s *WhatsappUpsert) {
+		s.UpdateAllowList()
+	})
+}
+
+// SetGroupAllowList sets the "group_allow_list" field.
+func (u *WhatsappUpsertOne) SetGroupAllowList(v []string) *WhatsappUpsertOne {
+	return u.Update(func(s *WhatsappUpsert) {
+		s.SetGroupAllowList(v)
+	})
+}
+
+// UpdateGroupAllowList sets the "group_allow_list" field to the value that was provided on create.
+func (u *WhatsappUpsertOne) UpdateGroupAllowList() *WhatsappUpsertOne {
+	return u.Update(func(s *WhatsappUpsert) {
+		s.UpdateGroupAllowList()
+	})
+}
+
+// SetBlockList sets the "block_list" field.
+func (u *WhatsappUpsertOne) SetBlockList(v []string) *WhatsappUpsertOne {
+	return u.Update(func(s *WhatsappUpsert) {
+		s.SetBlockList(v)
+	})
+}
+
+// UpdateBlockList sets the "block_list" field to the value that was provided on create.
+func (u *WhatsappUpsertOne) UpdateBlockList() *WhatsappUpsertOne {
+	return u.Update(func(s *WhatsappUpsert) {
+		s.UpdateBlockList()
+	})
+}
+
+// SetGroupBlockList sets the "group_block_list" field.
+func (u *WhatsappUpsertOne) SetGroupBlockList(v []string) *WhatsappUpsertOne {
+	return u.Update(func(s *WhatsappUpsert) {
+		s.SetGroupBlockList(v)
+	})
+}
+
+// UpdateGroupBlockList sets the "group_block_list" field to the value that was provided on create.
+func (u *WhatsappUpsertOne) UpdateGroupBlockList() *WhatsappUpsertOne {
+	return u.Update(func(s *WhatsappUpsert) {
+		s.UpdateGroupBlockList()
+	})
+}
+
+// Exec executes the query.
+func (u *WhatsappUpsertOne) Exec(ctx context.Context) error {
+	if len(u.create.conflict) == 0 {
+		return errors.New("ent: missing options for WhatsappCreate.OnConflict")
+	}
+	return u.create.Exec(ctx)
+}
+
+// ExecX is like Exec, but panics if an error occurs.
+func (u *WhatsappUpsertOne) ExecX(ctx context.Context) {
+	if err := u.create.Exec(ctx); err != nil {
+		panic(err)
+	}
+}
+
+// Exec executes the UPSERT query and returns the inserted/updated ID.
+func (u *WhatsappUpsertOne) ID(ctx context.Context) (id uint64, err error) {
+	node, err := u.create.Save(ctx)
+	if err != nil {
+		return id, err
+	}
+	return node.ID, nil
+}
+
+// IDX is like ID, but panics if an error occurs.
+func (u *WhatsappUpsertOne) IDX(ctx context.Context) uint64 {
+	id, err := u.ID(ctx)
+	if err != nil {
+		panic(err)
+	}
+	return id
+}
+
+// WhatsappCreateBulk is the builder for creating many Whatsapp entities in bulk.
+type WhatsappCreateBulk struct {
+	config
+	err      error
+	builders []*WhatsappCreate
+	conflict []sql.ConflictOption
+}
+
+// Save creates the Whatsapp entities in the database.
+func (wcb *WhatsappCreateBulk) Save(ctx context.Context) ([]*Whatsapp, error) {
+	if wcb.err != nil {
+		return nil, wcb.err
+	}
+	specs := make([]*sqlgraph.CreateSpec, len(wcb.builders))
+	nodes := make([]*Whatsapp, len(wcb.builders))
+	mutators := make([]Mutator, len(wcb.builders))
+	for i := range wcb.builders {
+		func(i int, root context.Context) {
+			builder := wcb.builders[i]
+			builder.defaults()
+			var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {
+				mutation, ok := m.(*WhatsappMutation)
+				if !ok {
+					return nil, fmt.Errorf("unexpected mutation type %T", m)
+				}
+				if err := builder.check(); err != nil {
+					return nil, err
+				}
+				builder.mutation = mutation
+				var err error
+				nodes[i], specs[i] = builder.createSpec()
+				if i < len(mutators)-1 {
+					_, err = mutators[i+1].Mutate(root, wcb.builders[i+1].mutation)
+				} else {
+					spec := &sqlgraph.BatchCreateSpec{Nodes: specs}
+					spec.OnConflict = wcb.conflict
+					// Invoke the actual operation on the latest mutation in the chain.
+					if err = sqlgraph.BatchCreate(ctx, wcb.driver, spec); err != nil {
+						if sqlgraph.IsConstraintError(err) {
+							err = &ConstraintError{msg: err.Error(), wrap: err}
+						}
+					}
+				}
+				if err != nil {
+					return nil, err
+				}
+				mutation.id = &nodes[i].ID
+				if specs[i].ID.Value != nil && nodes[i].ID == 0 {
+					id := specs[i].ID.Value.(int64)
+					nodes[i].ID = uint64(id)
+				}
+				mutation.done = true
+				return nodes[i], nil
+			})
+			for i := len(builder.hooks) - 1; i >= 0; i-- {
+				mut = builder.hooks[i](mut)
+			}
+			mutators[i] = mut
+		}(i, ctx)
+	}
+	if len(mutators) > 0 {
+		if _, err := mutators[0].Mutate(ctx, wcb.builders[0].mutation); err != nil {
+			return nil, err
+		}
+	}
+	return nodes, nil
+}
+
+// SaveX is like Save, but panics if an error occurs.
+func (wcb *WhatsappCreateBulk) SaveX(ctx context.Context) []*Whatsapp {
+	v, err := wcb.Save(ctx)
+	if err != nil {
+		panic(err)
+	}
+	return v
+}
+
+// Exec executes the query.
+func (wcb *WhatsappCreateBulk) Exec(ctx context.Context) error {
+	_, err := wcb.Save(ctx)
+	return err
+}
+
+// ExecX is like Exec, but panics if an error occurs.
+func (wcb *WhatsappCreateBulk) ExecX(ctx context.Context) {
+	if err := wcb.Exec(ctx); err != nil {
+		panic(err)
+	}
+}
+
+// OnConflict allows configuring the `ON CONFLICT` / `ON DUPLICATE KEY` clause
+// of the `INSERT` statement. For example:
+//
+//	client.Whatsapp.CreateBulk(builders...).
+//		OnConflict(
+//			// Update the row with the new values
+//			// the was proposed for insertion.
+//			sql.ResolveWithNewValues(),
+//		).
+//		// Override some of the fields with custom
+//		// update values.
+//		Update(func(u *ent.WhatsappUpsert) {
+//			SetCreatedAt(v+v).
+//		}).
+//		Exec(ctx)
+func (wcb *WhatsappCreateBulk) OnConflict(opts ...sql.ConflictOption) *WhatsappUpsertBulk {
+	wcb.conflict = opts
+	return &WhatsappUpsertBulk{
+		create: wcb,
+	}
+}
+
+// OnConflictColumns calls `OnConflict` and configures the columns
+// as conflict target. Using this option is equivalent to using:
+//
+//	client.Whatsapp.Create().
+//		OnConflict(sql.ConflictColumns(columns...)).
+//		Exec(ctx)
+func (wcb *WhatsappCreateBulk) OnConflictColumns(columns ...string) *WhatsappUpsertBulk {
+	wcb.conflict = append(wcb.conflict, sql.ConflictColumns(columns...))
+	return &WhatsappUpsertBulk{
+		create: wcb,
+	}
+}
+
+// WhatsappUpsertBulk is the builder for "upsert"-ing
+// a bulk of Whatsapp nodes.
+type WhatsappUpsertBulk struct {
+	create *WhatsappCreateBulk
+}
+
+// UpdateNewValues updates the mutable fields using the new values that
+// were set on create. Using this option is equivalent to using:
+//
+//	client.Whatsapp.Create().
+//		OnConflict(
+//			sql.ResolveWithNewValues(),
+//			sql.ResolveWith(func(u *sql.UpdateSet) {
+//				u.SetIgnore(whatsapp.FieldID)
+//			}),
+//		).
+//		Exec(ctx)
+func (u *WhatsappUpsertBulk) UpdateNewValues() *WhatsappUpsertBulk {
+	u.create.conflict = append(u.create.conflict, sql.ResolveWithNewValues())
+	u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(s *sql.UpdateSet) {
+		for _, b := range u.create.builders {
+			if _, exists := b.mutation.ID(); exists {
+				s.SetIgnore(whatsapp.FieldID)
+			}
+			if _, exists := b.mutation.CreatedAt(); exists {
+				s.SetIgnore(whatsapp.FieldCreatedAt)
+			}
+		}
+	}))
+	return u
+}
+
+// Ignore sets each column to itself in case of conflict.
+// Using this option is equivalent to using:
+//
+//	client.Whatsapp.Create().
+//		OnConflict(sql.ResolveWithIgnore()).
+//		Exec(ctx)
+func (u *WhatsappUpsertBulk) Ignore() *WhatsappUpsertBulk {
+	u.create.conflict = append(u.create.conflict, sql.ResolveWithIgnore())
+	return u
+}
+
+// DoNothing configures the conflict_action to `DO NOTHING`.
+// Supported only by SQLite and PostgreSQL.
+func (u *WhatsappUpsertBulk) DoNothing() *WhatsappUpsertBulk {
+	u.create.conflict = append(u.create.conflict, sql.DoNothing())
+	return u
+}
+
+// Update allows overriding fields `UPDATE` values. See the WhatsappCreateBulk.OnConflict
+// documentation for more info.
+func (u *WhatsappUpsertBulk) Update(set func(*WhatsappUpsert)) *WhatsappUpsertBulk {
+	u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(update *sql.UpdateSet) {
+		set(&WhatsappUpsert{UpdateSet: update})
+	}))
+	return u
+}
+
+// SetUpdatedAt sets the "updated_at" field.
+func (u *WhatsappUpsertBulk) SetUpdatedAt(v time.Time) *WhatsappUpsertBulk {
+	return u.Update(func(s *WhatsappUpsert) {
+		s.SetUpdatedAt(v)
+	})
+}
+
+// UpdateUpdatedAt sets the "updated_at" field to the value that was provided on create.
+func (u *WhatsappUpsertBulk) UpdateUpdatedAt() *WhatsappUpsertBulk {
+	return u.Update(func(s *WhatsappUpsert) {
+		s.UpdateUpdatedAt()
+	})
+}
+
+// SetStatus sets the "status" field.
+func (u *WhatsappUpsertBulk) SetStatus(v uint8) *WhatsappUpsertBulk {
+	return u.Update(func(s *WhatsappUpsert) {
+		s.SetStatus(v)
+	})
+}
+
+// AddStatus adds v to the "status" field.
+func (u *WhatsappUpsertBulk) AddStatus(v uint8) *WhatsappUpsertBulk {
+	return u.Update(func(s *WhatsappUpsert) {
+		s.AddStatus(v)
+	})
+}
+
+// UpdateStatus sets the "status" field to the value that was provided on create.
+func (u *WhatsappUpsertBulk) UpdateStatus() *WhatsappUpsertBulk {
+	return u.Update(func(s *WhatsappUpsert) {
+		s.UpdateStatus()
+	})
+}
+
+// ClearStatus clears the value of the "status" field.
+func (u *WhatsappUpsertBulk) ClearStatus() *WhatsappUpsertBulk {
+	return u.Update(func(s *WhatsappUpsert) {
+		s.ClearStatus()
+	})
+}
+
+// SetDeletedAt sets the "deleted_at" field.
+func (u *WhatsappUpsertBulk) SetDeletedAt(v time.Time) *WhatsappUpsertBulk {
+	return u.Update(func(s *WhatsappUpsert) {
+		s.SetDeletedAt(v)
+	})
+}
+
+// UpdateDeletedAt sets the "deleted_at" field to the value that was provided on create.
+func (u *WhatsappUpsertBulk) UpdateDeletedAt() *WhatsappUpsertBulk {
+	return u.Update(func(s *WhatsappUpsert) {
+		s.UpdateDeletedAt()
+	})
+}
+
+// ClearDeletedAt clears the value of the "deleted_at" field.
+func (u *WhatsappUpsertBulk) ClearDeletedAt() *WhatsappUpsertBulk {
+	return u.Update(func(s *WhatsappUpsert) {
+		s.ClearDeletedAt()
+	})
+}
+
+// SetAk sets the "ak" field.
+func (u *WhatsappUpsertBulk) SetAk(v string) *WhatsappUpsertBulk {
+	return u.Update(func(s *WhatsappUpsert) {
+		s.SetAk(v)
+	})
+}
+
+// UpdateAk sets the "ak" field to the value that was provided on create.
+func (u *WhatsappUpsertBulk) UpdateAk() *WhatsappUpsertBulk {
+	return u.Update(func(s *WhatsappUpsert) {
+		s.UpdateAk()
+	})
+}
+
+// ClearAk clears the value of the "ak" field.
+func (u *WhatsappUpsertBulk) ClearAk() *WhatsappUpsertBulk {
+	return u.Update(func(s *WhatsappUpsert) {
+		s.ClearAk()
+	})
+}
+
+// SetSk sets the "sk" field.
+func (u *WhatsappUpsertBulk) SetSk(v string) *WhatsappUpsertBulk {
+	return u.Update(func(s *WhatsappUpsert) {
+		s.SetSk(v)
+	})
+}
+
+// UpdateSk sets the "sk" field to the value that was provided on create.
+func (u *WhatsappUpsertBulk) UpdateSk() *WhatsappUpsertBulk {
+	return u.Update(func(s *WhatsappUpsert) {
+		s.UpdateSk()
+	})
+}
+
+// SetCallback sets the "callback" field.
+func (u *WhatsappUpsertBulk) SetCallback(v string) *WhatsappUpsertBulk {
+	return u.Update(func(s *WhatsappUpsert) {
+		s.SetCallback(v)
+	})
+}
+
+// UpdateCallback sets the "callback" field to the value that was provided on create.
+func (u *WhatsappUpsertBulk) UpdateCallback() *WhatsappUpsertBulk {
+	return u.Update(func(s *WhatsappUpsert) {
+		s.UpdateCallback()
+	})
+}
+
+// SetAccount sets the "account" field.
+func (u *WhatsappUpsertBulk) SetAccount(v string) *WhatsappUpsertBulk {
+	return u.Update(func(s *WhatsappUpsert) {
+		s.SetAccount(v)
+	})
+}
+
+// UpdateAccount sets the "account" field to the value that was provided on create.
+func (u *WhatsappUpsertBulk) UpdateAccount() *WhatsappUpsertBulk {
+	return u.Update(func(s *WhatsappUpsert) {
+		s.UpdateAccount()
+	})
+}
+
+// SetNickname sets the "nickname" field.
+func (u *WhatsappUpsertBulk) SetNickname(v string) *WhatsappUpsertBulk {
+	return u.Update(func(s *WhatsappUpsert) {
+		s.SetNickname(v)
+	})
+}
+
+// UpdateNickname sets the "nickname" field to the value that was provided on create.
+func (u *WhatsappUpsertBulk) UpdateNickname() *WhatsappUpsertBulk {
+	return u.Update(func(s *WhatsappUpsert) {
+		s.UpdateNickname()
+	})
+}
+
+// SetPhone sets the "phone" field.
+func (u *WhatsappUpsertBulk) SetPhone(v string) *WhatsappUpsertBulk {
+	return u.Update(func(s *WhatsappUpsert) {
+		s.SetPhone(v)
+	})
+}
+
+// UpdatePhone sets the "phone" field to the value that was provided on create.
+func (u *WhatsappUpsertBulk) UpdatePhone() *WhatsappUpsertBulk {
+	return u.Update(func(s *WhatsappUpsert) {
+		s.UpdatePhone()
+	})
+}
+
+// SetOrganizationID sets the "organization_id" field.
+func (u *WhatsappUpsertBulk) SetOrganizationID(v uint64) *WhatsappUpsertBulk {
+	return u.Update(func(s *WhatsappUpsert) {
+		s.SetOrganizationID(v)
+	})
+}
+
+// AddOrganizationID adds v to the "organization_id" field.
+func (u *WhatsappUpsertBulk) AddOrganizationID(v uint64) *WhatsappUpsertBulk {
+	return u.Update(func(s *WhatsappUpsert) {
+		s.AddOrganizationID(v)
+	})
+}
+
+// UpdateOrganizationID sets the "organization_id" field to the value that was provided on create.
+func (u *WhatsappUpsertBulk) UpdateOrganizationID() *WhatsappUpsertBulk {
+	return u.Update(func(s *WhatsappUpsert) {
+		s.UpdateOrganizationID()
+	})
+}
+
+// ClearOrganizationID clears the value of the "organization_id" field.
+func (u *WhatsappUpsertBulk) ClearOrganizationID() *WhatsappUpsertBulk {
+	return u.Update(func(s *WhatsappUpsert) {
+		s.ClearOrganizationID()
+	})
+}
+
+// SetAgentID sets the "agent_id" field.
+func (u *WhatsappUpsertBulk) SetAgentID(v uint64) *WhatsappUpsertBulk {
+	return u.Update(func(s *WhatsappUpsert) {
+		s.SetAgentID(v)
+	})
+}
+
+// AddAgentID adds v to the "agent_id" field.
+func (u *WhatsappUpsertBulk) AddAgentID(v uint64) *WhatsappUpsertBulk {
+	return u.Update(func(s *WhatsappUpsert) {
+		s.AddAgentID(v)
+	})
+}
+
+// UpdateAgentID sets the "agent_id" field to the value that was provided on create.
+func (u *WhatsappUpsertBulk) UpdateAgentID() *WhatsappUpsertBulk {
+	return u.Update(func(s *WhatsappUpsert) {
+		s.UpdateAgentID()
+	})
+}
+
+// SetAPIBase sets the "api_base" field.
+func (u *WhatsappUpsertBulk) SetAPIBase(v string) *WhatsappUpsertBulk {
+	return u.Update(func(s *WhatsappUpsert) {
+		s.SetAPIBase(v)
+	})
+}
+
+// UpdateAPIBase sets the "api_base" field to the value that was provided on create.
+func (u *WhatsappUpsertBulk) UpdateAPIBase() *WhatsappUpsertBulk {
+	return u.Update(func(s *WhatsappUpsert) {
+		s.UpdateAPIBase()
+	})
+}
+
+// ClearAPIBase clears the value of the "api_base" field.
+func (u *WhatsappUpsertBulk) ClearAPIBase() *WhatsappUpsertBulk {
+	return u.Update(func(s *WhatsappUpsert) {
+		s.ClearAPIBase()
+	})
+}
+
+// SetAPIKey sets the "api_key" field.
+func (u *WhatsappUpsertBulk) SetAPIKey(v string) *WhatsappUpsertBulk {
+	return u.Update(func(s *WhatsappUpsert) {
+		s.SetAPIKey(v)
+	})
+}
+
+// UpdateAPIKey sets the "api_key" field to the value that was provided on create.
+func (u *WhatsappUpsertBulk) UpdateAPIKey() *WhatsappUpsertBulk {
+	return u.Update(func(s *WhatsappUpsert) {
+		s.UpdateAPIKey()
+	})
+}
+
+// ClearAPIKey clears the value of the "api_key" field.
+func (u *WhatsappUpsertBulk) ClearAPIKey() *WhatsappUpsertBulk {
+	return u.Update(func(s *WhatsappUpsert) {
+		s.ClearAPIKey()
+	})
+}
+
+// SetAllowList sets the "allow_list" field.
+func (u *WhatsappUpsertBulk) SetAllowList(v []string) *WhatsappUpsertBulk {
+	return u.Update(func(s *WhatsappUpsert) {
+		s.SetAllowList(v)
+	})
+}
+
+// UpdateAllowList sets the "allow_list" field to the value that was provided on create.
+func (u *WhatsappUpsertBulk) UpdateAllowList() *WhatsappUpsertBulk {
+	return u.Update(func(s *WhatsappUpsert) {
+		s.UpdateAllowList()
+	})
+}
+
+// SetGroupAllowList sets the "group_allow_list" field.
+func (u *WhatsappUpsertBulk) SetGroupAllowList(v []string) *WhatsappUpsertBulk {
+	return u.Update(func(s *WhatsappUpsert) {
+		s.SetGroupAllowList(v)
+	})
+}
+
+// UpdateGroupAllowList sets the "group_allow_list" field to the value that was provided on create.
+func (u *WhatsappUpsertBulk) UpdateGroupAllowList() *WhatsappUpsertBulk {
+	return u.Update(func(s *WhatsappUpsert) {
+		s.UpdateGroupAllowList()
+	})
+}
+
+// SetBlockList sets the "block_list" field.
+func (u *WhatsappUpsertBulk) SetBlockList(v []string) *WhatsappUpsertBulk {
+	return u.Update(func(s *WhatsappUpsert) {
+		s.SetBlockList(v)
+	})
+}
+
+// UpdateBlockList sets the "block_list" field to the value that was provided on create.
+func (u *WhatsappUpsertBulk) UpdateBlockList() *WhatsappUpsertBulk {
+	return u.Update(func(s *WhatsappUpsert) {
+		s.UpdateBlockList()
+	})
+}
+
+// SetGroupBlockList sets the "group_block_list" field.
+func (u *WhatsappUpsertBulk) SetGroupBlockList(v []string) *WhatsappUpsertBulk {
+	return u.Update(func(s *WhatsappUpsert) {
+		s.SetGroupBlockList(v)
+	})
+}
+
+// UpdateGroupBlockList sets the "group_block_list" field to the value that was provided on create.
+func (u *WhatsappUpsertBulk) UpdateGroupBlockList() *WhatsappUpsertBulk {
+	return u.Update(func(s *WhatsappUpsert) {
+		s.UpdateGroupBlockList()
+	})
+}
+
+// Exec executes the query.
+func (u *WhatsappUpsertBulk) Exec(ctx context.Context) error {
+	if u.create.err != nil {
+		return u.create.err
+	}
+	for i, b := range u.create.builders {
+		if len(b.conflict) != 0 {
+			return fmt.Errorf("ent: OnConflict was set for builder %d. Set it on the WhatsappCreateBulk instead", i)
+		}
+	}
+	if len(u.create.conflict) == 0 {
+		return errors.New("ent: missing options for WhatsappCreateBulk.OnConflict")
+	}
+	return u.create.Exec(ctx)
+}
+
+// ExecX is like Exec, but panics if an error occurs.
+func (u *WhatsappUpsertBulk) ExecX(ctx context.Context) {
+	if err := u.create.Exec(ctx); err != nil {
+		panic(err)
+	}
+}

+ 88 - 0
ent/whatsapp_delete.go

@@ -0,0 +1,88 @@
+// Code generated by ent, DO NOT EDIT.
+
+package ent
+
+import (
+	"context"
+	"wechat-api/ent/predicate"
+	"wechat-api/ent/whatsapp"
+
+	"entgo.io/ent/dialect/sql"
+	"entgo.io/ent/dialect/sql/sqlgraph"
+	"entgo.io/ent/schema/field"
+)
+
+// WhatsappDelete is the builder for deleting a Whatsapp entity.
+type WhatsappDelete struct {
+	config
+	hooks    []Hook
+	mutation *WhatsappMutation
+}
+
+// Where appends a list predicates to the WhatsappDelete builder.
+func (wd *WhatsappDelete) Where(ps ...predicate.Whatsapp) *WhatsappDelete {
+	wd.mutation.Where(ps...)
+	return wd
+}
+
+// Exec executes the deletion query and returns how many vertices were deleted.
+func (wd *WhatsappDelete) Exec(ctx context.Context) (int, error) {
+	return withHooks(ctx, wd.sqlExec, wd.mutation, wd.hooks)
+}
+
+// ExecX is like Exec, but panics if an error occurs.
+func (wd *WhatsappDelete) ExecX(ctx context.Context) int {
+	n, err := wd.Exec(ctx)
+	if err != nil {
+		panic(err)
+	}
+	return n
+}
+
+func (wd *WhatsappDelete) sqlExec(ctx context.Context) (int, error) {
+	_spec := sqlgraph.NewDeleteSpec(whatsapp.Table, sqlgraph.NewFieldSpec(whatsapp.FieldID, field.TypeUint64))
+	if ps := wd.mutation.predicates; len(ps) > 0 {
+		_spec.Predicate = func(selector *sql.Selector) {
+			for i := range ps {
+				ps[i](selector)
+			}
+		}
+	}
+	affected, err := sqlgraph.DeleteNodes(ctx, wd.driver, _spec)
+	if err != nil && sqlgraph.IsConstraintError(err) {
+		err = &ConstraintError{msg: err.Error(), wrap: err}
+	}
+	wd.mutation.done = true
+	return affected, err
+}
+
+// WhatsappDeleteOne is the builder for deleting a single Whatsapp entity.
+type WhatsappDeleteOne struct {
+	wd *WhatsappDelete
+}
+
+// Where appends a list predicates to the WhatsappDelete builder.
+func (wdo *WhatsappDeleteOne) Where(ps ...predicate.Whatsapp) *WhatsappDeleteOne {
+	wdo.wd.mutation.Where(ps...)
+	return wdo
+}
+
+// Exec executes the deletion query.
+func (wdo *WhatsappDeleteOne) Exec(ctx context.Context) error {
+	n, err := wdo.wd.Exec(ctx)
+	switch {
+	case err != nil:
+		return err
+	case n == 0:
+		return &NotFoundError{whatsapp.Label}
+	default:
+		return nil
+	}
+}
+
+// ExecX is like Exec, but panics if an error occurs.
+func (wdo *WhatsappDeleteOne) ExecX(ctx context.Context) {
+	if err := wdo.Exec(ctx); err != nil {
+		panic(err)
+	}
+}

+ 526 - 0
ent/whatsapp_query.go

@@ -0,0 +1,526 @@
+// Code generated by ent, DO NOT EDIT.
+
+package ent
+
+import (
+	"context"
+	"fmt"
+	"math"
+	"wechat-api/ent/predicate"
+	"wechat-api/ent/whatsapp"
+
+	"entgo.io/ent/dialect/sql"
+	"entgo.io/ent/dialect/sql/sqlgraph"
+	"entgo.io/ent/schema/field"
+)
+
+// WhatsappQuery is the builder for querying Whatsapp entities.
+type WhatsappQuery struct {
+	config
+	ctx        *QueryContext
+	order      []whatsapp.OrderOption
+	inters     []Interceptor
+	predicates []predicate.Whatsapp
+	// intermediate query (i.e. traversal path).
+	sql  *sql.Selector
+	path func(context.Context) (*sql.Selector, error)
+}
+
+// Where adds a new predicate for the WhatsappQuery builder.
+func (wq *WhatsappQuery) Where(ps ...predicate.Whatsapp) *WhatsappQuery {
+	wq.predicates = append(wq.predicates, ps...)
+	return wq
+}
+
+// Limit the number of records to be returned by this query.
+func (wq *WhatsappQuery) Limit(limit int) *WhatsappQuery {
+	wq.ctx.Limit = &limit
+	return wq
+}
+
+// Offset to start from.
+func (wq *WhatsappQuery) Offset(offset int) *WhatsappQuery {
+	wq.ctx.Offset = &offset
+	return wq
+}
+
+// Unique configures the query builder to filter duplicate records on query.
+// By default, unique is set to true, and can be disabled using this method.
+func (wq *WhatsappQuery) Unique(unique bool) *WhatsappQuery {
+	wq.ctx.Unique = &unique
+	return wq
+}
+
+// Order specifies how the records should be ordered.
+func (wq *WhatsappQuery) Order(o ...whatsapp.OrderOption) *WhatsappQuery {
+	wq.order = append(wq.order, o...)
+	return wq
+}
+
+// First returns the first Whatsapp entity from the query.
+// Returns a *NotFoundError when no Whatsapp was found.
+func (wq *WhatsappQuery) First(ctx context.Context) (*Whatsapp, error) {
+	nodes, err := wq.Limit(1).All(setContextOp(ctx, wq.ctx, "First"))
+	if err != nil {
+		return nil, err
+	}
+	if len(nodes) == 0 {
+		return nil, &NotFoundError{whatsapp.Label}
+	}
+	return nodes[0], nil
+}
+
+// FirstX is like First, but panics if an error occurs.
+func (wq *WhatsappQuery) FirstX(ctx context.Context) *Whatsapp {
+	node, err := wq.First(ctx)
+	if err != nil && !IsNotFound(err) {
+		panic(err)
+	}
+	return node
+}
+
+// FirstID returns the first Whatsapp ID from the query.
+// Returns a *NotFoundError when no Whatsapp ID was found.
+func (wq *WhatsappQuery) FirstID(ctx context.Context) (id uint64, err error) {
+	var ids []uint64
+	if ids, err = wq.Limit(1).IDs(setContextOp(ctx, wq.ctx, "FirstID")); err != nil {
+		return
+	}
+	if len(ids) == 0 {
+		err = &NotFoundError{whatsapp.Label}
+		return
+	}
+	return ids[0], nil
+}
+
+// FirstIDX is like FirstID, but panics if an error occurs.
+func (wq *WhatsappQuery) FirstIDX(ctx context.Context) uint64 {
+	id, err := wq.FirstID(ctx)
+	if err != nil && !IsNotFound(err) {
+		panic(err)
+	}
+	return id
+}
+
+// Only returns a single Whatsapp entity found by the query, ensuring it only returns one.
+// Returns a *NotSingularError when more than one Whatsapp entity is found.
+// Returns a *NotFoundError when no Whatsapp entities are found.
+func (wq *WhatsappQuery) Only(ctx context.Context) (*Whatsapp, error) {
+	nodes, err := wq.Limit(2).All(setContextOp(ctx, wq.ctx, "Only"))
+	if err != nil {
+		return nil, err
+	}
+	switch len(nodes) {
+	case 1:
+		return nodes[0], nil
+	case 0:
+		return nil, &NotFoundError{whatsapp.Label}
+	default:
+		return nil, &NotSingularError{whatsapp.Label}
+	}
+}
+
+// OnlyX is like Only, but panics if an error occurs.
+func (wq *WhatsappQuery) OnlyX(ctx context.Context) *Whatsapp {
+	node, err := wq.Only(ctx)
+	if err != nil {
+		panic(err)
+	}
+	return node
+}
+
+// OnlyID is like Only, but returns the only Whatsapp ID in the query.
+// Returns a *NotSingularError when more than one Whatsapp ID is found.
+// Returns a *NotFoundError when no entities are found.
+func (wq *WhatsappQuery) OnlyID(ctx context.Context) (id uint64, err error) {
+	var ids []uint64
+	if ids, err = wq.Limit(2).IDs(setContextOp(ctx, wq.ctx, "OnlyID")); err != nil {
+		return
+	}
+	switch len(ids) {
+	case 1:
+		id = ids[0]
+	case 0:
+		err = &NotFoundError{whatsapp.Label}
+	default:
+		err = &NotSingularError{whatsapp.Label}
+	}
+	return
+}
+
+// OnlyIDX is like OnlyID, but panics if an error occurs.
+func (wq *WhatsappQuery) OnlyIDX(ctx context.Context) uint64 {
+	id, err := wq.OnlyID(ctx)
+	if err != nil {
+		panic(err)
+	}
+	return id
+}
+
+// All executes the query and returns a list of Whatsapps.
+func (wq *WhatsappQuery) All(ctx context.Context) ([]*Whatsapp, error) {
+	ctx = setContextOp(ctx, wq.ctx, "All")
+	if err := wq.prepareQuery(ctx); err != nil {
+		return nil, err
+	}
+	qr := querierAll[[]*Whatsapp, *WhatsappQuery]()
+	return withInterceptors[[]*Whatsapp](ctx, wq, qr, wq.inters)
+}
+
+// AllX is like All, but panics if an error occurs.
+func (wq *WhatsappQuery) AllX(ctx context.Context) []*Whatsapp {
+	nodes, err := wq.All(ctx)
+	if err != nil {
+		panic(err)
+	}
+	return nodes
+}
+
+// IDs executes the query and returns a list of Whatsapp IDs.
+func (wq *WhatsappQuery) IDs(ctx context.Context) (ids []uint64, err error) {
+	if wq.ctx.Unique == nil && wq.path != nil {
+		wq.Unique(true)
+	}
+	ctx = setContextOp(ctx, wq.ctx, "IDs")
+	if err = wq.Select(whatsapp.FieldID).Scan(ctx, &ids); err != nil {
+		return nil, err
+	}
+	return ids, nil
+}
+
+// IDsX is like IDs, but panics if an error occurs.
+func (wq *WhatsappQuery) IDsX(ctx context.Context) []uint64 {
+	ids, err := wq.IDs(ctx)
+	if err != nil {
+		panic(err)
+	}
+	return ids
+}
+
+// Count returns the count of the given query.
+func (wq *WhatsappQuery) Count(ctx context.Context) (int, error) {
+	ctx = setContextOp(ctx, wq.ctx, "Count")
+	if err := wq.prepareQuery(ctx); err != nil {
+		return 0, err
+	}
+	return withInterceptors[int](ctx, wq, querierCount[*WhatsappQuery](), wq.inters)
+}
+
+// CountX is like Count, but panics if an error occurs.
+func (wq *WhatsappQuery) CountX(ctx context.Context) int {
+	count, err := wq.Count(ctx)
+	if err != nil {
+		panic(err)
+	}
+	return count
+}
+
+// Exist returns true if the query has elements in the graph.
+func (wq *WhatsappQuery) Exist(ctx context.Context) (bool, error) {
+	ctx = setContextOp(ctx, wq.ctx, "Exist")
+	switch _, err := wq.FirstID(ctx); {
+	case IsNotFound(err):
+		return false, nil
+	case err != nil:
+		return false, fmt.Errorf("ent: check existence: %w", err)
+	default:
+		return true, nil
+	}
+}
+
+// ExistX is like Exist, but panics if an error occurs.
+func (wq *WhatsappQuery) ExistX(ctx context.Context) bool {
+	exist, err := wq.Exist(ctx)
+	if err != nil {
+		panic(err)
+	}
+	return exist
+}
+
+// Clone returns a duplicate of the WhatsappQuery builder, including all associated steps. It can be
+// used to prepare common query builders and use them differently after the clone is made.
+func (wq *WhatsappQuery) Clone() *WhatsappQuery {
+	if wq == nil {
+		return nil
+	}
+	return &WhatsappQuery{
+		config:     wq.config,
+		ctx:        wq.ctx.Clone(),
+		order:      append([]whatsapp.OrderOption{}, wq.order...),
+		inters:     append([]Interceptor{}, wq.inters...),
+		predicates: append([]predicate.Whatsapp{}, wq.predicates...),
+		// clone intermediate query.
+		sql:  wq.sql.Clone(),
+		path: wq.path,
+	}
+}
+
+// GroupBy is used to group vertices by one or more fields/columns.
+// It is often used with aggregate functions, like: count, max, mean, min, sum.
+//
+// Example:
+//
+//	var v []struct {
+//		CreatedAt time.Time `json:"created_at,omitempty"`
+//		Count int `json:"count,omitempty"`
+//	}
+//
+//	client.Whatsapp.Query().
+//		GroupBy(whatsapp.FieldCreatedAt).
+//		Aggregate(ent.Count()).
+//		Scan(ctx, &v)
+func (wq *WhatsappQuery) GroupBy(field string, fields ...string) *WhatsappGroupBy {
+	wq.ctx.Fields = append([]string{field}, fields...)
+	grbuild := &WhatsappGroupBy{build: wq}
+	grbuild.flds = &wq.ctx.Fields
+	grbuild.label = whatsapp.Label
+	grbuild.scan = grbuild.Scan
+	return grbuild
+}
+
+// Select allows the selection one or more fields/columns for the given query,
+// instead of selecting all fields in the entity.
+//
+// Example:
+//
+//	var v []struct {
+//		CreatedAt time.Time `json:"created_at,omitempty"`
+//	}
+//
+//	client.Whatsapp.Query().
+//		Select(whatsapp.FieldCreatedAt).
+//		Scan(ctx, &v)
+func (wq *WhatsappQuery) Select(fields ...string) *WhatsappSelect {
+	wq.ctx.Fields = append(wq.ctx.Fields, fields...)
+	sbuild := &WhatsappSelect{WhatsappQuery: wq}
+	sbuild.label = whatsapp.Label
+	sbuild.flds, sbuild.scan = &wq.ctx.Fields, sbuild.Scan
+	return sbuild
+}
+
+// Aggregate returns a WhatsappSelect configured with the given aggregations.
+func (wq *WhatsappQuery) Aggregate(fns ...AggregateFunc) *WhatsappSelect {
+	return wq.Select().Aggregate(fns...)
+}
+
+func (wq *WhatsappQuery) prepareQuery(ctx context.Context) error {
+	for _, inter := range wq.inters {
+		if inter == nil {
+			return fmt.Errorf("ent: uninitialized interceptor (forgotten import ent/runtime?)")
+		}
+		if trv, ok := inter.(Traverser); ok {
+			if err := trv.Traverse(ctx, wq); err != nil {
+				return err
+			}
+		}
+	}
+	for _, f := range wq.ctx.Fields {
+		if !whatsapp.ValidColumn(f) {
+			return &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)}
+		}
+	}
+	if wq.path != nil {
+		prev, err := wq.path(ctx)
+		if err != nil {
+			return err
+		}
+		wq.sql = prev
+	}
+	return nil
+}
+
+func (wq *WhatsappQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*Whatsapp, error) {
+	var (
+		nodes = []*Whatsapp{}
+		_spec = wq.querySpec()
+	)
+	_spec.ScanValues = func(columns []string) ([]any, error) {
+		return (*Whatsapp).scanValues(nil, columns)
+	}
+	_spec.Assign = func(columns []string, values []any) error {
+		node := &Whatsapp{config: wq.config}
+		nodes = append(nodes, node)
+		return node.assignValues(columns, values)
+	}
+	for i := range hooks {
+		hooks[i](ctx, _spec)
+	}
+	if err := sqlgraph.QueryNodes(ctx, wq.driver, _spec); err != nil {
+		return nil, err
+	}
+	if len(nodes) == 0 {
+		return nodes, nil
+	}
+	return nodes, nil
+}
+
+func (wq *WhatsappQuery) sqlCount(ctx context.Context) (int, error) {
+	_spec := wq.querySpec()
+	_spec.Node.Columns = wq.ctx.Fields
+	if len(wq.ctx.Fields) > 0 {
+		_spec.Unique = wq.ctx.Unique != nil && *wq.ctx.Unique
+	}
+	return sqlgraph.CountNodes(ctx, wq.driver, _spec)
+}
+
+func (wq *WhatsappQuery) querySpec() *sqlgraph.QuerySpec {
+	_spec := sqlgraph.NewQuerySpec(whatsapp.Table, whatsapp.Columns, sqlgraph.NewFieldSpec(whatsapp.FieldID, field.TypeUint64))
+	_spec.From = wq.sql
+	if unique := wq.ctx.Unique; unique != nil {
+		_spec.Unique = *unique
+	} else if wq.path != nil {
+		_spec.Unique = true
+	}
+	if fields := wq.ctx.Fields; len(fields) > 0 {
+		_spec.Node.Columns = make([]string, 0, len(fields))
+		_spec.Node.Columns = append(_spec.Node.Columns, whatsapp.FieldID)
+		for i := range fields {
+			if fields[i] != whatsapp.FieldID {
+				_spec.Node.Columns = append(_spec.Node.Columns, fields[i])
+			}
+		}
+	}
+	if ps := wq.predicates; len(ps) > 0 {
+		_spec.Predicate = func(selector *sql.Selector) {
+			for i := range ps {
+				ps[i](selector)
+			}
+		}
+	}
+	if limit := wq.ctx.Limit; limit != nil {
+		_spec.Limit = *limit
+	}
+	if offset := wq.ctx.Offset; offset != nil {
+		_spec.Offset = *offset
+	}
+	if ps := wq.order; len(ps) > 0 {
+		_spec.Order = func(selector *sql.Selector) {
+			for i := range ps {
+				ps[i](selector)
+			}
+		}
+	}
+	return _spec
+}
+
+func (wq *WhatsappQuery) sqlQuery(ctx context.Context) *sql.Selector {
+	builder := sql.Dialect(wq.driver.Dialect())
+	t1 := builder.Table(whatsapp.Table)
+	columns := wq.ctx.Fields
+	if len(columns) == 0 {
+		columns = whatsapp.Columns
+	}
+	selector := builder.Select(t1.Columns(columns...)...).From(t1)
+	if wq.sql != nil {
+		selector = wq.sql
+		selector.Select(selector.Columns(columns...)...)
+	}
+	if wq.ctx.Unique != nil && *wq.ctx.Unique {
+		selector.Distinct()
+	}
+	for _, p := range wq.predicates {
+		p(selector)
+	}
+	for _, p := range wq.order {
+		p(selector)
+	}
+	if offset := wq.ctx.Offset; offset != nil {
+		// limit is mandatory for offset clause. We start
+		// with default value, and override it below if needed.
+		selector.Offset(*offset).Limit(math.MaxInt32)
+	}
+	if limit := wq.ctx.Limit; limit != nil {
+		selector.Limit(*limit)
+	}
+	return selector
+}
+
+// WhatsappGroupBy is the group-by builder for Whatsapp entities.
+type WhatsappGroupBy struct {
+	selector
+	build *WhatsappQuery
+}
+
+// Aggregate adds the given aggregation functions to the group-by query.
+func (wgb *WhatsappGroupBy) Aggregate(fns ...AggregateFunc) *WhatsappGroupBy {
+	wgb.fns = append(wgb.fns, fns...)
+	return wgb
+}
+
+// Scan applies the selector query and scans the result into the given value.
+func (wgb *WhatsappGroupBy) Scan(ctx context.Context, v any) error {
+	ctx = setContextOp(ctx, wgb.build.ctx, "GroupBy")
+	if err := wgb.build.prepareQuery(ctx); err != nil {
+		return err
+	}
+	return scanWithInterceptors[*WhatsappQuery, *WhatsappGroupBy](ctx, wgb.build, wgb, wgb.build.inters, v)
+}
+
+func (wgb *WhatsappGroupBy) sqlScan(ctx context.Context, root *WhatsappQuery, v any) error {
+	selector := root.sqlQuery(ctx).Select()
+	aggregation := make([]string, 0, len(wgb.fns))
+	for _, fn := range wgb.fns {
+		aggregation = append(aggregation, fn(selector))
+	}
+	if len(selector.SelectedColumns()) == 0 {
+		columns := make([]string, 0, len(*wgb.flds)+len(wgb.fns))
+		for _, f := range *wgb.flds {
+			columns = append(columns, selector.C(f))
+		}
+		columns = append(columns, aggregation...)
+		selector.Select(columns...)
+	}
+	selector.GroupBy(selector.Columns(*wgb.flds...)...)
+	if err := selector.Err(); err != nil {
+		return err
+	}
+	rows := &sql.Rows{}
+	query, args := selector.Query()
+	if err := wgb.build.driver.Query(ctx, query, args, rows); err != nil {
+		return err
+	}
+	defer rows.Close()
+	return sql.ScanSlice(rows, v)
+}
+
+// WhatsappSelect is the builder for selecting fields of Whatsapp entities.
+type WhatsappSelect struct {
+	*WhatsappQuery
+	selector
+}
+
+// Aggregate adds the given aggregation functions to the selector query.
+func (ws *WhatsappSelect) Aggregate(fns ...AggregateFunc) *WhatsappSelect {
+	ws.fns = append(ws.fns, fns...)
+	return ws
+}
+
+// Scan applies the selector query and scans the result into the given value.
+func (ws *WhatsappSelect) Scan(ctx context.Context, v any) error {
+	ctx = setContextOp(ctx, ws.ctx, "Select")
+	if err := ws.prepareQuery(ctx); err != nil {
+		return err
+	}
+	return scanWithInterceptors[*WhatsappQuery, *WhatsappSelect](ctx, ws.WhatsappQuery, ws, ws.inters, v)
+}
+
+func (ws *WhatsappSelect) sqlScan(ctx context.Context, root *WhatsappQuery, v any) error {
+	selector := root.sqlQuery(ctx)
+	aggregation := make([]string, 0, len(ws.fns))
+	for _, fn := range ws.fns {
+		aggregation = append(aggregation, fn(selector))
+	}
+	switch n := len(*ws.selector.flds); {
+	case n == 0 && len(aggregation) > 0:
+		selector.Select(aggregation...)
+	case n != 0 && len(aggregation) > 0:
+		selector.AppendSelect(aggregation...)
+	}
+	rows := &sql.Rows{}
+	query, args := selector.Query()
+	if err := ws.driver.Query(ctx, query, args, rows); err != nil {
+		return err
+	}
+	defer rows.Close()
+	return sql.ScanSlice(rows, v)
+}

+ 961 - 0
ent/whatsapp_update.go

@@ -0,0 +1,961 @@
+// Code generated by ent, DO NOT EDIT.
+
+package ent
+
+import (
+	"context"
+	"errors"
+	"fmt"
+	"time"
+	"wechat-api/ent/predicate"
+	"wechat-api/ent/whatsapp"
+
+	"entgo.io/ent/dialect/sql"
+	"entgo.io/ent/dialect/sql/sqlgraph"
+	"entgo.io/ent/dialect/sql/sqljson"
+	"entgo.io/ent/schema/field"
+)
+
+// WhatsappUpdate is the builder for updating Whatsapp entities.
+type WhatsappUpdate struct {
+	config
+	hooks    []Hook
+	mutation *WhatsappMutation
+}
+
+// Where appends a list predicates to the WhatsappUpdate builder.
+func (wu *WhatsappUpdate) Where(ps ...predicate.Whatsapp) *WhatsappUpdate {
+	wu.mutation.Where(ps...)
+	return wu
+}
+
+// SetUpdatedAt sets the "updated_at" field.
+func (wu *WhatsappUpdate) SetUpdatedAt(t time.Time) *WhatsappUpdate {
+	wu.mutation.SetUpdatedAt(t)
+	return wu
+}
+
+// SetStatus sets the "status" field.
+func (wu *WhatsappUpdate) SetStatus(u uint8) *WhatsappUpdate {
+	wu.mutation.ResetStatus()
+	wu.mutation.SetStatus(u)
+	return wu
+}
+
+// SetNillableStatus sets the "status" field if the given value is not nil.
+func (wu *WhatsappUpdate) SetNillableStatus(u *uint8) *WhatsappUpdate {
+	if u != nil {
+		wu.SetStatus(*u)
+	}
+	return wu
+}
+
+// AddStatus adds u to the "status" field.
+func (wu *WhatsappUpdate) AddStatus(u int8) *WhatsappUpdate {
+	wu.mutation.AddStatus(u)
+	return wu
+}
+
+// ClearStatus clears the value of the "status" field.
+func (wu *WhatsappUpdate) ClearStatus() *WhatsappUpdate {
+	wu.mutation.ClearStatus()
+	return wu
+}
+
+// SetDeletedAt sets the "deleted_at" field.
+func (wu *WhatsappUpdate) SetDeletedAt(t time.Time) *WhatsappUpdate {
+	wu.mutation.SetDeletedAt(t)
+	return wu
+}
+
+// SetNillableDeletedAt sets the "deleted_at" field if the given value is not nil.
+func (wu *WhatsappUpdate) SetNillableDeletedAt(t *time.Time) *WhatsappUpdate {
+	if t != nil {
+		wu.SetDeletedAt(*t)
+	}
+	return wu
+}
+
+// ClearDeletedAt clears the value of the "deleted_at" field.
+func (wu *WhatsappUpdate) ClearDeletedAt() *WhatsappUpdate {
+	wu.mutation.ClearDeletedAt()
+	return wu
+}
+
+// SetAk sets the "ak" field.
+func (wu *WhatsappUpdate) SetAk(s string) *WhatsappUpdate {
+	wu.mutation.SetAk(s)
+	return wu
+}
+
+// SetNillableAk sets the "ak" field if the given value is not nil.
+func (wu *WhatsappUpdate) SetNillableAk(s *string) *WhatsappUpdate {
+	if s != nil {
+		wu.SetAk(*s)
+	}
+	return wu
+}
+
+// ClearAk clears the value of the "ak" field.
+func (wu *WhatsappUpdate) ClearAk() *WhatsappUpdate {
+	wu.mutation.ClearAk()
+	return wu
+}
+
+// SetSk sets the "sk" field.
+func (wu *WhatsappUpdate) SetSk(s string) *WhatsappUpdate {
+	wu.mutation.SetSk(s)
+	return wu
+}
+
+// SetNillableSk sets the "sk" field if the given value is not nil.
+func (wu *WhatsappUpdate) SetNillableSk(s *string) *WhatsappUpdate {
+	if s != nil {
+		wu.SetSk(*s)
+	}
+	return wu
+}
+
+// SetCallback sets the "callback" field.
+func (wu *WhatsappUpdate) SetCallback(s string) *WhatsappUpdate {
+	wu.mutation.SetCallback(s)
+	return wu
+}
+
+// SetNillableCallback sets the "callback" field if the given value is not nil.
+func (wu *WhatsappUpdate) SetNillableCallback(s *string) *WhatsappUpdate {
+	if s != nil {
+		wu.SetCallback(*s)
+	}
+	return wu
+}
+
+// SetAccount sets the "account" field.
+func (wu *WhatsappUpdate) SetAccount(s string) *WhatsappUpdate {
+	wu.mutation.SetAccount(s)
+	return wu
+}
+
+// SetNillableAccount sets the "account" field if the given value is not nil.
+func (wu *WhatsappUpdate) SetNillableAccount(s *string) *WhatsappUpdate {
+	if s != nil {
+		wu.SetAccount(*s)
+	}
+	return wu
+}
+
+// SetNickname sets the "nickname" field.
+func (wu *WhatsappUpdate) SetNickname(s string) *WhatsappUpdate {
+	wu.mutation.SetNickname(s)
+	return wu
+}
+
+// SetNillableNickname sets the "nickname" field if the given value is not nil.
+func (wu *WhatsappUpdate) SetNillableNickname(s *string) *WhatsappUpdate {
+	if s != nil {
+		wu.SetNickname(*s)
+	}
+	return wu
+}
+
+// SetPhone sets the "phone" field.
+func (wu *WhatsappUpdate) SetPhone(s string) *WhatsappUpdate {
+	wu.mutation.SetPhone(s)
+	return wu
+}
+
+// SetNillablePhone sets the "phone" field if the given value is not nil.
+func (wu *WhatsappUpdate) SetNillablePhone(s *string) *WhatsappUpdate {
+	if s != nil {
+		wu.SetPhone(*s)
+	}
+	return wu
+}
+
+// SetOrganizationID sets the "organization_id" field.
+func (wu *WhatsappUpdate) SetOrganizationID(u uint64) *WhatsappUpdate {
+	wu.mutation.ResetOrganizationID()
+	wu.mutation.SetOrganizationID(u)
+	return wu
+}
+
+// SetNillableOrganizationID sets the "organization_id" field if the given value is not nil.
+func (wu *WhatsappUpdate) SetNillableOrganizationID(u *uint64) *WhatsappUpdate {
+	if u != nil {
+		wu.SetOrganizationID(*u)
+	}
+	return wu
+}
+
+// AddOrganizationID adds u to the "organization_id" field.
+func (wu *WhatsappUpdate) AddOrganizationID(u int64) *WhatsappUpdate {
+	wu.mutation.AddOrganizationID(u)
+	return wu
+}
+
+// ClearOrganizationID clears the value of the "organization_id" field.
+func (wu *WhatsappUpdate) ClearOrganizationID() *WhatsappUpdate {
+	wu.mutation.ClearOrganizationID()
+	return wu
+}
+
+// SetAgentID sets the "agent_id" field.
+func (wu *WhatsappUpdate) SetAgentID(u uint64) *WhatsappUpdate {
+	wu.mutation.ResetAgentID()
+	wu.mutation.SetAgentID(u)
+	return wu
+}
+
+// SetNillableAgentID sets the "agent_id" field if the given value is not nil.
+func (wu *WhatsappUpdate) SetNillableAgentID(u *uint64) *WhatsappUpdate {
+	if u != nil {
+		wu.SetAgentID(*u)
+	}
+	return wu
+}
+
+// AddAgentID adds u to the "agent_id" field.
+func (wu *WhatsappUpdate) AddAgentID(u int64) *WhatsappUpdate {
+	wu.mutation.AddAgentID(u)
+	return wu
+}
+
+// SetAPIBase sets the "api_base" field.
+func (wu *WhatsappUpdate) SetAPIBase(s string) *WhatsappUpdate {
+	wu.mutation.SetAPIBase(s)
+	return wu
+}
+
+// SetNillableAPIBase sets the "api_base" field if the given value is not nil.
+func (wu *WhatsappUpdate) SetNillableAPIBase(s *string) *WhatsappUpdate {
+	if s != nil {
+		wu.SetAPIBase(*s)
+	}
+	return wu
+}
+
+// ClearAPIBase clears the value of the "api_base" field.
+func (wu *WhatsappUpdate) ClearAPIBase() *WhatsappUpdate {
+	wu.mutation.ClearAPIBase()
+	return wu
+}
+
+// SetAPIKey sets the "api_key" field.
+func (wu *WhatsappUpdate) SetAPIKey(s string) *WhatsappUpdate {
+	wu.mutation.SetAPIKey(s)
+	return wu
+}
+
+// SetNillableAPIKey sets the "api_key" field if the given value is not nil.
+func (wu *WhatsappUpdate) SetNillableAPIKey(s *string) *WhatsappUpdate {
+	if s != nil {
+		wu.SetAPIKey(*s)
+	}
+	return wu
+}
+
+// ClearAPIKey clears the value of the "api_key" field.
+func (wu *WhatsappUpdate) ClearAPIKey() *WhatsappUpdate {
+	wu.mutation.ClearAPIKey()
+	return wu
+}
+
+// SetAllowList sets the "allow_list" field.
+func (wu *WhatsappUpdate) SetAllowList(s []string) *WhatsappUpdate {
+	wu.mutation.SetAllowList(s)
+	return wu
+}
+
+// AppendAllowList appends s to the "allow_list" field.
+func (wu *WhatsappUpdate) AppendAllowList(s []string) *WhatsappUpdate {
+	wu.mutation.AppendAllowList(s)
+	return wu
+}
+
+// SetGroupAllowList sets the "group_allow_list" field.
+func (wu *WhatsappUpdate) SetGroupAllowList(s []string) *WhatsappUpdate {
+	wu.mutation.SetGroupAllowList(s)
+	return wu
+}
+
+// AppendGroupAllowList appends s to the "group_allow_list" field.
+func (wu *WhatsappUpdate) AppendGroupAllowList(s []string) *WhatsappUpdate {
+	wu.mutation.AppendGroupAllowList(s)
+	return wu
+}
+
+// SetBlockList sets the "block_list" field.
+func (wu *WhatsappUpdate) SetBlockList(s []string) *WhatsappUpdate {
+	wu.mutation.SetBlockList(s)
+	return wu
+}
+
+// AppendBlockList appends s to the "block_list" field.
+func (wu *WhatsappUpdate) AppendBlockList(s []string) *WhatsappUpdate {
+	wu.mutation.AppendBlockList(s)
+	return wu
+}
+
+// SetGroupBlockList sets the "group_block_list" field.
+func (wu *WhatsappUpdate) SetGroupBlockList(s []string) *WhatsappUpdate {
+	wu.mutation.SetGroupBlockList(s)
+	return wu
+}
+
+// AppendGroupBlockList appends s to the "group_block_list" field.
+func (wu *WhatsappUpdate) AppendGroupBlockList(s []string) *WhatsappUpdate {
+	wu.mutation.AppendGroupBlockList(s)
+	return wu
+}
+
+// Mutation returns the WhatsappMutation object of the builder.
+func (wu *WhatsappUpdate) Mutation() *WhatsappMutation {
+	return wu.mutation
+}
+
+// Save executes the query and returns the number of nodes affected by the update operation.
+func (wu *WhatsappUpdate) Save(ctx context.Context) (int, error) {
+	if err := wu.defaults(); err != nil {
+		return 0, err
+	}
+	return withHooks(ctx, wu.sqlSave, wu.mutation, wu.hooks)
+}
+
+// SaveX is like Save, but panics if an error occurs.
+func (wu *WhatsappUpdate) SaveX(ctx context.Context) int {
+	affected, err := wu.Save(ctx)
+	if err != nil {
+		panic(err)
+	}
+	return affected
+}
+
+// Exec executes the query.
+func (wu *WhatsappUpdate) Exec(ctx context.Context) error {
+	_, err := wu.Save(ctx)
+	return err
+}
+
+// ExecX is like Exec, but panics if an error occurs.
+func (wu *WhatsappUpdate) ExecX(ctx context.Context) {
+	if err := wu.Exec(ctx); err != nil {
+		panic(err)
+	}
+}
+
+// defaults sets the default values of the builder before save.
+func (wu *WhatsappUpdate) defaults() error {
+	if _, ok := wu.mutation.UpdatedAt(); !ok {
+		if whatsapp.UpdateDefaultUpdatedAt == nil {
+			return fmt.Errorf("ent: uninitialized whatsapp.UpdateDefaultUpdatedAt (forgotten import ent/runtime?)")
+		}
+		v := whatsapp.UpdateDefaultUpdatedAt()
+		wu.mutation.SetUpdatedAt(v)
+	}
+	return nil
+}
+
+func (wu *WhatsappUpdate) sqlSave(ctx context.Context) (n int, err error) {
+	_spec := sqlgraph.NewUpdateSpec(whatsapp.Table, whatsapp.Columns, sqlgraph.NewFieldSpec(whatsapp.FieldID, field.TypeUint64))
+	if ps := wu.mutation.predicates; len(ps) > 0 {
+		_spec.Predicate = func(selector *sql.Selector) {
+			for i := range ps {
+				ps[i](selector)
+			}
+		}
+	}
+	if value, ok := wu.mutation.UpdatedAt(); ok {
+		_spec.SetField(whatsapp.FieldUpdatedAt, field.TypeTime, value)
+	}
+	if value, ok := wu.mutation.Status(); ok {
+		_spec.SetField(whatsapp.FieldStatus, field.TypeUint8, value)
+	}
+	if value, ok := wu.mutation.AddedStatus(); ok {
+		_spec.AddField(whatsapp.FieldStatus, field.TypeUint8, value)
+	}
+	if wu.mutation.StatusCleared() {
+		_spec.ClearField(whatsapp.FieldStatus, field.TypeUint8)
+	}
+	if value, ok := wu.mutation.DeletedAt(); ok {
+		_spec.SetField(whatsapp.FieldDeletedAt, field.TypeTime, value)
+	}
+	if wu.mutation.DeletedAtCleared() {
+		_spec.ClearField(whatsapp.FieldDeletedAt, field.TypeTime)
+	}
+	if value, ok := wu.mutation.Ak(); ok {
+		_spec.SetField(whatsapp.FieldAk, field.TypeString, value)
+	}
+	if wu.mutation.AkCleared() {
+		_spec.ClearField(whatsapp.FieldAk, field.TypeString)
+	}
+	if value, ok := wu.mutation.Sk(); ok {
+		_spec.SetField(whatsapp.FieldSk, field.TypeString, value)
+	}
+	if value, ok := wu.mutation.Callback(); ok {
+		_spec.SetField(whatsapp.FieldCallback, field.TypeString, value)
+	}
+	if value, ok := wu.mutation.Account(); ok {
+		_spec.SetField(whatsapp.FieldAccount, field.TypeString, value)
+	}
+	if value, ok := wu.mutation.Nickname(); ok {
+		_spec.SetField(whatsapp.FieldNickname, field.TypeString, value)
+	}
+	if value, ok := wu.mutation.Phone(); ok {
+		_spec.SetField(whatsapp.FieldPhone, field.TypeString, value)
+	}
+	if value, ok := wu.mutation.OrganizationID(); ok {
+		_spec.SetField(whatsapp.FieldOrganizationID, field.TypeUint64, value)
+	}
+	if value, ok := wu.mutation.AddedOrganizationID(); ok {
+		_spec.AddField(whatsapp.FieldOrganizationID, field.TypeUint64, value)
+	}
+	if wu.mutation.OrganizationIDCleared() {
+		_spec.ClearField(whatsapp.FieldOrganizationID, field.TypeUint64)
+	}
+	if value, ok := wu.mutation.AgentID(); ok {
+		_spec.SetField(whatsapp.FieldAgentID, field.TypeUint64, value)
+	}
+	if value, ok := wu.mutation.AddedAgentID(); ok {
+		_spec.AddField(whatsapp.FieldAgentID, field.TypeUint64, value)
+	}
+	if value, ok := wu.mutation.APIBase(); ok {
+		_spec.SetField(whatsapp.FieldAPIBase, field.TypeString, value)
+	}
+	if wu.mutation.APIBaseCleared() {
+		_spec.ClearField(whatsapp.FieldAPIBase, field.TypeString)
+	}
+	if value, ok := wu.mutation.APIKey(); ok {
+		_spec.SetField(whatsapp.FieldAPIKey, field.TypeString, value)
+	}
+	if wu.mutation.APIKeyCleared() {
+		_spec.ClearField(whatsapp.FieldAPIKey, field.TypeString)
+	}
+	if value, ok := wu.mutation.AllowList(); ok {
+		_spec.SetField(whatsapp.FieldAllowList, field.TypeJSON, value)
+	}
+	if value, ok := wu.mutation.AppendedAllowList(); ok {
+		_spec.AddModifier(func(u *sql.UpdateBuilder) {
+			sqljson.Append(u, whatsapp.FieldAllowList, value)
+		})
+	}
+	if value, ok := wu.mutation.GroupAllowList(); ok {
+		_spec.SetField(whatsapp.FieldGroupAllowList, field.TypeJSON, value)
+	}
+	if value, ok := wu.mutation.AppendedGroupAllowList(); ok {
+		_spec.AddModifier(func(u *sql.UpdateBuilder) {
+			sqljson.Append(u, whatsapp.FieldGroupAllowList, value)
+		})
+	}
+	if value, ok := wu.mutation.BlockList(); ok {
+		_spec.SetField(whatsapp.FieldBlockList, field.TypeJSON, value)
+	}
+	if value, ok := wu.mutation.AppendedBlockList(); ok {
+		_spec.AddModifier(func(u *sql.UpdateBuilder) {
+			sqljson.Append(u, whatsapp.FieldBlockList, value)
+		})
+	}
+	if value, ok := wu.mutation.GroupBlockList(); ok {
+		_spec.SetField(whatsapp.FieldGroupBlockList, field.TypeJSON, value)
+	}
+	if value, ok := wu.mutation.AppendedGroupBlockList(); ok {
+		_spec.AddModifier(func(u *sql.UpdateBuilder) {
+			sqljson.Append(u, whatsapp.FieldGroupBlockList, value)
+		})
+	}
+	if n, err = sqlgraph.UpdateNodes(ctx, wu.driver, _spec); err != nil {
+		if _, ok := err.(*sqlgraph.NotFoundError); ok {
+			err = &NotFoundError{whatsapp.Label}
+		} else if sqlgraph.IsConstraintError(err) {
+			err = &ConstraintError{msg: err.Error(), wrap: err}
+		}
+		return 0, err
+	}
+	wu.mutation.done = true
+	return n, nil
+}
+
+// WhatsappUpdateOne is the builder for updating a single Whatsapp entity.
+type WhatsappUpdateOne struct {
+	config
+	fields   []string
+	hooks    []Hook
+	mutation *WhatsappMutation
+}
+
+// SetUpdatedAt sets the "updated_at" field.
+func (wuo *WhatsappUpdateOne) SetUpdatedAt(t time.Time) *WhatsappUpdateOne {
+	wuo.mutation.SetUpdatedAt(t)
+	return wuo
+}
+
+// SetStatus sets the "status" field.
+func (wuo *WhatsappUpdateOne) SetStatus(u uint8) *WhatsappUpdateOne {
+	wuo.mutation.ResetStatus()
+	wuo.mutation.SetStatus(u)
+	return wuo
+}
+
+// SetNillableStatus sets the "status" field if the given value is not nil.
+func (wuo *WhatsappUpdateOne) SetNillableStatus(u *uint8) *WhatsappUpdateOne {
+	if u != nil {
+		wuo.SetStatus(*u)
+	}
+	return wuo
+}
+
+// AddStatus adds u to the "status" field.
+func (wuo *WhatsappUpdateOne) AddStatus(u int8) *WhatsappUpdateOne {
+	wuo.mutation.AddStatus(u)
+	return wuo
+}
+
+// ClearStatus clears the value of the "status" field.
+func (wuo *WhatsappUpdateOne) ClearStatus() *WhatsappUpdateOne {
+	wuo.mutation.ClearStatus()
+	return wuo
+}
+
+// SetDeletedAt sets the "deleted_at" field.
+func (wuo *WhatsappUpdateOne) SetDeletedAt(t time.Time) *WhatsappUpdateOne {
+	wuo.mutation.SetDeletedAt(t)
+	return wuo
+}
+
+// SetNillableDeletedAt sets the "deleted_at" field if the given value is not nil.
+func (wuo *WhatsappUpdateOne) SetNillableDeletedAt(t *time.Time) *WhatsappUpdateOne {
+	if t != nil {
+		wuo.SetDeletedAt(*t)
+	}
+	return wuo
+}
+
+// ClearDeletedAt clears the value of the "deleted_at" field.
+func (wuo *WhatsappUpdateOne) ClearDeletedAt() *WhatsappUpdateOne {
+	wuo.mutation.ClearDeletedAt()
+	return wuo
+}
+
+// SetAk sets the "ak" field.
+func (wuo *WhatsappUpdateOne) SetAk(s string) *WhatsappUpdateOne {
+	wuo.mutation.SetAk(s)
+	return wuo
+}
+
+// SetNillableAk sets the "ak" field if the given value is not nil.
+func (wuo *WhatsappUpdateOne) SetNillableAk(s *string) *WhatsappUpdateOne {
+	if s != nil {
+		wuo.SetAk(*s)
+	}
+	return wuo
+}
+
+// ClearAk clears the value of the "ak" field.
+func (wuo *WhatsappUpdateOne) ClearAk() *WhatsappUpdateOne {
+	wuo.mutation.ClearAk()
+	return wuo
+}
+
+// SetSk sets the "sk" field.
+func (wuo *WhatsappUpdateOne) SetSk(s string) *WhatsappUpdateOne {
+	wuo.mutation.SetSk(s)
+	return wuo
+}
+
+// SetNillableSk sets the "sk" field if the given value is not nil.
+func (wuo *WhatsappUpdateOne) SetNillableSk(s *string) *WhatsappUpdateOne {
+	if s != nil {
+		wuo.SetSk(*s)
+	}
+	return wuo
+}
+
+// SetCallback sets the "callback" field.
+func (wuo *WhatsappUpdateOne) SetCallback(s string) *WhatsappUpdateOne {
+	wuo.mutation.SetCallback(s)
+	return wuo
+}
+
+// SetNillableCallback sets the "callback" field if the given value is not nil.
+func (wuo *WhatsappUpdateOne) SetNillableCallback(s *string) *WhatsappUpdateOne {
+	if s != nil {
+		wuo.SetCallback(*s)
+	}
+	return wuo
+}
+
+// SetAccount sets the "account" field.
+func (wuo *WhatsappUpdateOne) SetAccount(s string) *WhatsappUpdateOne {
+	wuo.mutation.SetAccount(s)
+	return wuo
+}
+
+// SetNillableAccount sets the "account" field if the given value is not nil.
+func (wuo *WhatsappUpdateOne) SetNillableAccount(s *string) *WhatsappUpdateOne {
+	if s != nil {
+		wuo.SetAccount(*s)
+	}
+	return wuo
+}
+
+// SetNickname sets the "nickname" field.
+func (wuo *WhatsappUpdateOne) SetNickname(s string) *WhatsappUpdateOne {
+	wuo.mutation.SetNickname(s)
+	return wuo
+}
+
+// SetNillableNickname sets the "nickname" field if the given value is not nil.
+func (wuo *WhatsappUpdateOne) SetNillableNickname(s *string) *WhatsappUpdateOne {
+	if s != nil {
+		wuo.SetNickname(*s)
+	}
+	return wuo
+}
+
+// SetPhone sets the "phone" field.
+func (wuo *WhatsappUpdateOne) SetPhone(s string) *WhatsappUpdateOne {
+	wuo.mutation.SetPhone(s)
+	return wuo
+}
+
+// SetNillablePhone sets the "phone" field if the given value is not nil.
+func (wuo *WhatsappUpdateOne) SetNillablePhone(s *string) *WhatsappUpdateOne {
+	if s != nil {
+		wuo.SetPhone(*s)
+	}
+	return wuo
+}
+
+// SetOrganizationID sets the "organization_id" field.
+func (wuo *WhatsappUpdateOne) SetOrganizationID(u uint64) *WhatsappUpdateOne {
+	wuo.mutation.ResetOrganizationID()
+	wuo.mutation.SetOrganizationID(u)
+	return wuo
+}
+
+// SetNillableOrganizationID sets the "organization_id" field if the given value is not nil.
+func (wuo *WhatsappUpdateOne) SetNillableOrganizationID(u *uint64) *WhatsappUpdateOne {
+	if u != nil {
+		wuo.SetOrganizationID(*u)
+	}
+	return wuo
+}
+
+// AddOrganizationID adds u to the "organization_id" field.
+func (wuo *WhatsappUpdateOne) AddOrganizationID(u int64) *WhatsappUpdateOne {
+	wuo.mutation.AddOrganizationID(u)
+	return wuo
+}
+
+// ClearOrganizationID clears the value of the "organization_id" field.
+func (wuo *WhatsappUpdateOne) ClearOrganizationID() *WhatsappUpdateOne {
+	wuo.mutation.ClearOrganizationID()
+	return wuo
+}
+
+// SetAgentID sets the "agent_id" field.
+func (wuo *WhatsappUpdateOne) SetAgentID(u uint64) *WhatsappUpdateOne {
+	wuo.mutation.ResetAgentID()
+	wuo.mutation.SetAgentID(u)
+	return wuo
+}
+
+// SetNillableAgentID sets the "agent_id" field if the given value is not nil.
+func (wuo *WhatsappUpdateOne) SetNillableAgentID(u *uint64) *WhatsappUpdateOne {
+	if u != nil {
+		wuo.SetAgentID(*u)
+	}
+	return wuo
+}
+
+// AddAgentID adds u to the "agent_id" field.
+func (wuo *WhatsappUpdateOne) AddAgentID(u int64) *WhatsappUpdateOne {
+	wuo.mutation.AddAgentID(u)
+	return wuo
+}
+
+// SetAPIBase sets the "api_base" field.
+func (wuo *WhatsappUpdateOne) SetAPIBase(s string) *WhatsappUpdateOne {
+	wuo.mutation.SetAPIBase(s)
+	return wuo
+}
+
+// SetNillableAPIBase sets the "api_base" field if the given value is not nil.
+func (wuo *WhatsappUpdateOne) SetNillableAPIBase(s *string) *WhatsappUpdateOne {
+	if s != nil {
+		wuo.SetAPIBase(*s)
+	}
+	return wuo
+}
+
+// ClearAPIBase clears the value of the "api_base" field.
+func (wuo *WhatsappUpdateOne) ClearAPIBase() *WhatsappUpdateOne {
+	wuo.mutation.ClearAPIBase()
+	return wuo
+}
+
+// SetAPIKey sets the "api_key" field.
+func (wuo *WhatsappUpdateOne) SetAPIKey(s string) *WhatsappUpdateOne {
+	wuo.mutation.SetAPIKey(s)
+	return wuo
+}
+
+// SetNillableAPIKey sets the "api_key" field if the given value is not nil.
+func (wuo *WhatsappUpdateOne) SetNillableAPIKey(s *string) *WhatsappUpdateOne {
+	if s != nil {
+		wuo.SetAPIKey(*s)
+	}
+	return wuo
+}
+
+// ClearAPIKey clears the value of the "api_key" field.
+func (wuo *WhatsappUpdateOne) ClearAPIKey() *WhatsappUpdateOne {
+	wuo.mutation.ClearAPIKey()
+	return wuo
+}
+
+// SetAllowList sets the "allow_list" field.
+func (wuo *WhatsappUpdateOne) SetAllowList(s []string) *WhatsappUpdateOne {
+	wuo.mutation.SetAllowList(s)
+	return wuo
+}
+
+// AppendAllowList appends s to the "allow_list" field.
+func (wuo *WhatsappUpdateOne) AppendAllowList(s []string) *WhatsappUpdateOne {
+	wuo.mutation.AppendAllowList(s)
+	return wuo
+}
+
+// SetGroupAllowList sets the "group_allow_list" field.
+func (wuo *WhatsappUpdateOne) SetGroupAllowList(s []string) *WhatsappUpdateOne {
+	wuo.mutation.SetGroupAllowList(s)
+	return wuo
+}
+
+// AppendGroupAllowList appends s to the "group_allow_list" field.
+func (wuo *WhatsappUpdateOne) AppendGroupAllowList(s []string) *WhatsappUpdateOne {
+	wuo.mutation.AppendGroupAllowList(s)
+	return wuo
+}
+
+// SetBlockList sets the "block_list" field.
+func (wuo *WhatsappUpdateOne) SetBlockList(s []string) *WhatsappUpdateOne {
+	wuo.mutation.SetBlockList(s)
+	return wuo
+}
+
+// AppendBlockList appends s to the "block_list" field.
+func (wuo *WhatsappUpdateOne) AppendBlockList(s []string) *WhatsappUpdateOne {
+	wuo.mutation.AppendBlockList(s)
+	return wuo
+}
+
+// SetGroupBlockList sets the "group_block_list" field.
+func (wuo *WhatsappUpdateOne) SetGroupBlockList(s []string) *WhatsappUpdateOne {
+	wuo.mutation.SetGroupBlockList(s)
+	return wuo
+}
+
+// AppendGroupBlockList appends s to the "group_block_list" field.
+func (wuo *WhatsappUpdateOne) AppendGroupBlockList(s []string) *WhatsappUpdateOne {
+	wuo.mutation.AppendGroupBlockList(s)
+	return wuo
+}
+
+// Mutation returns the WhatsappMutation object of the builder.
+func (wuo *WhatsappUpdateOne) Mutation() *WhatsappMutation {
+	return wuo.mutation
+}
+
+// Where appends a list predicates to the WhatsappUpdate builder.
+func (wuo *WhatsappUpdateOne) Where(ps ...predicate.Whatsapp) *WhatsappUpdateOne {
+	wuo.mutation.Where(ps...)
+	return wuo
+}
+
+// Select allows selecting one or more fields (columns) of the returned entity.
+// The default is selecting all fields defined in the entity schema.
+func (wuo *WhatsappUpdateOne) Select(field string, fields ...string) *WhatsappUpdateOne {
+	wuo.fields = append([]string{field}, fields...)
+	return wuo
+}
+
+// Save executes the query and returns the updated Whatsapp entity.
+func (wuo *WhatsappUpdateOne) Save(ctx context.Context) (*Whatsapp, error) {
+	if err := wuo.defaults(); err != nil {
+		return nil, err
+	}
+	return withHooks(ctx, wuo.sqlSave, wuo.mutation, wuo.hooks)
+}
+
+// SaveX is like Save, but panics if an error occurs.
+func (wuo *WhatsappUpdateOne) SaveX(ctx context.Context) *Whatsapp {
+	node, err := wuo.Save(ctx)
+	if err != nil {
+		panic(err)
+	}
+	return node
+}
+
+// Exec executes the query on the entity.
+func (wuo *WhatsappUpdateOne) Exec(ctx context.Context) error {
+	_, err := wuo.Save(ctx)
+	return err
+}
+
+// ExecX is like Exec, but panics if an error occurs.
+func (wuo *WhatsappUpdateOne) ExecX(ctx context.Context) {
+	if err := wuo.Exec(ctx); err != nil {
+		panic(err)
+	}
+}
+
+// defaults sets the default values of the builder before save.
+func (wuo *WhatsappUpdateOne) defaults() error {
+	if _, ok := wuo.mutation.UpdatedAt(); !ok {
+		if whatsapp.UpdateDefaultUpdatedAt == nil {
+			return fmt.Errorf("ent: uninitialized whatsapp.UpdateDefaultUpdatedAt (forgotten import ent/runtime?)")
+		}
+		v := whatsapp.UpdateDefaultUpdatedAt()
+		wuo.mutation.SetUpdatedAt(v)
+	}
+	return nil
+}
+
+func (wuo *WhatsappUpdateOne) sqlSave(ctx context.Context) (_node *Whatsapp, err error) {
+	_spec := sqlgraph.NewUpdateSpec(whatsapp.Table, whatsapp.Columns, sqlgraph.NewFieldSpec(whatsapp.FieldID, field.TypeUint64))
+	id, ok := wuo.mutation.ID()
+	if !ok {
+		return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "Whatsapp.id" for update`)}
+	}
+	_spec.Node.ID.Value = id
+	if fields := wuo.fields; len(fields) > 0 {
+		_spec.Node.Columns = make([]string, 0, len(fields))
+		_spec.Node.Columns = append(_spec.Node.Columns, whatsapp.FieldID)
+		for _, f := range fields {
+			if !whatsapp.ValidColumn(f) {
+				return nil, &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)}
+			}
+			if f != whatsapp.FieldID {
+				_spec.Node.Columns = append(_spec.Node.Columns, f)
+			}
+		}
+	}
+	if ps := wuo.mutation.predicates; len(ps) > 0 {
+		_spec.Predicate = func(selector *sql.Selector) {
+			for i := range ps {
+				ps[i](selector)
+			}
+		}
+	}
+	if value, ok := wuo.mutation.UpdatedAt(); ok {
+		_spec.SetField(whatsapp.FieldUpdatedAt, field.TypeTime, value)
+	}
+	if value, ok := wuo.mutation.Status(); ok {
+		_spec.SetField(whatsapp.FieldStatus, field.TypeUint8, value)
+	}
+	if value, ok := wuo.mutation.AddedStatus(); ok {
+		_spec.AddField(whatsapp.FieldStatus, field.TypeUint8, value)
+	}
+	if wuo.mutation.StatusCleared() {
+		_spec.ClearField(whatsapp.FieldStatus, field.TypeUint8)
+	}
+	if value, ok := wuo.mutation.DeletedAt(); ok {
+		_spec.SetField(whatsapp.FieldDeletedAt, field.TypeTime, value)
+	}
+	if wuo.mutation.DeletedAtCleared() {
+		_spec.ClearField(whatsapp.FieldDeletedAt, field.TypeTime)
+	}
+	if value, ok := wuo.mutation.Ak(); ok {
+		_spec.SetField(whatsapp.FieldAk, field.TypeString, value)
+	}
+	if wuo.mutation.AkCleared() {
+		_spec.ClearField(whatsapp.FieldAk, field.TypeString)
+	}
+	if value, ok := wuo.mutation.Sk(); ok {
+		_spec.SetField(whatsapp.FieldSk, field.TypeString, value)
+	}
+	if value, ok := wuo.mutation.Callback(); ok {
+		_spec.SetField(whatsapp.FieldCallback, field.TypeString, value)
+	}
+	if value, ok := wuo.mutation.Account(); ok {
+		_spec.SetField(whatsapp.FieldAccount, field.TypeString, value)
+	}
+	if value, ok := wuo.mutation.Nickname(); ok {
+		_spec.SetField(whatsapp.FieldNickname, field.TypeString, value)
+	}
+	if value, ok := wuo.mutation.Phone(); ok {
+		_spec.SetField(whatsapp.FieldPhone, field.TypeString, value)
+	}
+	if value, ok := wuo.mutation.OrganizationID(); ok {
+		_spec.SetField(whatsapp.FieldOrganizationID, field.TypeUint64, value)
+	}
+	if value, ok := wuo.mutation.AddedOrganizationID(); ok {
+		_spec.AddField(whatsapp.FieldOrganizationID, field.TypeUint64, value)
+	}
+	if wuo.mutation.OrganizationIDCleared() {
+		_spec.ClearField(whatsapp.FieldOrganizationID, field.TypeUint64)
+	}
+	if value, ok := wuo.mutation.AgentID(); ok {
+		_spec.SetField(whatsapp.FieldAgentID, field.TypeUint64, value)
+	}
+	if value, ok := wuo.mutation.AddedAgentID(); ok {
+		_spec.AddField(whatsapp.FieldAgentID, field.TypeUint64, value)
+	}
+	if value, ok := wuo.mutation.APIBase(); ok {
+		_spec.SetField(whatsapp.FieldAPIBase, field.TypeString, value)
+	}
+	if wuo.mutation.APIBaseCleared() {
+		_spec.ClearField(whatsapp.FieldAPIBase, field.TypeString)
+	}
+	if value, ok := wuo.mutation.APIKey(); ok {
+		_spec.SetField(whatsapp.FieldAPIKey, field.TypeString, value)
+	}
+	if wuo.mutation.APIKeyCleared() {
+		_spec.ClearField(whatsapp.FieldAPIKey, field.TypeString)
+	}
+	if value, ok := wuo.mutation.AllowList(); ok {
+		_spec.SetField(whatsapp.FieldAllowList, field.TypeJSON, value)
+	}
+	if value, ok := wuo.mutation.AppendedAllowList(); ok {
+		_spec.AddModifier(func(u *sql.UpdateBuilder) {
+			sqljson.Append(u, whatsapp.FieldAllowList, value)
+		})
+	}
+	if value, ok := wuo.mutation.GroupAllowList(); ok {
+		_spec.SetField(whatsapp.FieldGroupAllowList, field.TypeJSON, value)
+	}
+	if value, ok := wuo.mutation.AppendedGroupAllowList(); ok {
+		_spec.AddModifier(func(u *sql.UpdateBuilder) {
+			sqljson.Append(u, whatsapp.FieldGroupAllowList, value)
+		})
+	}
+	if value, ok := wuo.mutation.BlockList(); ok {
+		_spec.SetField(whatsapp.FieldBlockList, field.TypeJSON, value)
+	}
+	if value, ok := wuo.mutation.AppendedBlockList(); ok {
+		_spec.AddModifier(func(u *sql.UpdateBuilder) {
+			sqljson.Append(u, whatsapp.FieldBlockList, value)
+		})
+	}
+	if value, ok := wuo.mutation.GroupBlockList(); ok {
+		_spec.SetField(whatsapp.FieldGroupBlockList, field.TypeJSON, value)
+	}
+	if value, ok := wuo.mutation.AppendedGroupBlockList(); ok {
+		_spec.AddModifier(func(u *sql.UpdateBuilder) {
+			sqljson.Append(u, whatsapp.FieldGroupBlockList, value)
+		})
+	}
+	_node = &Whatsapp{config: wuo.config}
+	_spec.Assign = _node.assignValues
+	_spec.ScanValues = _node.scanValues
+	if err = sqlgraph.UpdateNode(ctx, wuo.driver, _spec); err != nil {
+		if _, ok := err.(*sqlgraph.NotFoundError); ok {
+			err = &NotFoundError{whatsapp.Label}
+		} else if sqlgraph.IsConstraintError(err) {
+			err = &ConstraintError{msg: err.Error(), wrap: err}
+		}
+		return nil, err
+	}
+	wuo.mutation.done = true
+	return _node, nil
+}

+ 44 - 0
internal/handler/UsageDetail/get_usage_detail_handler.go

@@ -0,0 +1,44 @@
+package UsageDetail
+
+import (
+	"net/http"
+
+	"github.com/zeromicro/go-zero/rest/httpx"
+
+	"wechat-api/internal/logic/UsageDetail"
+	"wechat-api/internal/svc"
+	"wechat-api/internal/types"
+)
+
+// swagger:route post /usage_detail UsageDetail GetUsageDetail
+//
+// Get usage detail list | 获取Wx列表
+//
+// Get usage detail list | 获取Wx列表
+//
+// Parameters:
+//  + name: body
+//    require: true
+//    in: body
+//    type: IDReq
+//
+// Responses:
+//  200: UsageDetailResp
+
+func GetUsageDetailHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
+	return func(w http.ResponseWriter, r *http.Request) {
+		var req types.IDReq
+		if err := httpx.Parse(r, &req, true); err != nil {
+			httpx.ErrorCtx(r.Context(), w, err)
+			return
+		}
+
+		l := UsageDetail.NewGetUsageDetailLogic(r.Context(), svcCtx)
+		resp, err := l.GetUsageDetail(&req)
+		if err != nil {
+			httpx.ErrorCtx(r.Context(), w, err)
+		} else {
+			httpx.OkJsonCtx(r.Context(), w, resp)
+		}
+	}
+}

+ 44 - 0
internal/handler/credit_balance/operate_credit_balance_handler.go

@@ -0,0 +1,44 @@
+package credit_balance
+
+import (
+	"net/http"
+
+	"github.com/zeromicro/go-zero/rest/httpx"
+
+	"wechat-api/internal/logic/credit_balance"
+	"wechat-api/internal/svc"
+	"wechat-api/internal/types"
+)
+
+// swagger:route post /credit_balance/operate credit_balance OperateCreditBalance
+//
+// Get credit balance by ID | 通过ID获取CreditBalance
+//
+// Get credit balance by ID | 通过ID获取CreditBalance
+//
+// Parameters:
+//  + name: body
+//    require: true
+//    in: body
+//    type: CreditBalanceOperateReq
+//
+// Responses:
+//  200: BaseMsgResp
+
+func OperateCreditBalanceHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
+	return func(w http.ResponseWriter, r *http.Request) {
+		var req types.CreditBalanceOperateReq
+		if err := httpx.Parse(r, &req, true); err != nil {
+			httpx.ErrorCtx(r.Context(), w, err)
+			return
+		}
+
+		l := credit_balance.NewOperateCreditBalanceLogic(r.Context(), svcCtx)
+		resp, err := l.OperateCreditBalance(&req)
+		if err != nil {
+			httpx.ErrorCtx(r.Context(), w, err)
+		} else {
+			httpx.OkJsonCtx(r.Context(), w, resp)
+		}
+	}
+}

+ 45 - 0
internal/handler/routes.go

@@ -41,6 +41,7 @@ import (
 	sop_task "wechat-api/internal/handler/sop_task"
 	token "wechat-api/internal/handler/token"
 	tutorial "wechat-api/internal/handler/tutorial"
+	whatsapp "wechat-api/internal/handler/whatsapp"
 	work_experience "wechat-api/internal/handler/work_experience"
 	wxcard "wechat-api/internal/handler/wxcard"
 	wxcarduser "wechat-api/internal/handler/wxcarduser"
@@ -1559,6 +1560,11 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) {
 					Path:    "/usage_detail/list",
 					Handler: UsageDetail.GetUsageDetailListHandler(serverCtx),
 				},
+				{
+					Method:  http.MethodPost,
+					Path:    "/usage_detail",
+					Handler: UsageDetail.GetUsageDetailHandler(serverCtx),
+				},
 			}...,
 		),
 		rest.WithJwt(serverCtx.Config.Auth.AccessSecret),
@@ -1690,6 +1696,11 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) {
 					Path:    "/credit_balance",
 					Handler: credit_balance.GetCreditBalanceByIdHandler(serverCtx),
 				},
+				{
+					Method:  http.MethodPost,
+					Path:    "/credit_balance/operate",
+					Handler: credit_balance.OperateCreditBalanceHandler(serverCtx),
+				},
 			}...,
 		),
 		rest.WithJwt(serverCtx.Config.Auth.AccessSecret),
@@ -1762,4 +1773,38 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) {
 		),
 		rest.WithJwt(serverCtx.Config.Auth.AccessSecret),
 	)
+
+	server.AddRoutes(
+		rest.WithMiddlewares(
+			[]rest.Middleware{serverCtx.Authority},
+			[]rest.Route{
+				{
+					Method:  http.MethodPost,
+					Path:    "/whatsapp/create",
+					Handler: whatsapp.CreateWhatsappHandler(serverCtx),
+				},
+				{
+					Method:  http.MethodPost,
+					Path:    "/whatsapp/update",
+					Handler: whatsapp.UpdateWhatsappHandler(serverCtx),
+				},
+				{
+					Method:  http.MethodPost,
+					Path:    "/whatsapp/delete",
+					Handler: whatsapp.DeleteWhatsappHandler(serverCtx),
+				},
+				{
+					Method:  http.MethodPost,
+					Path:    "/whatsapp/list",
+					Handler: whatsapp.GetWhatsappListHandler(serverCtx),
+				},
+				{
+					Method:  http.MethodPost,
+					Path:    "/whatsapp",
+					Handler: whatsapp.GetWhatsappByIdHandler(serverCtx),
+				},
+			}...,
+		),
+		rest.WithJwt(serverCtx.Config.Auth.AccessSecret),
+	)
 }

+ 44 - 0
internal/handler/whatsapp/create_whatsapp_handler.go

@@ -0,0 +1,44 @@
+package whatsapp
+
+import (
+	"net/http"
+
+	"github.com/zeromicro/go-zero/rest/httpx"
+
+	"wechat-api/internal/logic/whatsapp"
+	"wechat-api/internal/svc"
+	"wechat-api/internal/types"
+)
+
+// swagger:route post /whatsapp/create whatsapp CreateWhatsapp
+//
+// Create whatsapp information | 创建Whatsapp
+//
+// Create whatsapp information | 创建Whatsapp
+//
+// Parameters:
+//  + name: body
+//    require: true
+//    in: body
+//    type: WhatsappInfo
+//
+// Responses:
+//  200: BaseMsgResp
+
+func CreateWhatsappHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
+	return func(w http.ResponseWriter, r *http.Request) {
+		var req types.WhatsappInfo
+		if err := httpx.Parse(r, &req, true); err != nil {
+			httpx.ErrorCtx(r.Context(), w, err)
+			return
+		}
+
+		l := whatsapp.NewCreateWhatsappLogic(r.Context(), svcCtx)
+		resp, err := l.CreateWhatsapp(&req)
+		if err != nil {
+			httpx.ErrorCtx(r.Context(), w, err)
+		} else {
+			httpx.OkJsonCtx(r.Context(), w, resp)
+		}
+	}
+}

+ 44 - 0
internal/handler/whatsapp/delete_whatsapp_handler.go

@@ -0,0 +1,44 @@
+package whatsapp
+
+import (
+	"net/http"
+
+	"github.com/zeromicro/go-zero/rest/httpx"
+
+	"wechat-api/internal/logic/whatsapp"
+	"wechat-api/internal/svc"
+	"wechat-api/internal/types"
+)
+
+// swagger:route post /whatsapp/delete whatsapp DeleteWhatsapp
+//
+// Delete whatsapp information | 删除Whatsapp信息
+//
+// Delete whatsapp information | 删除Whatsapp信息
+//
+// Parameters:
+//  + name: body
+//    require: true
+//    in: body
+//    type: IDsReq
+//
+// Responses:
+//  200: BaseMsgResp
+
+func DeleteWhatsappHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
+	return func(w http.ResponseWriter, r *http.Request) {
+		var req types.IDsReq
+		if err := httpx.Parse(r, &req, true); err != nil {
+			httpx.ErrorCtx(r.Context(), w, err)
+			return
+		}
+
+		l := whatsapp.NewDeleteWhatsappLogic(r.Context(), svcCtx)
+		resp, err := l.DeleteWhatsapp(&req)
+		if err != nil {
+			httpx.ErrorCtx(r.Context(), w, err)
+		} else {
+			httpx.OkJsonCtx(r.Context(), w, resp)
+		}
+	}
+}

+ 44 - 0
internal/handler/whatsapp/get_whatsapp_by_id_handler.go

@@ -0,0 +1,44 @@
+package whatsapp
+
+import (
+	"net/http"
+
+	"github.com/zeromicro/go-zero/rest/httpx"
+
+	"wechat-api/internal/logic/whatsapp"
+	"wechat-api/internal/svc"
+	"wechat-api/internal/types"
+)
+
+// swagger:route post /whatsapp whatsapp GetWhatsappById
+//
+// Get whatsapp by ID | 通过ID获取Whatsapp
+//
+// Get whatsapp by ID | 通过ID获取Whatsapp
+//
+// Parameters:
+//  + name: body
+//    require: true
+//    in: body
+//    type: IDReq
+//
+// Responses:
+//  200: WhatsappInfoResp
+
+func GetWhatsappByIdHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
+	return func(w http.ResponseWriter, r *http.Request) {
+		var req types.IDReq
+		if err := httpx.Parse(r, &req, true); err != nil {
+			httpx.ErrorCtx(r.Context(), w, err)
+			return
+		}
+
+		l := whatsapp.NewGetWhatsappByIdLogic(r.Context(), svcCtx)
+		resp, err := l.GetWhatsappById(&req)
+		if err != nil {
+			httpx.ErrorCtx(r.Context(), w, err)
+		} else {
+			httpx.OkJsonCtx(r.Context(), w, resp)
+		}
+	}
+}

+ 44 - 0
internal/handler/whatsapp/get_whatsapp_list_handler.go

@@ -0,0 +1,44 @@
+package whatsapp
+
+import (
+	"net/http"
+
+	"github.com/zeromicro/go-zero/rest/httpx"
+
+	"wechat-api/internal/logic/whatsapp"
+	"wechat-api/internal/svc"
+	"wechat-api/internal/types"
+)
+
+// swagger:route post /whatsapp/list whatsapp GetWhatsappList
+//
+// Get whatsapp list | 获取Whatsapp列表
+//
+// Get whatsapp list | 获取Whatsapp列表
+//
+// Parameters:
+//  + name: body
+//    require: true
+//    in: body
+//    type: WhatsappListReq
+//
+// Responses:
+//  200: WhatsappListResp
+
+func GetWhatsappListHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
+	return func(w http.ResponseWriter, r *http.Request) {
+		var req types.WhatsappListReq
+		if err := httpx.Parse(r, &req, true); err != nil {
+			httpx.ErrorCtx(r.Context(), w, err)
+			return
+		}
+
+		l := whatsapp.NewGetWhatsappListLogic(r.Context(), svcCtx)
+		resp, err := l.GetWhatsappList(&req)
+		if err != nil {
+			httpx.ErrorCtx(r.Context(), w, err)
+		} else {
+			httpx.OkJsonCtx(r.Context(), w, resp)
+		}
+	}
+}

+ 44 - 0
internal/handler/whatsapp/update_whatsapp_handler.go

@@ -0,0 +1,44 @@
+package whatsapp
+
+import (
+	"net/http"
+
+	"github.com/zeromicro/go-zero/rest/httpx"
+
+	"wechat-api/internal/logic/whatsapp"
+	"wechat-api/internal/svc"
+	"wechat-api/internal/types"
+)
+
+// swagger:route post /whatsapp/update whatsapp UpdateWhatsapp
+//
+// Update whatsapp information | 更新Whatsapp
+//
+// Update whatsapp information | 更新Whatsapp
+//
+// Parameters:
+//  + name: body
+//    require: true
+//    in: body
+//    type: WhatsappInfo
+//
+// Responses:
+//  200: BaseMsgResp
+
+func UpdateWhatsappHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
+	return func(w http.ResponseWriter, r *http.Request) {
+		var req types.WhatsappInfo
+		if err := httpx.Parse(r, &req, true); err != nil {
+			httpx.ErrorCtx(r.Context(), w, err)
+			return
+		}
+
+		l := whatsapp.NewUpdateWhatsappLogic(r.Context(), svcCtx)
+		resp, err := l.UpdateWhatsapp(&req)
+		if err != nil {
+			httpx.ErrorCtx(r.Context(), w, err)
+		} else {
+			httpx.OkJsonCtx(r.Context(), w, resp)
+		}
+	}
+}

+ 85 - 0
internal/logic/UsageDetail/get_usage_detail_logic.go

@@ -0,0 +1,85 @@
+package UsageDetail
+
+import (
+	"context"
+	"github.com/suyuan32/simple-admin-common/msg/errormsg"
+	"github.com/suyuan32/simple-admin-common/utils/pointy"
+	"github.com/zeromicro/go-zero/core/errorx"
+	"wechat-api/ent/usagedetail"
+	"wechat-api/internal/utils/dberrorhandler"
+
+	"wechat-api/internal/svc"
+	"wechat-api/internal/types"
+
+	"github.com/zeromicro/go-zero/core/logx"
+)
+
+type GetUsageDetailLogic struct {
+	logx.Logger
+	ctx    context.Context
+	svcCtx *svc.ServiceContext
+}
+
+func NewGetUsageDetailLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetUsageDetailLogic {
+	return &GetUsageDetailLogic{
+		Logger: logx.WithContext(ctx),
+		ctx:    ctx,
+		svcCtx: svcCtx}
+}
+
+func (l *GetUsageDetailLogic) GetUsageDetail(req *types.IDReq) (resp *types.UsageDetailResp, err error) {
+	if req.Id <= 0 {
+		return nil, errorx.NewInvalidArgumentError("参数错误")
+	}
+
+	data, err := l.svcCtx.DB.UsageDetail.Query().Where(usagedetail.ID(req.Id)).Only(l.ctx)
+
+	if err != nil {
+		return nil, dberrorhandler.DefaultEntError(l.Logger, err, req)
+	}
+
+	resp = &types.UsageDetailResp{}
+	resp.Msg = errormsg.Success
+
+	if data != nil {
+		app := "未知"
+		if data.App == 1 {
+			app = "智能回复"
+		} else if data.App == 2 {
+			app = "AI角色-优化问题"
+		} else if data.App == 3 {
+			app = "AI角色-回复"
+		} else if data.App == 4 {
+			app = "SOP-节点判断"
+		} else if data.App == 5 {
+			app = "SOP-节点判断"
+		}
+		request := data.Request
+		if data.App == 2 {
+			request = "问题优化"
+		} else if data.App == 4 {
+			request = "节点判断"
+		}
+		resp.Data = types.UsageDetailInfo{
+			BaseIDInfo: types.BaseIDInfo{
+				Id:        &data.ID,
+				CreatedAt: pointy.GetPointer(data.CreatedAt.UnixMilli()),
+				UpdatedAt: pointy.GetPointer(data.UpdatedAt.UnixMilli()),
+			},
+			Status:           &data.Status,
+			Type:             &data.Type,
+			BotId:            &data.BotID,
+			ReceiverId:       &data.ReceiverID,
+			App:              &app,
+			SessionId:        &data.SessionID,
+			Request:          &request,
+			Response:         &data.Response,
+			TotalTokens:      &data.TotalTokens,
+			PromptTokens:     &data.PromptTokens,
+			CompletionTokens: &data.CompletionTokens,
+			OrganizationId:   &data.OrganizationID,
+		}
+	}
+
+	return resp, nil
+}

+ 62 - 0
internal/logic/base/init_api_data.go

@@ -6,6 +6,68 @@ import (
 )
 
 func (l *InitDatabaseLogic) insertApiData() (err error) {
+	// Whatsapp
+
+	_, err = l.svcCtx.CoreRpc.CreateApi(l.ctx, &core.ApiInfo{
+		ServiceName: pointy.GetPointer("Wechat"),
+		Path:        pointy.GetPointer("/whatsapp/create"),
+		Description: pointy.GetPointer("apiDesc.createWhatsapp"),
+		ApiGroup:    pointy.GetPointer("whatsapp"),
+		Method:      pointy.GetPointer("POST"),
+	})
+
+	if err != nil {
+		return err
+	}
+
+	_, err = l.svcCtx.CoreRpc.CreateApi(l.ctx, &core.ApiInfo{
+		ServiceName: pointy.GetPointer("Wechat"),
+		Path:        pointy.GetPointer("/whatsapp/update"),
+		Description: pointy.GetPointer("apiDesc.updateWhatsapp"),
+		ApiGroup:    pointy.GetPointer("whatsapp"),
+		Method:      pointy.GetPointer("POST"),
+	})
+
+	if err != nil {
+		return err
+	}
+
+	_, err = l.svcCtx.CoreRpc.CreateApi(l.ctx, &core.ApiInfo{
+		ServiceName: pointy.GetPointer("Wechat"),
+		Path:        pointy.GetPointer("/whatsapp/delete"),
+		Description: pointy.GetPointer("apiDesc.deleteWhatsapp"),
+		ApiGroup:    pointy.GetPointer("whatsapp"),
+		Method:      pointy.GetPointer("POST"),
+	})
+
+	if err != nil {
+		return err
+	}
+
+	_, err = l.svcCtx.CoreRpc.CreateApi(l.ctx, &core.ApiInfo{
+		ServiceName: pointy.GetPointer("Wechat"),
+		Path:        pointy.GetPointer("/whatsapp/list"),
+		Description: pointy.GetPointer("apiDesc.getWhatsappList"),
+		ApiGroup:    pointy.GetPointer("whatsapp"),
+		Method:      pointy.GetPointer("POST"),
+	})
+
+	if err != nil {
+		return err
+	}
+
+	_, err = l.svcCtx.CoreRpc.CreateApi(l.ctx, &core.ApiInfo{
+		ServiceName: pointy.GetPointer("Wechat"),
+		Path:        pointy.GetPointer("/whatsapp"),
+		Description: pointy.GetPointer("apiDesc.getWhatsappById"),
+		ApiGroup:    pointy.GetPointer("whatsapp"),
+		Method:      pointy.GetPointer("POST"),
+	})
+
+	if err != nil {
+		return err
+	}
+
 	// PayRecharge
 
 	_, err = l.svcCtx.CoreRpc.CreateApi(l.ctx, &core.ApiInfo{

+ 11 - 10
internal/logic/credit_balance/create_credit_balance_logic.go

@@ -2,12 +2,13 @@ package credit_balance
 
 import (
 	"context"
+	"github.com/alibabacloud-go/tea/tea"
 
 	"wechat-api/internal/svc"
 	"wechat-api/internal/types"
 	"wechat-api/internal/utils/dberrorhandler"
 
-    "github.com/suyuan32/simple-admin-common/msg/errormsg"
+	"github.com/suyuan32/simple-admin-common/msg/errormsg"
 
 	"github.com/zeromicro/go-zero/core/logx"
 )
@@ -27,16 +28,16 @@ func NewCreateCreditBalanceLogic(ctx context.Context, svcCtx *svc.ServiceContext
 }
 
 func (l *CreateCreditBalanceLogic) CreateCreditBalance(req *types.CreditBalanceInfo) (*types.BaseMsgResp, error) {
-    _, err := l.svcCtx.DB.CreditBalance.Create().
-			SetNotNilUserID(req.UserId).
-			SetNotNilBalance(req.Balance).
-			SetNotNilStatus(req.Status).
-			SetNotNilOrganizationID(req.OrganizationId).
-			Save(l.ctx)
-
-    if err != nil {
+	_, err := l.svcCtx.DB.CreditBalance.Create().
+		SetNotNilUserID(req.UserId).
+		SetNotNilBalance(req.Balance).
+		SetNotNilStatus(tea.Int(1)).
+		SetNotNilOrganizationID(req.OrganizationId).
+		Save(l.ctx)
+
+	if err != nil {
 		return nil, dberrorhandler.DefaultEntError(l.Logger, err, req)
 	}
 
-    return &types.BaseMsgResp{Msg: errormsg.CreateSuccess}, nil
+	return &types.BaseMsgResp{Msg: errormsg.CreateSuccess}, nil
 }

+ 27 - 17
internal/logic/credit_balance/get_credit_balance_by_id_logic.go

@@ -2,12 +2,13 @@ package credit_balance
 
 import (
 	"context"
+	"github.com/suyuan32/simple-admin-core/rpc/types/core"
 
 	"wechat-api/internal/svc"
 	"wechat-api/internal/types"
 	"wechat-api/internal/utils/dberrorhandler"
 
-    "github.com/suyuan32/simple-admin-common/msg/errormsg"
+	"github.com/suyuan32/simple-admin-common/msg/errormsg"
 
 	"github.com/suyuan32/simple-admin-common/utils/pointy"
 	"github.com/zeromicro/go-zero/core/logx"
@@ -33,22 +34,31 @@ func (l *GetCreditBalanceByIdLogic) GetCreditBalanceById(req *types.IDReq) (*typ
 		return nil, dberrorhandler.DefaultEntError(l.Logger, err, req)
 	}
 
+	bUserinfo := types.BUserInfo{}
+	userInfo, _ := l.svcCtx.CoreRpc.GetUserById(l.ctx, &core.UUIDReq{Id: data.UserID})
+	if userInfo != nil {
+		bUserinfo.Nickname = userInfo.Nickname
+		bUserinfo.Avatar = userInfo.Avatar
+		bUserinfo.Username = userInfo.Username
+		bUserinfo.UserId = userInfo.Id
+	}
+
 	return &types.CreditBalanceInfoResp{
-	    BaseDataInfo: types.BaseDataInfo{
-            Code: 0,
-            Msg:  errormsg.Success,
-        },
-        Data: types.CreditBalanceInfo{
-            BaseIDInfo:    types.BaseIDInfo{
-				Id:          &data.ID,
-				CreatedAt:    pointy.GetPointer(data.CreatedAt.UnixMilli()),
-				UpdatedAt:    pointy.GetPointer(data.UpdatedAt.UnixMilli()),
-            },
-			UserId:	&data.UserID,
-			Balance:	&data.Balance,
-			Status:	&data.Status,
-			OrganizationId:	&data.OrganizationID,
-        },
+		BaseDataInfo: types.BaseDataInfo{
+			Code: 0,
+			Msg:  errormsg.Success,
+		},
+		Data: types.CreditBalanceInfo{
+			BaseIDInfo: types.BaseIDInfo{
+				Id:        &data.ID,
+				CreatedAt: pointy.GetPointer(data.CreatedAt.UnixMilli()),
+				UpdatedAt: pointy.GetPointer(data.UpdatedAt.UnixMilli()),
+			},
+			UserId:         &data.UserID,
+			Balance:        &data.Balance,
+			Status:         &data.Status,
+			OrganizationId: &data.OrganizationID,
+			User:           bUserinfo,
+		},
 	}, nil
 }
-

+ 10 - 0
internal/logic/credit_balance/get_credit_balance_list_logic.go

@@ -2,6 +2,7 @@ package credit_balance
 
 import (
 	"context"
+	"github.com/suyuan32/simple-admin-core/rpc/types/core"
 
 	"wechat-api/ent/creditbalance"
 	"wechat-api/ent/predicate"
@@ -48,6 +49,14 @@ func (l *GetCreditBalanceListLogic) GetCreditBalanceList(req *types.CreditBalanc
 	resp.Data.Total = data.PageDetails.Total
 
 	for _, v := range data.List {
+		bUserinfo := types.BUserInfo{}
+		userInfo, _ := l.svcCtx.CoreRpc.GetUserById(l.ctx, &core.UUIDReq{Id: v.UserID})
+		if userInfo != nil {
+			bUserinfo.Nickname = userInfo.Nickname
+			bUserinfo.Avatar = userInfo.Avatar
+			bUserinfo.Username = userInfo.Username
+			bUserinfo.UserId = userInfo.Id
+		}
 		resp.Data.Data = append(resp.Data.Data,
 			types.CreditBalanceInfo{
 				BaseIDInfo: types.BaseIDInfo{
@@ -59,6 +68,7 @@ func (l *GetCreditBalanceListLogic) GetCreditBalanceList(req *types.CreditBalanc
 				Balance:        &v.Balance,
 				Status:         &v.Status,
 				OrganizationId: &v.OrganizationID,
+				User:           bUserinfo,
 			})
 	}
 

+ 105 - 0
internal/logic/credit_balance/operate_credit_balance_logic.go

@@ -0,0 +1,105 @@
+package credit_balance
+
+import (
+	"context"
+	"github.com/suyuan32/simple-admin-common/msg/errormsg"
+	"github.com/suyuan32/simple-admin-core/rpc/types/core"
+	"github.com/zeromicro/go-zero/core/errorx"
+	"wechat-api/ent/creditbalance"
+
+	"wechat-api/internal/svc"
+	"wechat-api/internal/types"
+
+	"github.com/zeromicro/go-zero/core/logx"
+)
+
+type OperateCreditBalanceLogic struct {
+	logx.Logger
+	ctx    context.Context
+	svcCtx *svc.ServiceContext
+}
+
+func NewOperateCreditBalanceLogic(ctx context.Context, svcCtx *svc.ServiceContext) *OperateCreditBalanceLogic {
+	return &OperateCreditBalanceLogic{
+		Logger: logx.WithContext(ctx),
+		ctx:    ctx,
+		svcCtx: svcCtx}
+}
+
+func (l *OperateCreditBalanceLogic) OperateCreditBalance(req *types.CreditBalanceOperateReq) (*types.BaseMsgResp, error) {
+	if req.Number == nil || *req.Number == 0 {
+		return nil, errorx.NewInvalidArgumentError("Number参数非法")
+	}
+	if req.UserId == nil {
+		return nil, errorx.NewInvalidArgumentError("UserId参数非法")
+	}
+
+	creditBalance, err := l.svcCtx.DB.CreditBalance.Query().Where(creditbalance.UserID(*req.UserId)).Only(l.ctx)
+	if err != nil {
+		l.Logger.Errorf("query credit_balance error:%v\n", err)
+		return nil, errorx.NewInvalidArgumentError(err.Error())
+	}
+
+	var ntype int
+	if *req.Number > 0 {
+		ntype = 2
+	} else {
+		ntype = 1
+	}
+
+	userInfo, err := l.svcCtx.CoreRpc.GetUserById(l.ctx, &core.UUIDReq{Id: *req.UserId})
+	if err != nil {
+		l.Logger.Errorf("query user error:%v\n", err)
+		return nil, errorx.NewInvalidArgumentError("用户不存在")
+	}
+
+	tx, err := l.svcCtx.DB.Tx(context.Background())
+	_, err = tx.CreditUsage.Create().
+		SetUserID(*req.UserId).
+		SetNumber(*req.Number).
+		SetNtype(ntype).
+		SetNid(0).
+		SetTable("").
+		SetReason(*req.Reason).
+		SetOrganizationID(*userInfo.DepartmentId).
+		Save(l.ctx)
+	if err != nil {
+		l.Logger.Errorf("create credit_usage error:%v\n", err)
+		_ = tx.Rollback()
+		return nil, errorx.NewInvalidArgumentError("创建用户积分明细失败,请重试")
+	}
+
+	if *req.Number > 0 {
+		if creditBalance == nil {
+			_, err = l.svcCtx.DB.CreditBalance.Create().
+				SetUserID(*req.UserId).
+				SetBalance(*req.Number).
+				Save(l.ctx)
+			if err != nil {
+				l.Logger.Errorf("create credit_balance error:%v\n", err)
+				_ = tx.Rollback()
+				return nil, errorx.NewInvalidArgumentError("创建用户积分余额失败,请重试")
+			}
+		} else {
+			_, err = l.svcCtx.DB.CreditBalance.Update().Where(creditbalance.UserID(*req.UserId)).SetBalance(creditBalance.Balance + *req.Number).Save(l.ctx)
+			if err != nil {
+				l.Logger.Errorf("update credit_balance error:%v\n", err)
+				_ = tx.Rollback()
+				return nil, errorx.NewInvalidArgumentError("修改用户积分余额失败,请重试.")
+			}
+		}
+	} else {
+		_, err := l.svcCtx.DB.CreditBalance.Update().Where(creditbalance.UserID(*req.UserId)).SetBalance(creditBalance.Balance + *req.Number).Save(l.ctx)
+		if err != nil {
+			l.Logger.Errorf("update credit_balance error:%v\n", err)
+			_ = tx.Rollback()
+			return nil, errorx.NewInvalidArgumentError("修改用户积分余额失败,请重试...")
+		}
+	}
+	_ = tx.Commit()
+
+	return &types.BaseMsgResp{
+		Code: 0,
+		Msg:  errormsg.Success,
+	}, nil
+}

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

@@ -0,0 +1,55 @@
+package whatsapp
+
+import (
+	"context"
+
+	"wechat-api/internal/svc"
+	"wechat-api/internal/types"
+	"wechat-api/internal/utils/dberrorhandler"
+
+	"github.com/suyuan32/simple-admin-common/msg/errormsg"
+
+	"github.com/zeromicro/go-zero/core/logx"
+)
+
+type CreateWhatsappLogic struct {
+	ctx    context.Context
+	svcCtx *svc.ServiceContext
+	logx.Logger
+}
+
+func NewCreateWhatsappLogic(ctx context.Context, svcCtx *svc.ServiceContext) *CreateWhatsappLogic {
+	return &CreateWhatsappLogic{
+		ctx:    ctx,
+		svcCtx: svcCtx,
+		Logger: logx.WithContext(ctx),
+	}
+}
+
+func (l *CreateWhatsappLogic) CreateWhatsapp(req *types.WhatsappInfo) (*types.BaseMsgResp, error) {
+	var stringSlice []string
+
+	_, err := l.svcCtx.DB.Whatsapp.Create().
+		SetNotNilStatus(req.Status).
+		SetNotNilAk(req.Ak).
+		SetNotNilSk(req.Sk).
+		SetNotNilCallback(req.Callback).
+		SetNotNilAccount(req.Account).
+		SetNotNilNickname(req.Nickname).
+		SetNotNilPhone(req.Phone).
+		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
+}

+ 37 - 0
internal/logic/whatsapp/delete_whatsapp_logic.go

@@ -0,0 +1,37 @@
+package whatsapp
+
+import (
+	"context"
+
+    "wechat-api/ent/whatsapp"
+    "wechat-api/internal/svc"
+    "wechat-api/internal/types"
+    "wechat-api/internal/utils/dberrorhandler"
+
+    "github.com/suyuan32/simple-admin-common/msg/errormsg"
+    "github.com/zeromicro/go-zero/core/logx"
+)
+
+type DeleteWhatsappLogic struct {
+	ctx    context.Context
+	svcCtx *svc.ServiceContext
+	logx.Logger
+}
+
+func NewDeleteWhatsappLogic(ctx context.Context, svcCtx *svc.ServiceContext) *DeleteWhatsappLogic {
+	return &DeleteWhatsappLogic{
+		ctx:    ctx,
+		svcCtx: svcCtx,
+		Logger: logx.WithContext(ctx),
+	}
+}
+
+func (l *DeleteWhatsappLogic) DeleteWhatsapp(req *types.IDsReq) (*types.BaseMsgResp, error) {
+	_, err := l.svcCtx.DB.Whatsapp.Delete().Where(whatsapp.IDIn(req.Ids...)).Exec(l.ctx)
+
+    if err != nil {
+		return nil, dberrorhandler.DefaultEntError(l.Logger, err, req)
+	}
+
+    return &types.BaseMsgResp{Msg: errormsg.DeleteSuccess}, nil
+}

+ 60 - 0
internal/logic/whatsapp/get_whatsapp_by_id_logic.go

@@ -0,0 +1,60 @@
+package whatsapp
+
+import (
+	"context"
+
+	"wechat-api/internal/svc"
+	"wechat-api/internal/types"
+	"wechat-api/internal/utils/dberrorhandler"
+
+	"github.com/suyuan32/simple-admin-common/msg/errormsg"
+
+	"github.com/suyuan32/simple-admin-common/utils/pointy"
+	"github.com/zeromicro/go-zero/core/logx"
+)
+
+type GetWhatsappByIdLogic struct {
+	ctx    context.Context
+	svcCtx *svc.ServiceContext
+	logx.Logger
+}
+
+func NewGetWhatsappByIdLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetWhatsappByIdLogic {
+	return &GetWhatsappByIdLogic{
+		ctx:    ctx,
+		svcCtx: svcCtx,
+		Logger: logx.WithContext(ctx),
+	}
+}
+
+func (l *GetWhatsappByIdLogic) GetWhatsappById(req *types.IDReq) (*types.WhatsappInfoResp, error) {
+	data, err := l.svcCtx.DB.Whatsapp.Get(l.ctx, req.Id)
+	if err != nil {
+		return nil, dberrorhandler.DefaultEntError(l.Logger, err, req)
+	}
+
+	return &types.WhatsappInfoResp{
+		BaseDataInfo: types.BaseDataInfo{
+			Code: 0,
+			Msg:  errormsg.Success,
+		},
+		Data: types.WhatsappInfo{
+			BaseIDInfo: types.BaseIDInfo{
+				Id:        &data.ID,
+				CreatedAt: pointy.GetPointer(data.CreatedAt.UnixMilli()),
+				UpdatedAt: pointy.GetPointer(data.UpdatedAt.UnixMilli()),
+			},
+			Status:         &data.Status,
+			Ak:             &data.Ak,
+			Sk:             &data.Sk,
+			Callback:       &data.Callback,
+			Account:        &data.Account,
+			Nickname:       &data.Nickname,
+			Phone:          &data.Phone,
+			OrganizationId: &data.OrganizationID,
+			AgentId:        &data.AgentID,
+			ApiBase:        &data.APIBase,
+			ApiKey:         &data.APIKey,
+		},
+	}, nil
+}

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

@@ -0,0 +1,76 @@
+package whatsapp
+
+import (
+	"context"
+
+	"wechat-api/ent/predicate"
+	"wechat-api/ent/whatsapp"
+	"wechat-api/internal/svc"
+	"wechat-api/internal/types"
+	"wechat-api/internal/utils/dberrorhandler"
+
+	"github.com/suyuan32/simple-admin-common/msg/errormsg"
+
+	"github.com/suyuan32/simple-admin-common/utils/pointy"
+	"github.com/zeromicro/go-zero/core/logx"
+)
+
+type GetWhatsappListLogic struct {
+	ctx    context.Context
+	svcCtx *svc.ServiceContext
+	logx.Logger
+}
+
+func NewGetWhatsappListLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetWhatsappListLogic {
+	return &GetWhatsappListLogic{
+		ctx:    ctx,
+		svcCtx: svcCtx,
+		Logger: logx.WithContext(ctx),
+	}
+}
+
+func (l *GetWhatsappListLogic) GetWhatsappList(req *types.WhatsappListReq) (*types.WhatsappListResp, error) {
+	var predicates []predicate.Whatsapp
+	if req.Ak != nil {
+		predicates = append(predicates, whatsapp.AkContains(*req.Ak))
+	}
+	if req.Sk != nil {
+		predicates = append(predicates, whatsapp.SkContains(*req.Sk))
+	}
+	if req.Callback != nil {
+		predicates = append(predicates, whatsapp.CallbackContains(*req.Callback))
+	}
+	data, err := l.svcCtx.DB.Whatsapp.Query().Where(predicates...).Page(l.ctx, req.Page, req.PageSize)
+
+	if err != nil {
+		return nil, dberrorhandler.DefaultEntError(l.Logger, err, req)
+	}
+
+	resp := &types.WhatsappListResp{}
+	resp.Msg = errormsg.Success
+	resp.Data.Total = data.PageDetails.Total
+
+	for _, v := range data.List {
+		resp.Data.Data = append(resp.Data.Data,
+			types.WhatsappInfo{
+				BaseIDInfo: types.BaseIDInfo{
+					Id:        &v.ID,
+					CreatedAt: pointy.GetPointer(v.CreatedAt.UnixMilli()),
+					UpdatedAt: pointy.GetPointer(v.UpdatedAt.UnixMilli()),
+				},
+				Status:         &v.Status,
+				Ak:             &v.Ak,
+				Sk:             &v.Sk,
+				Callback:       &v.Callback,
+				Account:        &v.Account,
+				Nickname:       &v.Nickname,
+				Phone:          &v.Phone,
+				OrganizationId: &v.OrganizationID,
+				AgentId:        &v.AgentID,
+				ApiBase:        &v.APIBase,
+				ApiKey:         &v.APIKey,
+			})
+	}
+
+	return resp, nil
+}

+ 48 - 0
internal/logic/whatsapp/update_whatsapp_logic.go

@@ -0,0 +1,48 @@
+package whatsapp
+
+import (
+	"context"
+
+	"wechat-api/internal/svc"
+	"wechat-api/internal/types"
+	"wechat-api/internal/utils/dberrorhandler"
+
+	"github.com/suyuan32/simple-admin-common/msg/errormsg"
+	"github.com/zeromicro/go-zero/core/logx"
+)
+
+type UpdateWhatsappLogic struct {
+	ctx    context.Context
+	svcCtx *svc.ServiceContext
+	logx.Logger
+}
+
+func NewUpdateWhatsappLogic(ctx context.Context, svcCtx *svc.ServiceContext) *UpdateWhatsappLogic {
+	return &UpdateWhatsappLogic{
+		ctx:    ctx,
+		svcCtx: svcCtx,
+		Logger: logx.WithContext(ctx),
+	}
+}
+
+func (l *UpdateWhatsappLogic) UpdateWhatsapp(req *types.WhatsappInfo) (*types.BaseMsgResp, error) {
+	err := l.svcCtx.DB.Whatsapp.UpdateOneID(*req.Id).
+		SetNotNilStatus(req.Status).
+		SetNotNilAk(req.Ak).
+		SetNotNilSk(req.Sk).
+		SetNotNilCallback(req.Callback).
+		SetNotNilAccount(req.Account).
+		SetNotNilNickname(req.Nickname).
+		SetNotNilPhone(req.Phone).
+		SetNotNilOrganizationID(req.OrganizationId).
+		SetNotNilAgentID(req.AgentId).
+		SetNotNilAPIBase(req.ApiBase).
+		SetNotNilAPIKey(req.ApiKey).
+		Exec(l.ctx)
+
+	if err != nil {
+		return nil, dberrorhandler.DefaultEntError(l.Logger, err, req)
+	}
+
+	return &types.BaseMsgResp{Msg: errormsg.UpdateSuccess}, nil
+}

+ 98 - 1
internal/types/types.go

@@ -3036,6 +3036,12 @@ type UsageDetailListReq struct {
 	BotId *string `json:"botId,optional"`
 }
 
+// swagger:model UsageDetailResp
+type UsageDetailResp struct {
+	BaseDataInfo
+	Data UsageDetailInfo `json:"data"`
+}
+
 // The response data of UsageTotal information | UsageTotal信息
 // swagger:model UsageTotalInfo
 type UsageTotalInfo struct {
@@ -3248,7 +3254,19 @@ type CreditBalanceInfo struct {
 	// status | 状态 1-正常 2-禁用
 	Status *int `json:"status,optional"`
 	// organization_id | 租户ID
-	OrganizationId *uint64 `json:"organizationId,optional"`
+	OrganizationId *uint64   `json:"organizationId,optional"`
+	User           BUserInfo `json:"user,optional"`
+}
+
+// swagger:model BUserInfo
+type BUserInfo struct {
+	UserId *string `json:"userId,optional"`
+	// User's name | 用户名
+	Username *string `json:"username,optional"`
+	// User's nickname | 用户的昵称
+	Nickname *string `json:"nickname,optional"`
+	// The user's avatar path | 用户的头像路径
+	Avatar *string `json:"avatar,optional"`
 }
 
 // The response data of credit balance list | CreditBalance列表数据
@@ -3284,6 +3302,13 @@ type CreditBalanceInfoResp struct {
 	Data CreditBalanceInfo `json:"data"`
 }
 
+// swagger:model CreditBalanceOperateReq
+type CreditBalanceOperateReq struct {
+	UserId *string  `json:"userId,optional"`
+	Number *float32 `json:"number,optional"`
+	Reason *string  `json:"reason,optional"`
+}
+
 // The data of credit usage information | CreditUsage信息
 // swagger:model CreditUsageInfo
 type CreditUsageInfo struct {
@@ -3395,3 +3420,75 @@ type PayRechargeInfoResp struct {
 	// PayRecharge information | PayRecharge数据
 	Data PayRechargeInfo `json:"data"`
 }
+
+// The data of whatsapp information | Whatsapp信息
+// swagger:model WhatsappInfo
+type WhatsappInfo struct {
+	BaseIDInfo
+	// Status 1: normal 2: ban | 状态 1 正常 2 禁用
+	Status *uint8 `json:"status,optional"`
+	// ak
+	Ak *string `json:"ak,optional"`
+	// 端口号
+	Sk *string `json:"sk,optional"`
+	// 回调地址
+	Callback *string `json:"callback,optional"`
+	// 微信账号
+	Account *string `json:"account,optional"`
+	// 昵称
+	Nickname *string `json:"nickname,optional"`
+	// 手机号
+	Phone *string `json:"phone,optional"`
+	// 机构 ID
+	OrganizationId *uint64 `json:"organizationId,optional"`
+	// 模式ID
+	AgentId *uint64 `json:"agentId,optional"`
+	// 大模型服务地址
+	ApiBase *string `json:"apiBase,optional"`
+	// 大模型服务密钥
+	ApiKey *string `json:"apiKey,optional"`
+	// 白名单
+	AllowList []ContactInfo `json:"allowList,optional"`
+	// 群白名单
+	GroupAllowList []ContactInfo `json:"groupAllowList,optional"`
+	// 黑名单
+	BlockList []ContactInfo `json:"blockList,optional"`
+	// 群黑名单
+	GroupBlockList []ContactInfo `json:"groupBlockList,optional"`
+}
+
+// The response data of whatsapp list | Whatsapp列表数据
+// swagger:model WhatsappListResp
+type WhatsappListResp struct {
+	BaseDataInfo
+	// Whatsapp list data | Whatsapp列表数据
+	Data WhatsappListInfo `json:"data"`
+}
+
+// Whatsapp list data | Whatsapp列表数据
+// swagger:model WhatsappListInfo
+type WhatsappListInfo struct {
+	BaseListInfo
+	// The API list data | Whatsapp列表数据
+	Data []WhatsappInfo `json:"data"`
+}
+
+// Get whatsapp list request params | Whatsapp列表请求参数
+// swagger:model WhatsappListReq
+type WhatsappListReq struct {
+	PageInfo
+	// ak
+	Ak *string `json:"ak,optional"`
+	// 端口号
+	Sk *string `json:"sk,optional"`
+	// 回调地址
+	Callback *string `json:"callback,optional"`
+}
+
+// Whatsapp information response | Whatsapp信息返回体
+// swagger:model WhatsappInfoResp
+type WhatsappInfoResp struct {
+	BaseDataInfo
+	// Whatsapp information | Whatsapp数据
+	Data WhatsappInfo `json:"data"`
+}