usage_statistic_hour.go 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. package schema
  2. import (
  3. "wechat-api/ent/custom_types"
  4. "wechat-api/ent/schema/localmixin"
  5. "entgo.io/ent"
  6. "entgo.io/ent/dialect/entsql"
  7. "entgo.io/ent/schema"
  8. "entgo.io/ent/schema/field"
  9. "entgo.io/ent/schema/index"
  10. "github.com/suyuan32/simple-admin-common/orm/ent/mixins"
  11. )
  12. type UsageStatisticHour struct {
  13. ent.Schema
  14. }
  15. func (UsageStatisticHour) Fields() []ent.Field {
  16. return []ent.Field{
  17. field.Uint64("addtime").Comment("写入小时"),
  18. field.Int("type").Comment("1-微信 2-名片"),
  19. field.String("bot_id").Optional().Comment("微信或名片id"),
  20. field.Uint64("organization_id").Optional().Comment("机构ID"),
  21. field.Uint64("ai_response").Comment("AI回复次数"),
  22. field.Uint64("sop_run").Comment("SOP运行次数"),
  23. field.Uint64("total_friend").Comment("好友总数"),
  24. field.Uint64("total_group").Comment("群总数"),
  25. field.Uint64("account_balance").Comment("账户余额(单位:分)"),
  26. field.Uint64("consume_token").Comment("消耗token数"),
  27. field.Uint64("active_user").Comment("活跃用户数"),
  28. field.Int64("new_user").Comment("新增用户数"),
  29. field.JSON("label_dist", []custom_types.LabelDist{}).
  30. Annotations(entsql.WithComments(true)).
  31. Comment("标签分布"),
  32. }
  33. }
  34. func (UsageStatisticHour) Mixin() []ent.Mixin {
  35. return []ent.Mixin{
  36. mixins.IDMixin{},
  37. mixins.StatusMixin{},
  38. localmixin.SoftDeleteMixin{},
  39. }
  40. }
  41. func (UsageStatisticHour) Indexes() []ent.Index {
  42. return []ent.Index{
  43. index.Fields("addtime"),
  44. index.Fields("bot_id"),
  45. }
  46. }
  47. func (UsageStatisticHour) Edges() []ent.Edge {
  48. return nil
  49. }
  50. func (UsageStatisticHour) Annotations() []schema.Annotation {
  51. return []schema.Annotation{
  52. entsql.WithComments(true),
  53. entsql.Annotation{Table: "usage_statistic_hour"},
  54. }
  55. }