diff --git a/dao/model.go b/dao/model.go index 7a5f45a..56bda81 100644 --- a/dao/model.go +++ b/dao/model.go @@ -46,6 +46,17 @@ func FindModelByID(id, userID int) []Model { return model } +// 根据modelID查找模型 +func FindModelByModelID(modelID uint) []Model { + var model []Model + if proto.Config.SERVER_SQL_LOG { + DB.Debug().Where("id = ?", modelID).Find(&model) + } else { + DB.Where("id = ?", modelID).Find(&model) + } + return model +} + // 根据用户id查找模型 func FindModelByUserID(userID int) []Model { var models []Model diff --git a/handler/im.go b/handler/im.go index 114c904..dde4a9f 100644 --- a/handler/im.go +++ b/handler/im.go @@ -199,11 +199,13 @@ func doReceiveGenChatMessage(userId int, sessionID *uint, data *proto.WSMessageR var model dao.Model //查看请求功能类型 models, funcs := service.FindFuncModelByFunction(data.Function, userId) - //log.Println("find function model by function:", models, funcs) + log.Println("find function model by function:", models, funcs) + log.Println("funcs:", len(funcs), "\tmodels:", len(models)) if len(funcs) == 0 { return errors.New("function not exist") } if len(models) == 0 { + log.Println("doReceiveGenChatMessage models:", models) return errors.New("model not exist") } model = models[0] diff --git a/service/modelService.go b/service/modelService.go index 2ef3a1c..66fd137 100644 --- a/service/modelService.go +++ b/service/modelService.go @@ -116,5 +116,5 @@ func FindFuncModelByFunction(function string, userID int) ([]dao.Model, []dao.Fu } modelID := funcModels[0].ModelID //再查找对应模型 - return dao.FindModelByID(int(modelID), userID), funcModels + return dao.FindModelByModelID(modelID), funcModels }