diff --git a/proto/model.go b/proto/model.go new file mode 100644 index 0000000..0d8eae8 --- /dev/null +++ b/proto/model.go @@ -0,0 +1,5 @@ +package proto + +type FunctionModelIDs struct { + ID int `json:"id" form:"id"` +} diff --git a/service/modelService.go b/service/modelService.go index cf6cd1b..fffc604 100644 --- a/service/modelService.go +++ b/service/modelService.go @@ -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)