e_chat_assistant.go 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. package entity
  2. import (
  3. "context"
  4. "gorm.io/gorm"
  5. "yx-dataset-server/app/schema"
  6. )
  7. // GetChatAssistantDB 获取ChatAssistant存储
  8. func GetChatAssistantDB(ctx context.Context, defDB *gorm.DB) *gorm.DB {
  9. return getDBWithModel(ctx, defDB, ChatAssistant{})
  10. }
  11. // SchemaChatAssistant ChatAssistant对象
  12. type SchemaChatAssistant schema.ChatAssistant
  13. // ToChatAssistant 转换为ChatAssistant实体
  14. func (a SchemaChatAssistant) ToChatAssistant() *ChatAssistant {
  15. item := &ChatAssistant{
  16. RecordID: a.RecordID,
  17. UserId: a.UserId,
  18. OrgId: a.OrgId,
  19. Name: a.Name,
  20. Desc: a.Desc,
  21. Source: a.Source,
  22. RagChatId: a.RagChatId,
  23. CreatorId: a.CreatorId,
  24. }
  25. return item
  26. }
  27. // ToSchemaChatAssistant 转换为ChatAssistant对象
  28. func (a ChatAssistant) ToSchemaChatAssistant() *schema.ChatAssistant {
  29. item := &schema.ChatAssistant{
  30. RecordID: a.RecordID,
  31. UserId: a.UserId,
  32. OrgId: a.OrgId,
  33. Name: a.Name,
  34. Desc: a.Desc,
  35. Source: a.Source,
  36. RagChatId: a.RagChatId,
  37. CreatorId: a.CreatorId,
  38. CreatedAt: a.CreatedAt,
  39. }
  40. return item
  41. }
  42. // ChatAssistant ChatAssistant实体
  43. type ChatAssistant struct {
  44. gorm.Model
  45. RecordID string `gorm:"column:record_id;size:32;index;"` // 记录id
  46. UserId string `gorm:"column:user_id;size:32;index;"` // 所属用户id
  47. OrgId string `gorm:"column:org_id;size:32;index;"` // 所属组织id
  48. Name string `gorm:"column:name;size:50;"` // 助手名称
  49. Desc string `gorm:"column:desc;size:30;"` // 描述
  50. Source int `gorm:"column:source;"` // 来源 1h5 2 钉钉机器人
  51. RagChatId string `gorm:"column:rag_chat_id;size:32;"` // rag_chat_id
  52. CreatorId string `gorm:"column:creator_id;size:32;index;"` // 创建人id
  53. }
  54. // ChatAssistants ChatAssistant列表
  55. type ChatAssistants []*ChatAssistant
  56. // ToSchemaChatAssistants 转换为ChatAssistant对象列表
  57. func (a ChatAssistants) ToSchemaChatAssistants() []*schema.ChatAssistant {
  58. list := make([]*schema.ChatAssistant, len(a))
  59. for i, item := range a {
  60. list[i] = item.ToSchemaChatAssistant()
  61. }
  62. return list
  63. }