package entity import ( "context" "gorm.io/gorm" "yx-dataset-server/app/schema" ) // GetRobotConfigDB 获取RobotConfig存储 func GetRobotConfigDB(ctx context.Context, defDB *gorm.DB) *gorm.DB { return getDBWithModel(ctx, defDB, RobotConfig{}) } // SchemaRobotConfig RobotConfig对象 type SchemaRobotConfig schema.RobotConfig // ToRobotConfig 转换为RobotConfig实体 func (a SchemaRobotConfig) ToRobotConfig() *RobotConfig { item := &RobotConfig{ RecordID: a.RecordID, OrgId: a.OrgId, Name: a.Name, Type: a.Type, APPID: a.APPID, ClientId: a.ClientId, ClientSecret: a.ClientSecret, Webhook: a.Webhook, AssistantId: a.AssistantId, SessionId: a.SessionId, CreatorId: a.CreatorId, } return item } // ToSchemaRobotConfig 转换为RobotConfig对象 func (a RobotConfig) ToSchemaRobotConfig() *schema.RobotConfig { item := &schema.RobotConfig{ RecordID: a.RecordID, OrgId: a.OrgId, Name: a.Name, Type: a.Type, APPID: a.APPID, ClientId: a.ClientId, ClientSecret: a.ClientSecret, Webhook: a.Webhook, CreatorId: a.CreatorId, AssistantId: a.AssistantId, SessionId: a.SessionId, CreatedAt: a.CreatedAt, } return item } // RobotConfig RobotConfig实体 type RobotConfig struct { gorm.Model RecordID string `gorm:"column:record_id;size:32;index;"` // 记录id OrgId string `gorm:"column:org_id;size:32;index;"` // 组织ID Name string `gorm:"column:name;size:20;"` // 机器人名称 Type int `gorm:"column:type;"` // 机器人类型 APPID string `gorm:"column:appid;size:50;"` // APP ID ClientId string `gorm:"column:client_id;size:50;"` // 客户端ID ClientSecret string `gorm:"column:client_secret;size:100;"` // 客户端密钥 Webhook string `gorm:"column:webhook;size:100;"` // 消息接收WebHook AssistantId string `gorm:"column:assistant_id;size:32;"` // 助手id SessionId string `gorm:"column:session_id;size:32;"` // 会话id CreatorId string `gorm:"column:creator_id;size:32;"` // 创建人 } // RobotConfigs RobotConfig列表 type RobotConfigs []*RobotConfig // ToSchemaRobotConfigs 转换为RobotConfig对象列表 func (a RobotConfigs) ToSchemaRobotConfigs() []*schema.RobotConfig { list := make([]*schema.RobotConfig, len(a)) for i, item := range a { list[i] = item.ToSchemaRobotConfig() } return list }