chat_session.go 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  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 ChatSession struct {
  12. ent.Schema
  13. }
  14. func (ChatSession) Fields() []ent.Field {
  15. return []ent.Field{
  16. field.String("name").Default("").Comment("名称"),
  17. field.Uint64("user_id").Default(0).Comment("用户ID"),
  18. field.Uint64("bot_id").Default(0).Comment("聊天ID"),
  19. field.Uint8("bot_type").Default(2).Comment("类型:1-微信 2-小程序card 3-智能体"),
  20. }
  21. }
  22. func (ChatSession) Mixin() []ent.Mixin {
  23. return []ent.Mixin{
  24. mixins.IDMixin{},
  25. localmixin.SoftDeleteMixin{},
  26. }
  27. }
  28. func (ChatSession) Indexes() []ent.Index {
  29. return []ent.Index{
  30. index.Fields("user_id", "bot_id", "bot_type"),
  31. }
  32. }
  33. func (ChatSession) Edges() []ent.Edge {
  34. return nil
  35. }
  36. func (ChatSession) Annotations() []schema.Annotation {
  37. return []schema.Annotation{
  38. entsql.WithComments(true),
  39. entsql.Annotation{Table: "chat_session"},
  40. }
  41. }