From 754346b32f78b306152fd3a13afe761e721991e7 Mon Sep 17 00:00:00 2001 From: junleea <354425203@qq.com> Date: Mon, 31 Mar 2025 13:09:25 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E6=99=AE=E9=80=9A=E6=A0=B9?= =?UTF-8?q?=E6=8D=AE=E5=8A=9F=E8=83=BD=E8=8E=B7=E5=8F=96=E6=A8=A1=E5=9E=8B?= =?UTF-8?q?=E5=88=97=E8=A1=A8=E8=A7=A3=E6=9E=90=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- proto/model.go | 5 +++++ service/modelService.go | 10 ++++++++-- 2 files changed, 13 insertions(+), 2 deletions(-) create mode 100644 proto/model.go 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)