mirror of
https://github.com/bufanyun/hotgo.git
synced 2025-08-26 16:46:14 +08:00
fix 修复websocket在某些情况下不重连问题
fix 修复登录日志查看权限 feat 访问日志增加接口信息显示 perf 为所有orm的Insert操作增加OmitEmptyData选项
This commit is contained in:
@@ -65,7 +65,7 @@ func Install(m Module) (err error) {
|
||||
_, _ = GetModel(m.Ctx()).Where("id", record.Id).Delete()
|
||||
}
|
||||
|
||||
if _, err = GetModel(m.Ctx()).Data(data).Insert(); err != nil {
|
||||
if _, err = GetModel(m.Ctx()).Data(data).OmitEmptyData().Insert(); err != nil {
|
||||
return err
|
||||
}
|
||||
return m.Install(ctx)
|
||||
|
@@ -151,7 +151,7 @@ func (a *adapter) SavePolicy(model model.Model) (err error) {
|
||||
}
|
||||
|
||||
if count := len(policyRules); count > 0 {
|
||||
if _, err = a.model().Insert(policyRules); err != nil {
|
||||
if _, err = a.model().OmitEmptyData().Insert(policyRules); err != nil {
|
||||
return
|
||||
}
|
||||
}
|
||||
@@ -160,7 +160,7 @@ func (a *adapter) SavePolicy(model model.Model) (err error) {
|
||||
|
||||
// AddPolicy adds a policy rule to the storage.
|
||||
func (a *adapter) AddPolicy(sec string, ptype string, rule []string) (err error) {
|
||||
_, err = a.model().Insert(a.buildPolicyRule(ptype, rule))
|
||||
_, err = a.model().OmitEmptyData().Insert(a.buildPolicyRule(ptype, rule))
|
||||
return
|
||||
}
|
||||
|
||||
@@ -176,7 +176,7 @@ func (a *adapter) AddPolicies(sec string, ptype string, rules [][]string) (err e
|
||||
policyRules = append(policyRules, a.buildPolicyRule(ptype, rule))
|
||||
}
|
||||
|
||||
_, err = a.model().Insert(policyRules)
|
||||
_, err = a.model().OmitEmptyData().Insert(policyRules)
|
||||
return
|
||||
}
|
||||
|
||||
|
@@ -19,7 +19,7 @@ const (
|
||||
LogicWhereComments = "\n\t// 查询%s\n"
|
||||
LogicWhereNoSupport = "\t// TODO 暂不支持生成[ %s ]查询方式,请自行补充此处代码!"
|
||||
LogicEditUpdate = "\tif _, err = s.Model(ctx%s).\n\t\t\tFields(%sin.%sUpdateFields{}).\n\t\t\tWherePri(in.%s).Data(in).Update(); err != nil {\n\t\t\terr = gerror.Wrap(err, \"修改%s失败,请稍后重试!\")\n\t\t}\n\t\treturn"
|
||||
LogicEditInsert = "\tif _, err = s.Model(ctx, &handler.Option{FilterAuth: false}).\n\t\tFields(%sin.%sInsertFields{}).\n\t\tData(in).Insert(); err != nil {\n\t\terr = gerror.Wrap(err, \"新增%s失败,请稍后重试!\")\n\t}"
|
||||
LogicEditInsert = "\tif _, err = s.Model(ctx, &handler.Option{FilterAuth: false}).\n\t\tFields(%sin.%sInsertFields{}).\n\t\tData(in).OmitEmptyData().Insert(); err != nil {\n\t\terr = gerror.Wrap(err, \"新增%s失败,请稍后重试!\")\n\t}"
|
||||
LogicEditUnique = "\t// 验证'%s'唯一\n\tif err = hgorm.IsUnique(ctx, &dao.%s, g.Map{dao.%s.Columns().%s: in.%s}, \"%s已存在\", in.Id); err != nil {\n\t\treturn\n\t}\n"
|
||||
LogicSwitchUpdate = "g.Map{\n\t\tin.Key: in.Value,\n%s}"
|
||||
LogicStatusUpdate = "g.Map{\n\t\tdao.%s.Columns().Status: in.Status,\n%s}"
|
||||
|
@@ -50,7 +50,7 @@ func TestSaveTenant_User(t *testing.T) {
|
||||
cols.Status: consts.PayStatusWait,
|
||||
}
|
||||
|
||||
_, err := dao.AddonHgexampleTenantOrder.Ctx(ctx).Data(data).Hook(hook.SaveTenant).Insert()
|
||||
_, err := dao.AddonHgexampleTenantOrder.Ctx(ctx).Data(data).Hook(hook.SaveTenant).OmitEmptyData().Insert()
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
@@ -233,7 +233,7 @@ func write(ctx context.Context, meta *FileMeta, fullPath string) (models *entity
|
||||
Status: consts.StatusEnabled,
|
||||
}
|
||||
|
||||
id, err := GetModel(ctx).Data(models).InsertAndGetId()
|
||||
id, err := GetModel(ctx).Data(models).OmitEmptyData().InsertAndGetId()
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
Reference in New Issue
Block a user