chat_records.go 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  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. "wechat-api/ent/schema/localmixin"
  10. )
  11. type ChatRecords struct {
  12. ent.Schema
  13. }
  14. func (ChatRecords) Fields() []ent.Field {
  15. return []ent.Field{
  16. field.String("content").Default("").Comment("内容"),
  17. field.Uint8("content_type").Default(1).Comment("内容类型:1-提问 2-回答"),
  18. field.Uint64("session_id").Default(0).Comment("会话ID"),
  19. field.Uint64("user_id").Default(0).Comment("用户ID"),
  20. field.Uint64("bot_id").Default(0).Comment("聊天ID"),
  21. field.Uint8("bot_type").Default(2).Comment("类型:1-微信 2-小程序card 3-智能体"),
  22. }
  23. }
  24. func (ChatRecords) Mixin() []ent.Mixin {
  25. return []ent.Mixin{
  26. mixins.IDMixin{},
  27. localmixin.SoftDeleteMixin{},
  28. }
  29. }
  30. func (ChatRecords) Indexes() []ent.Index {
  31. return []ent.Index{
  32. index.Fields("user_id", "bot_id", "bot_type"),
  33. index.Fields("session_id"),
  34. }
  35. }
  36. func (ChatRecords) Edges() []ent.Edge {
  37. return nil
  38. }
  39. func (ChatRecords) Annotations() []schema.Annotation {
  40. return []schema.Annotation{
  41. entsql.WithComments(true),
  42. entsql.Annotation{Table: "chat_records"},
  43. }
  44. }