e_chat_assistant.go 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  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. RagChatId: a.RagChatId,
  22. CreatorId: a.CreatorId,
  23. }
  24. return item
  25. }
  26. // ToSchemaChatAssistant 转换为ChatAssistant对象
  27. func (a ChatAssistant) ToSchemaChatAssistant() *schema.ChatAssistant {
  28. item := &schema.ChatAssistant{
  29. RecordID: a.RecordID,
  30. UserId: a.UserId,
  31. OrgId: a.OrgId,
  32. Name: a.Name,
  33. Desc: a.Desc,
  34. RagChatId: a.RagChatId,
  35. CreatorId: a.CreatorId,
  36. CreatedAt: a.CreatedAt,
  37. }
  38. return item
  39. }
  40. // ChatAssistant ChatAssistant实体
  41. type ChatAssistant struct {
  42. gorm.Model
  43. RecordID string `gorm:"column:record_id;size:32;index;"` // 记录id
  44. UserId string `gorm:"column:user_id;size:32;index;"` // 所属用户id
  45. OrgId string `gorm:"column:org_id;size:32;index;"` // 所属组织id
  46. Name string `gorm:"column:name;size:20;"` // 助手名称
  47. Desc string `gorm:"column:desc;size:30;"` // 描述
  48. RagChatId string `gorm:"column:rag_chat_id;size:32;"` // rag_chat_id
  49. CreatorId string `gorm:"column:creator_id;size:32;index;"` // 创建人id
  50. }
  51. // ChatAssistants ChatAssistant列表
  52. type ChatAssistants []*ChatAssistant
  53. // ToSchemaChatAssistants 转换为ChatAssistant对象列表
  54. func (a ChatAssistants) ToSchemaChatAssistants() []*schema.ChatAssistant {
  55. list := make([]*schema.ChatAssistant, len(a))
  56. for i, item := range a {
  57. list[i] = item.ToSchemaChatAssistant()
  58. }
  59. return list
  60. }