🎨 优化前端菜单栏(修改为抽屉模式)&& 新增ai预设功能 && 优化ai对话前端渲染
This commit is contained in:
24
server/model/app/request/ai_preset.go
Normal file
24
server/model/app/request/ai_preset.go
Normal file
@@ -0,0 +1,24 @@
|
||||
package request
|
||||
|
||||
import "git.echol.cn/loser/st/server/model/common/request"
|
||||
|
||||
// CreateAIPresetRequest 创建预设请求
|
||||
type CreateAIPresetRequest struct {
|
||||
Name string `json:"name" binding:"required,max=200"`
|
||||
Type string `json:"type" binding:"required,max=100"`
|
||||
Content map[string]interface{} `json:"content" binding:"required"`
|
||||
}
|
||||
|
||||
// UpdateAIPresetRequest 更新预设请求
|
||||
type UpdateAIPresetRequest struct {
|
||||
Name string `json:"name" binding:"required,max=200"`
|
||||
Type string `json:"type" binding:"required,max=100"`
|
||||
Content map[string]interface{} `json:"content" binding:"required"`
|
||||
}
|
||||
|
||||
// AIPresetSearch 预设搜索请求
|
||||
type AIPresetSearch struct {
|
||||
request.PageInfo
|
||||
Name string `json:"name" form:"name"`
|
||||
Type string `json:"type" form:"type"`
|
||||
}
|
||||
42
server/model/app/response/ai_preset.go
Normal file
42
server/model/app/response/ai_preset.go
Normal file
@@ -0,0 +1,42 @@
|
||||
package response
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"git.echol.cn/loser/st/server/model/app"
|
||||
"time"
|
||||
)
|
||||
|
||||
// AIPresetResponse 预设响应
|
||||
type AIPresetResponse struct {
|
||||
ID uint `json:"id"`
|
||||
Name string `json:"name"`
|
||||
Type string `json:"type"`
|
||||
Content map[string]interface{} `json:"content"`
|
||||
IsSystem bool `json:"isSystem"`
|
||||
IsDefault bool `json:"isDefault"`
|
||||
CreatedAt time.Time `json:"createdAt"`
|
||||
UpdatedAt time.Time `json:"updatedAt"`
|
||||
}
|
||||
|
||||
// ToAIPresetResponse 转换为响应格式
|
||||
func ToAIPresetResponse(preset *app.AIPreset) *AIPresetResponse {
|
||||
content := make(map[string]interface{})
|
||||
if preset.Config != nil && len(preset.Config) > 0 {
|
||||
// 将 datatypes.JSON 转换为 map
|
||||
if err := json.Unmarshal(preset.Config, &content); err != nil {
|
||||
// 如果解析失败,返回空 map
|
||||
content = make(map[string]interface{})
|
||||
}
|
||||
}
|
||||
|
||||
return &AIPresetResponse{
|
||||
ID: preset.ID,
|
||||
Name: preset.Name,
|
||||
Type: preset.PresetType,
|
||||
Content: content,
|
||||
IsSystem: preset.IsSystem,
|
||||
IsDefault: preset.IsDefault,
|
||||
CreatedAt: preset.CreatedAt,
|
||||
UpdatedAt: preset.UpdatedAt,
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user