// Code generated by ent, DO NOT EDIT. package ent import ( "encoding/json" "fmt" "strings" "time" "wechat-api/ent/custom_types" "wechat-api/ent/usagestatisticmonth" "entgo.io/ent" "entgo.io/ent/dialect/sql" ) // UsageStatisticMonth is the model entity for the UsageStatisticMonth schema. type UsageStatisticMonth 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"` // 写入年月 Addtime uint64 `json:"addtime,omitempty"` // 1-微信 2-名片 Type int `json:"type,omitempty"` // 微信或名片id BotID string `json:"bot_id,omitempty"` // 机构ID OrganizationID uint64 `json:"organization_id,omitempty"` // AI回复次数 AiResponse uint64 `json:"ai_response,omitempty"` // SOP运行次数 SopRun uint64 `json:"sop_run,omitempty"` // 好友总数 TotalFriend uint64 `json:"total_friend,omitempty"` // 群总数 TotalGroup uint64 `json:"total_group,omitempty"` // 账户余额(单位:分) AccountBalance uint64 `json:"account_balance,omitempty"` // 消耗token数 ConsumeToken uint64 `json:"consume_token,omitempty"` // 活跃用户数 ActiveUser uint64 `json:"active_user,omitempty"` // 新增用户数 NewUser int64 `json:"new_user,omitempty"` // 标签分布 LabelDist []custom_types.LabelDist `json:"label_dist,omitempty"` selectValues sql.SelectValues } // scanValues returns the types for scanning values from sql.Rows. func (*UsageStatisticMonth) scanValues(columns []string) ([]any, error) { values := make([]any, len(columns)) for i := range columns { switch columns[i] { case usagestatisticmonth.FieldLabelDist: values[i] = new([]byte) case usagestatisticmonth.FieldID, usagestatisticmonth.FieldStatus, usagestatisticmonth.FieldAddtime, usagestatisticmonth.FieldType, usagestatisticmonth.FieldOrganizationID, usagestatisticmonth.FieldAiResponse, usagestatisticmonth.FieldSopRun, usagestatisticmonth.FieldTotalFriend, usagestatisticmonth.FieldTotalGroup, usagestatisticmonth.FieldAccountBalance, usagestatisticmonth.FieldConsumeToken, usagestatisticmonth.FieldActiveUser, usagestatisticmonth.FieldNewUser: values[i] = new(sql.NullInt64) case usagestatisticmonth.FieldBotID: values[i] = new(sql.NullString) case usagestatisticmonth.FieldCreatedAt, usagestatisticmonth.FieldUpdatedAt, usagestatisticmonth.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 UsageStatisticMonth fields. func (usm *UsageStatisticMonth) 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 usagestatisticmonth.FieldID: value, ok := values[i].(*sql.NullInt64) if !ok { return fmt.Errorf("unexpected type %T for field id", value) } usm.ID = uint64(value.Int64) case usagestatisticmonth.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 { usm.CreatedAt = value.Time } case usagestatisticmonth.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 { usm.UpdatedAt = value.Time } case usagestatisticmonth.FieldStatus: if value, ok := values[i].(*sql.NullInt64); !ok { return fmt.Errorf("unexpected type %T for field status", values[i]) } else if value.Valid { usm.Status = uint8(value.Int64) } case usagestatisticmonth.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 { usm.DeletedAt = value.Time } case usagestatisticmonth.FieldAddtime: if value, ok := values[i].(*sql.NullInt64); !ok { return fmt.Errorf("unexpected type %T for field addtime", values[i]) } else if value.Valid { usm.Addtime = uint64(value.Int64) } case usagestatisticmonth.FieldType: if value, ok := values[i].(*sql.NullInt64); !ok { return fmt.Errorf("unexpected type %T for field type", values[i]) } else if value.Valid { usm.Type = int(value.Int64) } case usagestatisticmonth.FieldBotID: if value, ok := values[i].(*sql.NullString); !ok { return fmt.Errorf("unexpected type %T for field bot_id", values[i]) } else if value.Valid { usm.BotID = value.String } case usagestatisticmonth.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 { usm.OrganizationID = uint64(value.Int64) } case usagestatisticmonth.FieldAiResponse: if value, ok := values[i].(*sql.NullInt64); !ok { return fmt.Errorf("unexpected type %T for field ai_response", values[i]) } else if value.Valid { usm.AiResponse = uint64(value.Int64) } case usagestatisticmonth.FieldSopRun: if value, ok := values[i].(*sql.NullInt64); !ok { return fmt.Errorf("unexpected type %T for field sop_run", values[i]) } else if value.Valid { usm.SopRun = uint64(value.Int64) } case usagestatisticmonth.FieldTotalFriend: if value, ok := values[i].(*sql.NullInt64); !ok { return fmt.Errorf("unexpected type %T for field total_friend", values[i]) } else if value.Valid { usm.TotalFriend = uint64(value.Int64) } case usagestatisticmonth.FieldTotalGroup: if value, ok := values[i].(*sql.NullInt64); !ok { return fmt.Errorf("unexpected type %T for field total_group", values[i]) } else if value.Valid { usm.TotalGroup = uint64(value.Int64) } case usagestatisticmonth.FieldAccountBalance: if value, ok := values[i].(*sql.NullInt64); !ok { return fmt.Errorf("unexpected type %T for field account_balance", values[i]) } else if value.Valid { usm.AccountBalance = uint64(value.Int64) } case usagestatisticmonth.FieldConsumeToken: if value, ok := values[i].(*sql.NullInt64); !ok { return fmt.Errorf("unexpected type %T for field consume_token", values[i]) } else if value.Valid { usm.ConsumeToken = uint64(value.Int64) } case usagestatisticmonth.FieldActiveUser: if value, ok := values[i].(*sql.NullInt64); !ok { return fmt.Errorf("unexpected type %T for field active_user", values[i]) } else if value.Valid { usm.ActiveUser = uint64(value.Int64) } case usagestatisticmonth.FieldNewUser: if value, ok := values[i].(*sql.NullInt64); !ok { return fmt.Errorf("unexpected type %T for field new_user", values[i]) } else if value.Valid { usm.NewUser = value.Int64 } case usagestatisticmonth.FieldLabelDist: if value, ok := values[i].(*[]byte); !ok { return fmt.Errorf("unexpected type %T for field label_dist", values[i]) } else if value != nil && len(*value) > 0 { if err := json.Unmarshal(*value, &usm.LabelDist); err != nil { return fmt.Errorf("unmarshal field label_dist: %w", err) } } default: usm.selectValues.Set(columns[i], values[i]) } } return nil } // Value returns the ent.Value that was dynamically selected and assigned to the UsageStatisticMonth. // This includes values selected through modifiers, order, etc. func (usm *UsageStatisticMonth) Value(name string) (ent.Value, error) { return usm.selectValues.Get(name) } // Update returns a builder for updating this UsageStatisticMonth. // Note that you need to call UsageStatisticMonth.Unwrap() before calling this method if this UsageStatisticMonth // was returned from a transaction, and the transaction was committed or rolled back. func (usm *UsageStatisticMonth) Update() *UsageStatisticMonthUpdateOne { return NewUsageStatisticMonthClient(usm.config).UpdateOne(usm) } // Unwrap unwraps the UsageStatisticMonth 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 (usm *UsageStatisticMonth) Unwrap() *UsageStatisticMonth { _tx, ok := usm.config.driver.(*txDriver) if !ok { panic("ent: UsageStatisticMonth is not a transactional entity") } usm.config.driver = _tx.drv return usm } // String implements the fmt.Stringer. func (usm *UsageStatisticMonth) String() string { var builder strings.Builder builder.WriteString("UsageStatisticMonth(") builder.WriteString(fmt.Sprintf("id=%v, ", usm.ID)) builder.WriteString("created_at=") builder.WriteString(usm.CreatedAt.Format(time.ANSIC)) builder.WriteString(", ") builder.WriteString("updated_at=") builder.WriteString(usm.UpdatedAt.Format(time.ANSIC)) builder.WriteString(", ") builder.WriteString("status=") builder.WriteString(fmt.Sprintf("%v", usm.Status)) builder.WriteString(", ") builder.WriteString("deleted_at=") builder.WriteString(usm.DeletedAt.Format(time.ANSIC)) builder.WriteString(", ") builder.WriteString("addtime=") builder.WriteString(fmt.Sprintf("%v", usm.Addtime)) builder.WriteString(", ") builder.WriteString("type=") builder.WriteString(fmt.Sprintf("%v", usm.Type)) builder.WriteString(", ") builder.WriteString("bot_id=") builder.WriteString(usm.BotID) builder.WriteString(", ") builder.WriteString("organization_id=") builder.WriteString(fmt.Sprintf("%v", usm.OrganizationID)) builder.WriteString(", ") builder.WriteString("ai_response=") builder.WriteString(fmt.Sprintf("%v", usm.AiResponse)) builder.WriteString(", ") builder.WriteString("sop_run=") builder.WriteString(fmt.Sprintf("%v", usm.SopRun)) builder.WriteString(", ") builder.WriteString("total_friend=") builder.WriteString(fmt.Sprintf("%v", usm.TotalFriend)) builder.WriteString(", ") builder.WriteString("total_group=") builder.WriteString(fmt.Sprintf("%v", usm.TotalGroup)) builder.WriteString(", ") builder.WriteString("account_balance=") builder.WriteString(fmt.Sprintf("%v", usm.AccountBalance)) builder.WriteString(", ") builder.WriteString("consume_token=") builder.WriteString(fmt.Sprintf("%v", usm.ConsumeToken)) builder.WriteString(", ") builder.WriteString("active_user=") builder.WriteString(fmt.Sprintf("%v", usm.ActiveUser)) builder.WriteString(", ") builder.WriteString("new_user=") builder.WriteString(fmt.Sprintf("%v", usm.NewUser)) builder.WriteString(", ") builder.WriteString("label_dist=") builder.WriteString(fmt.Sprintf("%v", usm.LabelDist)) builder.WriteByte(')') return builder.String() } // UsageStatisticMonths is a parsable slice of UsageStatisticMonth. type UsageStatisticMonths []*UsageStatisticMonth