refactor(logging): 统一使用自定义Loger替代g.Log()日志记录
This commit is contained in:
@@ -65,30 +65,30 @@ func FillInitData(ctx g.Ctx, moduleName string, model IModel, ismod *bool) (bool
|
||||
mInit := g.DB("default").Model("base_sys_init")
|
||||
n, err := mInit.Clone().Where("group", model.GroupName()).Where("table", model.TableName()).Count()
|
||||
if err != nil {
|
||||
g.Log().Error(ctx, "读取表 base_sys_init 失败 ", err.Error())
|
||||
Loger.Error(ctx, "读取表 base_sys_init 失败 ", err.Error())
|
||||
return false, err
|
||||
}
|
||||
if n > 0 {
|
||||
g.Log().Debug(ctx, "分组", model.GroupName(), "中的表", model.TableName(), "已经初始化过,跳过本次初始化.")
|
||||
Loger.Debug(ctx, "分组", model.GroupName(), "中的表", model.TableName(), "已经初始化过,跳过本次初始化.")
|
||||
return false, err
|
||||
}
|
||||
m := g.DB(model.GroupName()).Model(model.TableName())
|
||||
jsonData, _ := gjson.LoadContent(gres.GetContent("modules/" + moduleName + "/resource/initjson/" + model.TableName() + ".json"))
|
||||
if jsonData.Var().Clone().IsEmpty() {
|
||||
g.Log().Debug(ctx, "分组", model.GroupName(), "中的表", model.TableName(), "无可用的初始化数据,跳过本次初始化.")
|
||||
Loger.Debug(ctx, "分组", model.GroupName(), "中的表", model.TableName(), "无可用的初始化数据,跳过本次初始化.")
|
||||
return false, err
|
||||
}
|
||||
_, err = m.Data(jsonData).Insert()
|
||||
if err != nil {
|
||||
g.Log().Error(ctx, err.Error())
|
||||
Loger.Error(ctx, err.Error())
|
||||
return false, err
|
||||
}
|
||||
_, err = mInit.Insert(g.Map{"group": model.GroupName(), "table": model.TableName()})
|
||||
if err != nil {
|
||||
g.Log().Error(ctx, err.Error())
|
||||
Loger.Error(ctx, err.Error())
|
||||
return false, err
|
||||
}
|
||||
g.Log().Info(ctx, "分组", model.GroupName(), "中的表", model.TableName(), "初始化完成.")
|
||||
Loger.Info(ctx, "分组", model.GroupName(), "中的表", model.TableName(), "初始化完成.")
|
||||
if ismod != nil {
|
||||
*ismod = true
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user