usage_total.go 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. package schema
  2. import (
  3. "entgo.io/ent"
  4. "entgo.io/ent/dialect/entsql"
  5. "entgo.io/ent/schema"
  6. "entgo.io/ent/schema/field"
  7. "entgo.io/ent/schema/index"
  8. "github.com/suyuan32/simple-admin-common/orm/ent/mixins"
  9. )
  10. type UsageTotal struct {
  11. ent.Schema
  12. }
  13. func (UsageTotal) Fields() []ent.Field {
  14. return []ent.Field{
  15. field.Int("type").Optional().Default(1).
  16. Annotations(entsql.WithComments(true)).
  17. Comment("1 微信 2 名片"),
  18. field.String("bot_id").Default("").
  19. Annotations(entsql.WithComments(true)).
  20. Comment("微信或名片id"),
  21. field.Uint64("total_tokens").Optional().Default(0).
  22. Annotations(entsql.WithComments(true)).
  23. Comment("使用token总数"),
  24. field.Float("credits").Optional().Default(0).
  25. Annotations(entsql.WithComments(true)).
  26. Comment("使用积分总数"),
  27. field.Uint64("start_index").Optional().Default(0).
  28. Annotations(entsql.WithComments(true)).
  29. Comment("重制后的起始usage_detail 索引"),
  30. field.Uint64("end_index").Optional().Default(0).
  31. Annotations(entsql.WithComments(true)).
  32. Comment("usage_detail 索引"),
  33. field.Uint64("organization_id").Optional().Default(1).
  34. Comment("机构 ID").
  35. Annotations(entsql.WithComments(true)),
  36. }
  37. }
  38. func (UsageTotal) Mixin() []ent.Mixin {
  39. return []ent.Mixin{
  40. mixins.IDMixin{},
  41. mixins.StatusMixin{},
  42. }
  43. }
  44. func (UsageTotal) Indexes() []ent.Index {
  45. return []ent.Index{
  46. index.Fields("bot_id"),
  47. index.Fields("organization_id"),
  48. }
  49. }
  50. func (UsageTotal) Edges() []ent.Edge { return []ent.Edge{} }
  51. func (UsageTotal) Annotations() []schema.Annotation {
  52. return []schema.Annotation{
  53. entsql.WithComments(true),
  54. entsql.Annotation{Table: "usage_total"},
  55. }
  56. }