e_robot_config.go 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. package entity
  2. import (
  3. "context"
  4. "gorm.io/gorm"
  5. "yx-dataset-server/app/schema"
  6. )
  7. // GetRobotConfigDB 获取RobotConfig存储
  8. func GetRobotConfigDB(ctx context.Context, defDB *gorm.DB) *gorm.DB {
  9. return getDBWithModel(ctx, defDB, RobotConfig{})
  10. }
  11. // SchemaRobotConfig RobotConfig对象
  12. type SchemaRobotConfig schema.RobotConfig
  13. // ToRobotConfig 转换为RobotConfig实体
  14. func (a SchemaRobotConfig) ToRobotConfig() *RobotConfig {
  15. item := &RobotConfig{
  16. RecordID: a.RecordID,
  17. OrgId: a.OrgId,
  18. Name: a.Name,
  19. Type: a.Type,
  20. ReplyType: a.ReplyType,
  21. APPID: a.APPID,
  22. ClientId: a.ClientId,
  23. ClientSecret: a.ClientSecret,
  24. Webhook: a.Webhook,
  25. CardTemplateId: a.CardTemplateId,
  26. AssistantId: a.AssistantId,
  27. SessionId: a.SessionId,
  28. CreatorId: a.CreatorId,
  29. }
  30. return item
  31. }
  32. // ToSchemaRobotConfig 转换为RobotConfig对象
  33. func (a RobotConfig) ToSchemaRobotConfig() *schema.RobotConfig {
  34. item := &schema.RobotConfig{
  35. RecordID: a.RecordID,
  36. OrgId: a.OrgId,
  37. Name: a.Name,
  38. Type: a.Type,
  39. ReplyType: a.ReplyType,
  40. APPID: a.APPID,
  41. ClientId: a.ClientId,
  42. ClientSecret: a.ClientSecret,
  43. Webhook: a.Webhook,
  44. CardTemplateId: a.CardTemplateId,
  45. CreatorId: a.CreatorId,
  46. AssistantId: a.AssistantId,
  47. SessionId: a.SessionId,
  48. CreatedAt: a.CreatedAt,
  49. }
  50. return item
  51. }
  52. // RobotConfig RobotConfig实体
  53. type RobotConfig struct {
  54. gorm.Model
  55. RecordID string `gorm:"column:record_id;size:32;index;"` // 记录id
  56. OrgId string `gorm:"column:org_id;size:32;index;"` // 组织ID
  57. Name string `gorm:"column:name;size:20;"` // 机器人名称
  58. Type int `gorm:"column:type;"` // 机器人类型
  59. ReplyType int `gorm:"column:reply_type;"` // 钉钉机器人回复类型
  60. APPID string `gorm:"column:appid;size:50;"` // APP ID
  61. ClientId string `gorm:"column:client_id;size:50;"` // 客户端ID
  62. ClientSecret string `gorm:"column:client_secret;size:100;"` // 客户端密钥
  63. Webhook string `gorm:"column:webhook;size:100;"` // 消息接收WebHook
  64. OutTrackId string `gorm:"column:out_track_id;size:100;index;"` // 外部卡片实例Id
  65. CardTemplateId string `gorm:"column:card_template_id;size:100;"` // 卡片模板ID
  66. AssistantId string `gorm:"column:assistant_id;size:32;"` // 助手id
  67. SessionId string `gorm:"column:session_id;size:32;"` // 会话id
  68. CreatorId string `gorm:"column:creator_id;size:32;"` // 创建人
  69. }
  70. // RobotConfigs RobotConfig列表
  71. type RobotConfigs []*RobotConfig
  72. // ToSchemaRobotConfigs 转换为RobotConfig对象列表
  73. func (a RobotConfigs) ToSchemaRobotConfigs() []*schema.RobotConfig {
  74. list := make([]*schema.RobotConfig, len(a))
  75. for i, item := range a {
  76. list[i] = item.ToSchemaRobotConfig()
  77. }
  78. return list
  79. }