| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687 |
- 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,
- ReplyType: a.ReplyType,
- APPID: a.APPID,
- ClientId: a.ClientId,
- ClientSecret: a.ClientSecret,
- Webhook: a.Webhook,
- CardTemplateId: a.CardTemplateId,
- 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,
- ReplyType: a.ReplyType,
- APPID: a.APPID,
- ClientId: a.ClientId,
- ClientSecret: a.ClientSecret,
- Webhook: a.Webhook,
- CardTemplateId: a.CardTemplateId,
- 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;"` // 机器人类型
- ReplyType int `gorm:"column:reply_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
- OutTrackId string `gorm:"column:out_track_id;size:100;index;"` // 外部卡片实例Id
- CardTemplateId string `gorm:"column:card_template_id;size:100;"` // 卡片模板ID
- 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
- }
|