修改模型查找,添加日志输出

This commit is contained in:
junleea 2025-03-28 15:28:21 +08:00
parent 63f81760ae
commit b2c591cdb9
3 changed files with 15 additions and 2 deletions

View File

@ -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

View File

@ -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]

View File

@ -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
}