|
@@ -20,6 +20,8 @@ import (
|
|
"wechat-api/ent/chatrecords"
|
|
"wechat-api/ent/chatrecords"
|
|
"wechat-api/ent/chatsession"
|
|
"wechat-api/ent/chatsession"
|
|
"wechat-api/ent/contact"
|
|
"wechat-api/ent/contact"
|
|
|
|
+ "wechat-api/ent/creditbalance"
|
|
|
|
+ "wechat-api/ent/creditusage"
|
|
"wechat-api/ent/employee"
|
|
"wechat-api/ent/employee"
|
|
"wechat-api/ent/employeeconfig"
|
|
"wechat-api/ent/employeeconfig"
|
|
"wechat-api/ent/label"
|
|
"wechat-api/ent/label"
|
|
@@ -28,6 +30,7 @@ import (
|
|
"wechat-api/ent/message"
|
|
"wechat-api/ent/message"
|
|
"wechat-api/ent/messagerecords"
|
|
"wechat-api/ent/messagerecords"
|
|
"wechat-api/ent/msg"
|
|
"wechat-api/ent/msg"
|
|
|
|
+ "wechat-api/ent/payrecharge"
|
|
"wechat-api/ent/server"
|
|
"wechat-api/ent/server"
|
|
"wechat-api/ent/sopnode"
|
|
"wechat-api/ent/sopnode"
|
|
"wechat-api/ent/sopstage"
|
|
"wechat-api/ent/sopstage"
|
|
@@ -78,6 +81,10 @@ type Client struct {
|
|
ChatSession *ChatSessionClient
|
|
ChatSession *ChatSessionClient
|
|
// Contact is the client for interacting with the Contact builders.
|
|
// Contact is the client for interacting with the Contact builders.
|
|
Contact *ContactClient
|
|
Contact *ContactClient
|
|
|
|
+ // CreditBalance is the client for interacting with the CreditBalance builders.
|
|
|
|
+ CreditBalance *CreditBalanceClient
|
|
|
|
+ // CreditUsage is the client for interacting with the CreditUsage builders.
|
|
|
|
+ CreditUsage *CreditUsageClient
|
|
// Employee is the client for interacting with the Employee builders.
|
|
// Employee is the client for interacting with the Employee builders.
|
|
Employee *EmployeeClient
|
|
Employee *EmployeeClient
|
|
// EmployeeConfig is the client for interacting with the EmployeeConfig builders.
|
|
// EmployeeConfig is the client for interacting with the EmployeeConfig builders.
|
|
@@ -94,6 +101,8 @@ type Client struct {
|
|
MessageRecords *MessageRecordsClient
|
|
MessageRecords *MessageRecordsClient
|
|
// Msg is the client for interacting with the Msg builders.
|
|
// Msg is the client for interacting with the Msg builders.
|
|
Msg *MsgClient
|
|
Msg *MsgClient
|
|
|
|
+ // PayRecharge is the client for interacting with the PayRecharge builders.
|
|
|
|
+ PayRecharge *PayRechargeClient
|
|
// Server is the client for interacting with the Server builders.
|
|
// Server is the client for interacting with the Server builders.
|
|
Server *ServerClient
|
|
Server *ServerClient
|
|
// SopNode is the client for interacting with the SopNode builders.
|
|
// SopNode is the client for interacting with the SopNode builders.
|
|
@@ -150,6 +159,8 @@ func (c *Client) init() {
|
|
c.ChatRecords = NewChatRecordsClient(c.config)
|
|
c.ChatRecords = NewChatRecordsClient(c.config)
|
|
c.ChatSession = NewChatSessionClient(c.config)
|
|
c.ChatSession = NewChatSessionClient(c.config)
|
|
c.Contact = NewContactClient(c.config)
|
|
c.Contact = NewContactClient(c.config)
|
|
|
|
+ c.CreditBalance = NewCreditBalanceClient(c.config)
|
|
|
|
+ c.CreditUsage = NewCreditUsageClient(c.config)
|
|
c.Employee = NewEmployeeClient(c.config)
|
|
c.Employee = NewEmployeeClient(c.config)
|
|
c.EmployeeConfig = NewEmployeeConfigClient(c.config)
|
|
c.EmployeeConfig = NewEmployeeConfigClient(c.config)
|
|
c.Label = NewLabelClient(c.config)
|
|
c.Label = NewLabelClient(c.config)
|
|
@@ -158,6 +169,7 @@ func (c *Client) init() {
|
|
c.Message = NewMessageClient(c.config)
|
|
c.Message = NewMessageClient(c.config)
|
|
c.MessageRecords = NewMessageRecordsClient(c.config)
|
|
c.MessageRecords = NewMessageRecordsClient(c.config)
|
|
c.Msg = NewMsgClient(c.config)
|
|
c.Msg = NewMsgClient(c.config)
|
|
|
|
+ c.PayRecharge = NewPayRechargeClient(c.config)
|
|
c.Server = NewServerClient(c.config)
|
|
c.Server = NewServerClient(c.config)
|
|
c.SopNode = NewSopNodeClient(c.config)
|
|
c.SopNode = NewSopNodeClient(c.config)
|
|
c.SopStage = NewSopStageClient(c.config)
|
|
c.SopStage = NewSopStageClient(c.config)
|
|
@@ -277,6 +289,8 @@ func (c *Client) Tx(ctx context.Context) (*Tx, error) {
|
|
ChatRecords: NewChatRecordsClient(cfg),
|
|
ChatRecords: NewChatRecordsClient(cfg),
|
|
ChatSession: NewChatSessionClient(cfg),
|
|
ChatSession: NewChatSessionClient(cfg),
|
|
Contact: NewContactClient(cfg),
|
|
Contact: NewContactClient(cfg),
|
|
|
|
+ CreditBalance: NewCreditBalanceClient(cfg),
|
|
|
|
+ CreditUsage: NewCreditUsageClient(cfg),
|
|
Employee: NewEmployeeClient(cfg),
|
|
Employee: NewEmployeeClient(cfg),
|
|
EmployeeConfig: NewEmployeeConfigClient(cfg),
|
|
EmployeeConfig: NewEmployeeConfigClient(cfg),
|
|
Label: NewLabelClient(cfg),
|
|
Label: NewLabelClient(cfg),
|
|
@@ -285,6 +299,7 @@ func (c *Client) Tx(ctx context.Context) (*Tx, error) {
|
|
Message: NewMessageClient(cfg),
|
|
Message: NewMessageClient(cfg),
|
|
MessageRecords: NewMessageRecordsClient(cfg),
|
|
MessageRecords: NewMessageRecordsClient(cfg),
|
|
Msg: NewMsgClient(cfg),
|
|
Msg: NewMsgClient(cfg),
|
|
|
|
+ PayRecharge: NewPayRechargeClient(cfg),
|
|
Server: NewServerClient(cfg),
|
|
Server: NewServerClient(cfg),
|
|
SopNode: NewSopNodeClient(cfg),
|
|
SopNode: NewSopNodeClient(cfg),
|
|
SopStage: NewSopStageClient(cfg),
|
|
SopStage: NewSopStageClient(cfg),
|
|
@@ -331,6 +346,8 @@ func (c *Client) BeginTx(ctx context.Context, opts *sql.TxOptions) (*Tx, error)
|
|
ChatRecords: NewChatRecordsClient(cfg),
|
|
ChatRecords: NewChatRecordsClient(cfg),
|
|
ChatSession: NewChatSessionClient(cfg),
|
|
ChatSession: NewChatSessionClient(cfg),
|
|
Contact: NewContactClient(cfg),
|
|
Contact: NewContactClient(cfg),
|
|
|
|
+ CreditBalance: NewCreditBalanceClient(cfg),
|
|
|
|
+ CreditUsage: NewCreditUsageClient(cfg),
|
|
Employee: NewEmployeeClient(cfg),
|
|
Employee: NewEmployeeClient(cfg),
|
|
EmployeeConfig: NewEmployeeConfigClient(cfg),
|
|
EmployeeConfig: NewEmployeeConfigClient(cfg),
|
|
Label: NewLabelClient(cfg),
|
|
Label: NewLabelClient(cfg),
|
|
@@ -339,6 +356,7 @@ func (c *Client) BeginTx(ctx context.Context, opts *sql.TxOptions) (*Tx, error)
|
|
Message: NewMessageClient(cfg),
|
|
Message: NewMessageClient(cfg),
|
|
MessageRecords: NewMessageRecordsClient(cfg),
|
|
MessageRecords: NewMessageRecordsClient(cfg),
|
|
Msg: NewMsgClient(cfg),
|
|
Msg: NewMsgClient(cfg),
|
|
|
|
+ PayRecharge: NewPayRechargeClient(cfg),
|
|
Server: NewServerClient(cfg),
|
|
Server: NewServerClient(cfg),
|
|
SopNode: NewSopNodeClient(cfg),
|
|
SopNode: NewSopNodeClient(cfg),
|
|
SopStage: NewSopStageClient(cfg),
|
|
SopStage: NewSopStageClient(cfg),
|
|
@@ -387,8 +405,9 @@ func (c *Client) Close() error {
|
|
func (c *Client) Use(hooks ...Hook) {
|
|
func (c *Client) Use(hooks ...Hook) {
|
|
for _, n := range []interface{ Use(...Hook) }{
|
|
for _, n := range []interface{ Use(...Hook) }{
|
|
c.Agent, c.AgentBase, c.AliyunAvatar, c.AllocAgent, c.BatchMsg, c.Category,
|
|
c.Agent, c.AgentBase, c.AliyunAvatar, c.AllocAgent, c.BatchMsg, c.Category,
|
|
- c.ChatRecords, c.ChatSession, c.Contact, c.Employee, c.EmployeeConfig, c.Label,
|
|
|
|
- c.LabelRelationship, c.LabelTagging, c.Message, c.MessageRecords, c.Msg,
|
|
|
|
|
|
+ c.ChatRecords, c.ChatSession, c.Contact, c.CreditBalance, c.CreditUsage,
|
|
|
|
+ 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.Server, c.SopNode, c.SopStage, c.SopTask, c.Token, c.Tutorial, c.UsageDetail,
|
|
c.UsageStatisticDay, c.UsageStatisticHour, c.UsageStatisticMonth, c.UsageTotal, c.WorkExperience,
|
|
c.UsageStatisticDay, c.UsageStatisticHour, c.UsageStatisticMonth, c.UsageTotal, c.WorkExperience,
|
|
c.WpChatroom, c.WpChatroomMember, c.Wx, c.WxCard, c.WxCardUser, c.WxCardVisit,
|
|
c.WpChatroom, c.WpChatroomMember, c.Wx, c.WxCard, c.WxCardUser, c.WxCardVisit,
|
|
@@ -402,8 +421,10 @@ func (c *Client) Use(hooks ...Hook) {
|
|
func (c *Client) Intercept(interceptors ...Interceptor) {
|
|
func (c *Client) Intercept(interceptors ...Interceptor) {
|
|
for _, n := range []interface{ Intercept(...Interceptor) }{
|
|
for _, n := range []interface{ Intercept(...Interceptor) }{
|
|
c.Agent, c.AgentBase, c.AliyunAvatar, c.AllocAgent, c.BatchMsg, c.Category,
|
|
c.Agent, c.AgentBase, c.AliyunAvatar, c.AllocAgent, c.BatchMsg, c.Category,
|
|
- c.ChatRecords, c.ChatSession, c.Contact, c.Employee, c.EmployeeConfig, c.Label,
|
|
|
|
|
|
+ c.ChatRecords, c.ChatSession, c.Contact, c.CreditBalance, c.CreditUsage,
|
|
|
|
+ c.Employee, c.EmployeeConfig, c.Label,
|
|
c.LabelRelationship, c.LabelTagging, c.Message, c.MessageRecords, c.Msg,
|
|
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.Server, c.SopNode, c.SopStage, c.SopTask, c.Token, c.Tutorial, c.UsageDetail,
|
|
c.UsageStatisticDay, c.UsageStatisticHour, c.UsageStatisticMonth, c.UsageTotal, c.WorkExperience,
|
|
c.UsageStatisticDay, c.UsageStatisticHour, c.UsageStatisticMonth, c.UsageTotal, c.WorkExperience,
|
|
c.WpChatroom, c.WpChatroomMember, c.Wx, c.WxCard, c.WxCardUser, c.WxCardVisit,
|
|
c.WpChatroom, c.WpChatroomMember, c.Wx, c.WxCard, c.WxCardUser, c.WxCardVisit,
|
|
@@ -433,6 +454,10 @@ func (c *Client) Mutate(ctx context.Context, m Mutation) (Value, error) {
|
|
return c.ChatSession.mutate(ctx, m)
|
|
return c.ChatSession.mutate(ctx, m)
|
|
case *ContactMutation:
|
|
case *ContactMutation:
|
|
return c.Contact.mutate(ctx, m)
|
|
return c.Contact.mutate(ctx, m)
|
|
|
|
+ case *CreditBalanceMutation:
|
|
|
|
+ return c.CreditBalance.mutate(ctx, m)
|
|
|
|
+ case *CreditUsageMutation:
|
|
|
|
+ return c.CreditUsage.mutate(ctx, m)
|
|
case *EmployeeMutation:
|
|
case *EmployeeMutation:
|
|
return c.Employee.mutate(ctx, m)
|
|
return c.Employee.mutate(ctx, m)
|
|
case *EmployeeConfigMutation:
|
|
case *EmployeeConfigMutation:
|
|
@@ -449,6 +474,8 @@ func (c *Client) Mutate(ctx context.Context, m Mutation) (Value, error) {
|
|
return c.MessageRecords.mutate(ctx, m)
|
|
return c.MessageRecords.mutate(ctx, m)
|
|
case *MsgMutation:
|
|
case *MsgMutation:
|
|
return c.Msg.mutate(ctx, m)
|
|
return c.Msg.mutate(ctx, m)
|
|
|
|
+ case *PayRechargeMutation:
|
|
|
|
+ return c.PayRecharge.mutate(ctx, m)
|
|
case *ServerMutation:
|
|
case *ServerMutation:
|
|
return c.Server.mutate(ctx, m)
|
|
return c.Server.mutate(ctx, m)
|
|
case *SopNodeMutation:
|
|
case *SopNodeMutation:
|
|
@@ -1783,6 +1810,276 @@ func (c *ContactClient) mutate(ctx context.Context, m *ContactMutation) (Value,
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+// CreditBalanceClient is a client for the CreditBalance schema.
|
|
|
|
+type CreditBalanceClient struct {
|
|
|
|
+ config
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+// NewCreditBalanceClient returns a client for the CreditBalance from the given config.
|
|
|
|
+func NewCreditBalanceClient(c config) *CreditBalanceClient {
|
|
|
|
+ return &CreditBalanceClient{config: c}
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+// Use adds a list of mutation hooks to the hooks stack.
|
|
|
|
+// A call to `Use(f, g, h)` equals to `creditbalance.Hooks(f(g(h())))`.
|
|
|
|
+func (c *CreditBalanceClient) Use(hooks ...Hook) {
|
|
|
|
+ c.hooks.CreditBalance = append(c.hooks.CreditBalance, hooks...)
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+// Intercept adds a list of query interceptors to the interceptors stack.
|
|
|
|
+// A call to `Intercept(f, g, h)` equals to `creditbalance.Intercept(f(g(h())))`.
|
|
|
|
+func (c *CreditBalanceClient) Intercept(interceptors ...Interceptor) {
|
|
|
|
+ c.inters.CreditBalance = append(c.inters.CreditBalance, interceptors...)
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+// Create returns a builder for creating a CreditBalance entity.
|
|
|
|
+func (c *CreditBalanceClient) Create() *CreditBalanceCreate {
|
|
|
|
+ mutation := newCreditBalanceMutation(c.config, OpCreate)
|
|
|
|
+ return &CreditBalanceCreate{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+// CreateBulk returns a builder for creating a bulk of CreditBalance entities.
|
|
|
|
+func (c *CreditBalanceClient) CreateBulk(builders ...*CreditBalanceCreate) *CreditBalanceCreateBulk {
|
|
|
|
+ return &CreditBalanceCreateBulk{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 *CreditBalanceClient) MapCreateBulk(slice any, setFunc func(*CreditBalanceCreate, int)) *CreditBalanceCreateBulk {
|
|
|
|
+ rv := reflect.ValueOf(slice)
|
|
|
|
+ if rv.Kind() != reflect.Slice {
|
|
|
|
+ return &CreditBalanceCreateBulk{err: fmt.Errorf("calling to CreditBalanceClient.MapCreateBulk with wrong type %T, need slice", slice)}
|
|
|
|
+ }
|
|
|
|
+ builders := make([]*CreditBalanceCreate, rv.Len())
|
|
|
|
+ for i := 0; i < rv.Len(); i++ {
|
|
|
|
+ builders[i] = c.Create()
|
|
|
|
+ setFunc(builders[i], i)
|
|
|
|
+ }
|
|
|
|
+ return &CreditBalanceCreateBulk{config: c.config, builders: builders}
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+// Update returns an update builder for CreditBalance.
|
|
|
|
+func (c *CreditBalanceClient) Update() *CreditBalanceUpdate {
|
|
|
|
+ mutation := newCreditBalanceMutation(c.config, OpUpdate)
|
|
|
|
+ return &CreditBalanceUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+// UpdateOne returns an update builder for the given entity.
|
|
|
|
+func (c *CreditBalanceClient) UpdateOne(cb *CreditBalance) *CreditBalanceUpdateOne {
|
|
|
|
+ mutation := newCreditBalanceMutation(c.config, OpUpdateOne, withCreditBalance(cb))
|
|
|
|
+ return &CreditBalanceUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+// UpdateOneID returns an update builder for the given id.
|
|
|
|
+func (c *CreditBalanceClient) UpdateOneID(id uint64) *CreditBalanceUpdateOne {
|
|
|
|
+ mutation := newCreditBalanceMutation(c.config, OpUpdateOne, withCreditBalanceID(id))
|
|
|
|
+ return &CreditBalanceUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+// Delete returns a delete builder for CreditBalance.
|
|
|
|
+func (c *CreditBalanceClient) Delete() *CreditBalanceDelete {
|
|
|
|
+ mutation := newCreditBalanceMutation(c.config, OpDelete)
|
|
|
|
+ return &CreditBalanceDelete{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+// DeleteOne returns a builder for deleting the given entity.
|
|
|
|
+func (c *CreditBalanceClient) DeleteOne(cb *CreditBalance) *CreditBalanceDeleteOne {
|
|
|
|
+ return c.DeleteOneID(cb.ID)
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+// DeleteOneID returns a builder for deleting the given entity by its id.
|
|
|
|
+func (c *CreditBalanceClient) DeleteOneID(id uint64) *CreditBalanceDeleteOne {
|
|
|
|
+ builder := c.Delete().Where(creditbalance.ID(id))
|
|
|
|
+ builder.mutation.id = &id
|
|
|
|
+ builder.mutation.op = OpDeleteOne
|
|
|
|
+ return &CreditBalanceDeleteOne{builder}
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+// Query returns a query builder for CreditBalance.
|
|
|
|
+func (c *CreditBalanceClient) Query() *CreditBalanceQuery {
|
|
|
|
+ return &CreditBalanceQuery{
|
|
|
|
+ config: c.config,
|
|
|
|
+ ctx: &QueryContext{Type: TypeCreditBalance},
|
|
|
|
+ inters: c.Interceptors(),
|
|
|
|
+ }
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+// Get returns a CreditBalance entity by its id.
|
|
|
|
+func (c *CreditBalanceClient) Get(ctx context.Context, id uint64) (*CreditBalance, error) {
|
|
|
|
+ return c.Query().Where(creditbalance.ID(id)).Only(ctx)
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+// GetX is like Get, but panics if an error occurs.
|
|
|
|
+func (c *CreditBalanceClient) GetX(ctx context.Context, id uint64) *CreditBalance {
|
|
|
|
+ obj, err := c.Get(ctx, id)
|
|
|
|
+ if err != nil {
|
|
|
|
+ panic(err)
|
|
|
|
+ }
|
|
|
|
+ return obj
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+// Hooks returns the client hooks.
|
|
|
|
+func (c *CreditBalanceClient) Hooks() []Hook {
|
|
|
|
+ hooks := c.hooks.CreditBalance
|
|
|
|
+ return append(hooks[:len(hooks):len(hooks)], creditbalance.Hooks[:]...)
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+// Interceptors returns the client interceptors.
|
|
|
|
+func (c *CreditBalanceClient) Interceptors() []Interceptor {
|
|
|
|
+ inters := c.inters.CreditBalance
|
|
|
|
+ return append(inters[:len(inters):len(inters)], creditbalance.Interceptors[:]...)
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+func (c *CreditBalanceClient) mutate(ctx context.Context, m *CreditBalanceMutation) (Value, error) {
|
|
|
|
+ switch m.Op() {
|
|
|
|
+ case OpCreate:
|
|
|
|
+ return (&CreditBalanceCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
|
|
|
|
+ case OpUpdate:
|
|
|
|
+ return (&CreditBalanceUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
|
|
|
|
+ case OpUpdateOne:
|
|
|
|
+ return (&CreditBalanceUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
|
|
|
|
+ case OpDelete, OpDeleteOne:
|
|
|
|
+ return (&CreditBalanceDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx)
|
|
|
|
+ default:
|
|
|
|
+ return nil, fmt.Errorf("ent: unknown CreditBalance mutation op: %q", m.Op())
|
|
|
|
+ }
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+// CreditUsageClient is a client for the CreditUsage schema.
|
|
|
|
+type CreditUsageClient struct {
|
|
|
|
+ config
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+// NewCreditUsageClient returns a client for the CreditUsage from the given config.
|
|
|
|
+func NewCreditUsageClient(c config) *CreditUsageClient {
|
|
|
|
+ return &CreditUsageClient{config: c}
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+// Use adds a list of mutation hooks to the hooks stack.
|
|
|
|
+// A call to `Use(f, g, h)` equals to `creditusage.Hooks(f(g(h())))`.
|
|
|
|
+func (c *CreditUsageClient) Use(hooks ...Hook) {
|
|
|
|
+ c.hooks.CreditUsage = append(c.hooks.CreditUsage, hooks...)
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+// Intercept adds a list of query interceptors to the interceptors stack.
|
|
|
|
+// A call to `Intercept(f, g, h)` equals to `creditusage.Intercept(f(g(h())))`.
|
|
|
|
+func (c *CreditUsageClient) Intercept(interceptors ...Interceptor) {
|
|
|
|
+ c.inters.CreditUsage = append(c.inters.CreditUsage, interceptors...)
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+// Create returns a builder for creating a CreditUsage entity.
|
|
|
|
+func (c *CreditUsageClient) Create() *CreditUsageCreate {
|
|
|
|
+ mutation := newCreditUsageMutation(c.config, OpCreate)
|
|
|
|
+ return &CreditUsageCreate{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+// CreateBulk returns a builder for creating a bulk of CreditUsage entities.
|
|
|
|
+func (c *CreditUsageClient) CreateBulk(builders ...*CreditUsageCreate) *CreditUsageCreateBulk {
|
|
|
|
+ return &CreditUsageCreateBulk{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 *CreditUsageClient) MapCreateBulk(slice any, setFunc func(*CreditUsageCreate, int)) *CreditUsageCreateBulk {
|
|
|
|
+ rv := reflect.ValueOf(slice)
|
|
|
|
+ if rv.Kind() != reflect.Slice {
|
|
|
|
+ return &CreditUsageCreateBulk{err: fmt.Errorf("calling to CreditUsageClient.MapCreateBulk with wrong type %T, need slice", slice)}
|
|
|
|
+ }
|
|
|
|
+ builders := make([]*CreditUsageCreate, rv.Len())
|
|
|
|
+ for i := 0; i < rv.Len(); i++ {
|
|
|
|
+ builders[i] = c.Create()
|
|
|
|
+ setFunc(builders[i], i)
|
|
|
|
+ }
|
|
|
|
+ return &CreditUsageCreateBulk{config: c.config, builders: builders}
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+// Update returns an update builder for CreditUsage.
|
|
|
|
+func (c *CreditUsageClient) Update() *CreditUsageUpdate {
|
|
|
|
+ mutation := newCreditUsageMutation(c.config, OpUpdate)
|
|
|
|
+ return &CreditUsageUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+// UpdateOne returns an update builder for the given entity.
|
|
|
|
+func (c *CreditUsageClient) UpdateOne(cu *CreditUsage) *CreditUsageUpdateOne {
|
|
|
|
+ mutation := newCreditUsageMutation(c.config, OpUpdateOne, withCreditUsage(cu))
|
|
|
|
+ return &CreditUsageUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+// UpdateOneID returns an update builder for the given id.
|
|
|
|
+func (c *CreditUsageClient) UpdateOneID(id uint64) *CreditUsageUpdateOne {
|
|
|
|
+ mutation := newCreditUsageMutation(c.config, OpUpdateOne, withCreditUsageID(id))
|
|
|
|
+ return &CreditUsageUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+// Delete returns a delete builder for CreditUsage.
|
|
|
|
+func (c *CreditUsageClient) Delete() *CreditUsageDelete {
|
|
|
|
+ mutation := newCreditUsageMutation(c.config, OpDelete)
|
|
|
|
+ return &CreditUsageDelete{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+// DeleteOne returns a builder for deleting the given entity.
|
|
|
|
+func (c *CreditUsageClient) DeleteOne(cu *CreditUsage) *CreditUsageDeleteOne {
|
|
|
|
+ return c.DeleteOneID(cu.ID)
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+// DeleteOneID returns a builder for deleting the given entity by its id.
|
|
|
|
+func (c *CreditUsageClient) DeleteOneID(id uint64) *CreditUsageDeleteOne {
|
|
|
|
+ builder := c.Delete().Where(creditusage.ID(id))
|
|
|
|
+ builder.mutation.id = &id
|
|
|
|
+ builder.mutation.op = OpDeleteOne
|
|
|
|
+ return &CreditUsageDeleteOne{builder}
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+// Query returns a query builder for CreditUsage.
|
|
|
|
+func (c *CreditUsageClient) Query() *CreditUsageQuery {
|
|
|
|
+ return &CreditUsageQuery{
|
|
|
|
+ config: c.config,
|
|
|
|
+ ctx: &QueryContext{Type: TypeCreditUsage},
|
|
|
|
+ inters: c.Interceptors(),
|
|
|
|
+ }
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+// Get returns a CreditUsage entity by its id.
|
|
|
|
+func (c *CreditUsageClient) Get(ctx context.Context, id uint64) (*CreditUsage, error) {
|
|
|
|
+ return c.Query().Where(creditusage.ID(id)).Only(ctx)
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+// GetX is like Get, but panics if an error occurs.
|
|
|
|
+func (c *CreditUsageClient) GetX(ctx context.Context, id uint64) *CreditUsage {
|
|
|
|
+ obj, err := c.Get(ctx, id)
|
|
|
|
+ if err != nil {
|
|
|
|
+ panic(err)
|
|
|
|
+ }
|
|
|
|
+ return obj
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+// Hooks returns the client hooks.
|
|
|
|
+func (c *CreditUsageClient) Hooks() []Hook {
|
|
|
|
+ hooks := c.hooks.CreditUsage
|
|
|
|
+ return append(hooks[:len(hooks):len(hooks)], creditusage.Hooks[:]...)
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+// Interceptors returns the client interceptors.
|
|
|
|
+func (c *CreditUsageClient) Interceptors() []Interceptor {
|
|
|
|
+ inters := c.inters.CreditUsage
|
|
|
|
+ return append(inters[:len(inters):len(inters)], creditusage.Interceptors[:]...)
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+func (c *CreditUsageClient) mutate(ctx context.Context, m *CreditUsageMutation) (Value, error) {
|
|
|
|
+ switch m.Op() {
|
|
|
|
+ case OpCreate:
|
|
|
|
+ return (&CreditUsageCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
|
|
|
|
+ case OpUpdate:
|
|
|
|
+ return (&CreditUsageUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
|
|
|
|
+ case OpUpdateOne:
|
|
|
|
+ return (&CreditUsageUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
|
|
|
|
+ case OpDelete, OpDeleteOne:
|
|
|
|
+ return (&CreditUsageDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx)
|
|
|
|
+ default:
|
|
|
|
+ return nil, fmt.Errorf("ent: unknown CreditUsage mutation op: %q", m.Op())
|
|
|
|
+ }
|
|
|
|
+}
|
|
|
|
+
|
|
// EmployeeClient is a client for the Employee schema.
|
|
// EmployeeClient is a client for the Employee schema.
|
|
type EmployeeClient struct {
|
|
type EmployeeClient struct {
|
|
config
|
|
config
|
|
@@ -2985,6 +3282,141 @@ func (c *MsgClient) mutate(ctx context.Context, m *MsgMutation) (Value, error) {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+// PayRechargeClient is a client for the PayRecharge schema.
|
|
|
|
+type PayRechargeClient struct {
|
|
|
|
+ config
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+// NewPayRechargeClient returns a client for the PayRecharge from the given config.
|
|
|
|
+func NewPayRechargeClient(c config) *PayRechargeClient {
|
|
|
|
+ return &PayRechargeClient{config: c}
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+// Use adds a list of mutation hooks to the hooks stack.
|
|
|
|
+// A call to `Use(f, g, h)` equals to `payrecharge.Hooks(f(g(h())))`.
|
|
|
|
+func (c *PayRechargeClient) Use(hooks ...Hook) {
|
|
|
|
+ c.hooks.PayRecharge = append(c.hooks.PayRecharge, hooks...)
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+// Intercept adds a list of query interceptors to the interceptors stack.
|
|
|
|
+// A call to `Intercept(f, g, h)` equals to `payrecharge.Intercept(f(g(h())))`.
|
|
|
|
+func (c *PayRechargeClient) Intercept(interceptors ...Interceptor) {
|
|
|
|
+ c.inters.PayRecharge = append(c.inters.PayRecharge, interceptors...)
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+// Create returns a builder for creating a PayRecharge entity.
|
|
|
|
+func (c *PayRechargeClient) Create() *PayRechargeCreate {
|
|
|
|
+ mutation := newPayRechargeMutation(c.config, OpCreate)
|
|
|
|
+ return &PayRechargeCreate{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+// CreateBulk returns a builder for creating a bulk of PayRecharge entities.
|
|
|
|
+func (c *PayRechargeClient) CreateBulk(builders ...*PayRechargeCreate) *PayRechargeCreateBulk {
|
|
|
|
+ return &PayRechargeCreateBulk{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 *PayRechargeClient) MapCreateBulk(slice any, setFunc func(*PayRechargeCreate, int)) *PayRechargeCreateBulk {
|
|
|
|
+ rv := reflect.ValueOf(slice)
|
|
|
|
+ if rv.Kind() != reflect.Slice {
|
|
|
|
+ return &PayRechargeCreateBulk{err: fmt.Errorf("calling to PayRechargeClient.MapCreateBulk with wrong type %T, need slice", slice)}
|
|
|
|
+ }
|
|
|
|
+ builders := make([]*PayRechargeCreate, rv.Len())
|
|
|
|
+ for i := 0; i < rv.Len(); i++ {
|
|
|
|
+ builders[i] = c.Create()
|
|
|
|
+ setFunc(builders[i], i)
|
|
|
|
+ }
|
|
|
|
+ return &PayRechargeCreateBulk{config: c.config, builders: builders}
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+// Update returns an update builder for PayRecharge.
|
|
|
|
+func (c *PayRechargeClient) Update() *PayRechargeUpdate {
|
|
|
|
+ mutation := newPayRechargeMutation(c.config, OpUpdate)
|
|
|
|
+ return &PayRechargeUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+// UpdateOne returns an update builder for the given entity.
|
|
|
|
+func (c *PayRechargeClient) UpdateOne(pr *PayRecharge) *PayRechargeUpdateOne {
|
|
|
|
+ mutation := newPayRechargeMutation(c.config, OpUpdateOne, withPayRecharge(pr))
|
|
|
|
+ return &PayRechargeUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+// UpdateOneID returns an update builder for the given id.
|
|
|
|
+func (c *PayRechargeClient) UpdateOneID(id uint64) *PayRechargeUpdateOne {
|
|
|
|
+ mutation := newPayRechargeMutation(c.config, OpUpdateOne, withPayRechargeID(id))
|
|
|
|
+ return &PayRechargeUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+// Delete returns a delete builder for PayRecharge.
|
|
|
|
+func (c *PayRechargeClient) Delete() *PayRechargeDelete {
|
|
|
|
+ mutation := newPayRechargeMutation(c.config, OpDelete)
|
|
|
|
+ return &PayRechargeDelete{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+// DeleteOne returns a builder for deleting the given entity.
|
|
|
|
+func (c *PayRechargeClient) DeleteOne(pr *PayRecharge) *PayRechargeDeleteOne {
|
|
|
|
+ return c.DeleteOneID(pr.ID)
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+// DeleteOneID returns a builder for deleting the given entity by its id.
|
|
|
|
+func (c *PayRechargeClient) DeleteOneID(id uint64) *PayRechargeDeleteOne {
|
|
|
|
+ builder := c.Delete().Where(payrecharge.ID(id))
|
|
|
|
+ builder.mutation.id = &id
|
|
|
|
+ builder.mutation.op = OpDeleteOne
|
|
|
|
+ return &PayRechargeDeleteOne{builder}
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+// Query returns a query builder for PayRecharge.
|
|
|
|
+func (c *PayRechargeClient) Query() *PayRechargeQuery {
|
|
|
|
+ return &PayRechargeQuery{
|
|
|
|
+ config: c.config,
|
|
|
|
+ ctx: &QueryContext{Type: TypePayRecharge},
|
|
|
|
+ inters: c.Interceptors(),
|
|
|
|
+ }
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+// Get returns a PayRecharge entity by its id.
|
|
|
|
+func (c *PayRechargeClient) Get(ctx context.Context, id uint64) (*PayRecharge, error) {
|
|
|
|
+ return c.Query().Where(payrecharge.ID(id)).Only(ctx)
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+// GetX is like Get, but panics if an error occurs.
|
|
|
|
+func (c *PayRechargeClient) GetX(ctx context.Context, id uint64) *PayRecharge {
|
|
|
|
+ obj, err := c.Get(ctx, id)
|
|
|
|
+ if err != nil {
|
|
|
|
+ panic(err)
|
|
|
|
+ }
|
|
|
|
+ return obj
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+// Hooks returns the client hooks.
|
|
|
|
+func (c *PayRechargeClient) Hooks() []Hook {
|
|
|
|
+ hooks := c.hooks.PayRecharge
|
|
|
|
+ return append(hooks[:len(hooks):len(hooks)], payrecharge.Hooks[:]...)
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+// Interceptors returns the client interceptors.
|
|
|
|
+func (c *PayRechargeClient) Interceptors() []Interceptor {
|
|
|
|
+ inters := c.inters.PayRecharge
|
|
|
|
+ return append(inters[:len(inters):len(inters)], payrecharge.Interceptors[:]...)
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+func (c *PayRechargeClient) mutate(ctx context.Context, m *PayRechargeMutation) (Value, error) {
|
|
|
|
+ switch m.Op() {
|
|
|
|
+ case OpCreate:
|
|
|
|
+ return (&PayRechargeCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
|
|
|
|
+ case OpUpdate:
|
|
|
|
+ return (&PayRechargeUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
|
|
|
|
+ case OpUpdateOne:
|
|
|
|
+ return (&PayRechargeUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
|
|
|
|
+ case OpDelete, OpDeleteOne:
|
|
|
|
+ return (&PayRechargeDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx)
|
|
|
|
+ default:
|
|
|
|
+ return nil, fmt.Errorf("ent: unknown PayRecharge mutation op: %q", m.Op())
|
|
|
|
+ }
|
|
|
|
+}
|
|
|
|
+
|
|
// ServerClient is a client for the Server schema.
|
|
// ServerClient is a client for the Server schema.
|
|
type ServerClient struct {
|
|
type ServerClient struct {
|
|
config
|
|
config
|
|
@@ -5603,16 +6035,16 @@ func (c *WxCardVisitClient) mutate(ctx context.Context, m *WxCardVisitMutation)
|
|
type (
|
|
type (
|
|
hooks struct {
|
|
hooks struct {
|
|
Agent, AgentBase, AliyunAvatar, AllocAgent, BatchMsg, Category, ChatRecords,
|
|
Agent, AgentBase, AliyunAvatar, AllocAgent, BatchMsg, Category, ChatRecords,
|
|
- ChatSession, Contact, Employee, EmployeeConfig, Label, LabelRelationship,
|
|
|
|
- LabelTagging, Message,MessageRecords, Msg, Server, SopNode, SopStage, SopTask, Token,
|
|
|
|
|
|
+ ChatSession, Contact, CreditBalance, CreditUsage, Employee, EmployeeConfig, Label, LabelRelationship,
|
|
|
|
+ LabelTagging, Message,MessageRecords, Msg, PayRecharge, Server, SopNode, SopStage, SopTask, Token,
|
|
Tutorial, UsageDetail, UsageStatisticDay, UsageStatisticHour,
|
|
Tutorial, UsageDetail, UsageStatisticDay, UsageStatisticHour,
|
|
UsageStatisticMonth, UsageTotal, WorkExperience, WpChatroom, WpChatroomMember,
|
|
UsageStatisticMonth, UsageTotal, WorkExperience, WpChatroom, WpChatroomMember,
|
|
Wx, WxCard, WxCardUser, WxCardVisit []ent.Hook
|
|
Wx, WxCard, WxCardUser, WxCardVisit []ent.Hook
|
|
}
|
|
}
|
|
inters struct {
|
|
inters struct {
|
|
Agent, AgentBase, AliyunAvatar, AllocAgent, BatchMsg, Category, ChatRecords,
|
|
Agent, AgentBase, AliyunAvatar, AllocAgent, BatchMsg, Category, ChatRecords,
|
|
- ChatSession, Contact, Employee, EmployeeConfig, Label, LabelRelationship,
|
|
|
|
- LabelTagging, Message,MessageRecords, Msg, Server, SopNode, SopStage, SopTask, Token,
|
|
|
|
|
|
+ ChatSession, Contact, CreditBalance, CreditUsage, Employee, EmployeeConfig, Label, LabelRelationship,
|
|
|
|
+ LabelTagging, Message,MessageRecords, Msg, PayRecharge, Server, SopNode, SopStage, SopTask, Token,
|
|
Tutorial, UsageDetail, UsageStatisticDay, UsageStatisticHour,
|
|
Tutorial, UsageDetail, UsageStatisticDay, UsageStatisticHour,
|
|
UsageStatisticMonth, UsageTotal, WorkExperience, WpChatroom, WpChatroomMember,
|
|
UsageStatisticMonth, UsageTotal, WorkExperience, WpChatroom, WpChatroomMember,
|
|
Wx, WxCard, WxCardUser, WxCardVisit []ent.Interceptor
|
|
Wx, WxCard, WxCardUser, WxCardVisit []ent.Interceptor
|