usage_total.go 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  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.Uint64("start_index").Optional().Default(0).
  25. Annotations(entsql.WithComments(true)).
  26. Comment("重制后的起始usage_detail 索引"),
  27. field.Uint64("end_index").Optional().Default(0).
  28. Annotations(entsql.WithComments(true)).
  29. Comment("usage_detail 索引"),
  30. field.Uint64("organization_id").Optional().Default(1).
  31. Comment("机构 ID").
  32. Annotations(entsql.WithComments(true)),
  33. }
  34. }
  35. func (UsageTotal) Mixin() []ent.Mixin {
  36. return []ent.Mixin{
  37. mixins.IDMixin{},
  38. mixins.StatusMixin{},
  39. }
  40. }
  41. func (UsageTotal) Indexes() []ent.Index {
  42. return []ent.Index{
  43. index.Fields("bot_id"),
  44. index.Fields("organization_id"),
  45. }
  46. }
  47. func (UsageTotal) Edges() []ent.Edge { return []ent.Edge{} }
  48. func (UsageTotal) Annotations() []schema.Annotation {
  49. return []schema.Annotation{
  50. entsql.WithComments(true),
  51. entsql.Annotation{Table: "usage_total"},
  52. }
  53. }