修改模型查找,添加日志输出
This commit is contained in:
parent
63f81760ae
commit
b2c591cdb9
11
dao/model.go
11
dao/model.go
|
|
@ -46,6 +46,17 @@ func FindModelByID(id, userID int) []Model {
|
||||||
return 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查找模型
|
// 根据用户id查找模型
|
||||||
func FindModelByUserID(userID int) []Model {
|
func FindModelByUserID(userID int) []Model {
|
||||||
var models []Model
|
var models []Model
|
||||||
|
|
|
||||||
|
|
@ -199,11 +199,13 @@ func doReceiveGenChatMessage(userId int, sessionID *uint, data *proto.WSMessageR
|
||||||
var model dao.Model
|
var model dao.Model
|
||||||
//查看请求功能类型
|
//查看请求功能类型
|
||||||
models, funcs := service.FindFuncModelByFunction(data.Function, userId)
|
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 {
|
if len(funcs) == 0 {
|
||||||
return errors.New("function not exist")
|
return errors.New("function not exist")
|
||||||
}
|
}
|
||||||
if len(models) == 0 {
|
if len(models) == 0 {
|
||||||
|
log.Println("doReceiveGenChatMessage models:", models)
|
||||||
return errors.New("model not exist")
|
return errors.New("model not exist")
|
||||||
}
|
}
|
||||||
model = models[0]
|
model = models[0]
|
||||||
|
|
|
||||||
|
|
@ -116,5 +116,5 @@ func FindFuncModelByFunction(function string, userID int) ([]dao.Model, []dao.Fu
|
||||||
}
|
}
|
||||||
modelID := funcModels[0].ModelID
|
modelID := funcModels[0].ModelID
|
||||||
//再查找对应模型
|
//再查找对应模型
|
||||||
return dao.FindModelByID(int(modelID), userID), funcModels
|
return dao.FindModelByModelID(modelID), funcModels
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue