修复普通根据功能获取模型列表解析问题

This commit is contained in:
junleea 2025-03-31 13:09:25 +08:00
parent 5592e47f72
commit 754346b32f
2 changed files with 13 additions and 2 deletions

5
proto/model.go Normal file
View File

@ -0,0 +1,5 @@
package proto
type FunctionModelIDs struct {
ID int `json:"id" form:"id"`
}

View File

@ -2,6 +2,7 @@ package service
import (
"StuAcaWorksAI/dao"
"StuAcaWorksAI/proto"
"encoding/json"
"errors"
"log"
@ -150,12 +151,17 @@ func FindFuncModelByFunction(function string, userID int) ([]dao.Model, []dao.Fu
// 根据功能查找对应的功能模型列表不查询密钥等信息只差id,类型及名称)
func FindFuncModelListByFunction(function string) ([]dao.Model, error) {
funcModels := dao.FindFunctionModelByFunction(function)
modelIDs := map[int]bool{}
err := json.Unmarshal([]byte(funcModels[0].ModelIDS), &modelIDs)
var functionModelIDs []proto.FunctionModelIDs
err := json.Unmarshal([]byte(funcModels[0].ModelIDS), &functionModelIDs)
if err != nil {
log.Println("FindFuncModelListByFunction json unmarshal error:", err)
return nil, err
}
modelIDs := map[int]bool{}
for _, v := range functionModelIDs {
modelIDs[v.ID] = true
}
var models []dao.Model
for k := range modelIDs {
models_ := dao.FindModelByIDV2(k)