修复普通根据功能获取模型列表解析问题
This commit is contained in:
parent
5592e47f72
commit
754346b32f
|
|
@ -0,0 +1,5 @@
|
||||||
|
package proto
|
||||||
|
|
||||||
|
type FunctionModelIDs struct {
|
||||||
|
ID int `json:"id" form:"id"`
|
||||||
|
}
|
||||||
|
|
@ -2,6 +2,7 @@ package service
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"StuAcaWorksAI/dao"
|
"StuAcaWorksAI/dao"
|
||||||
|
"StuAcaWorksAI/proto"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"errors"
|
"errors"
|
||||||
"log"
|
"log"
|
||||||
|
|
@ -150,12 +151,17 @@ func FindFuncModelByFunction(function string, userID int) ([]dao.Model, []dao.Fu
|
||||||
// 根据功能查找对应的功能模型列表(不查询密钥等信息,只差id,类型及名称)
|
// 根据功能查找对应的功能模型列表(不查询密钥等信息,只差id,类型及名称)
|
||||||
func FindFuncModelListByFunction(function string) ([]dao.Model, error) {
|
func FindFuncModelListByFunction(function string) ([]dao.Model, error) {
|
||||||
funcModels := dao.FindFunctionModelByFunction(function)
|
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 {
|
if err != nil {
|
||||||
log.Println("FindFuncModelListByFunction json unmarshal error:", err)
|
log.Println("FindFuncModelListByFunction json unmarshal error:", err)
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
modelIDs := map[int]bool{}
|
||||||
|
for _, v := range functionModelIDs {
|
||||||
|
modelIDs[v.ID] = true
|
||||||
|
}
|
||||||
var models []dao.Model
|
var models []dao.Model
|
||||||
for k := range modelIDs {
|
for k := range modelIDs {
|
||||||
models_ := dao.FindModelByIDV2(k)
|
models_ := dao.FindModelByIDV2(k)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue