Skip to content

Commit b40ec9e

Browse files
committed
fix: 修复行为bug
1 parent c358d4e commit b40ec9e

File tree

3 files changed

+17
-27
lines changed

3 files changed

+17
-27
lines changed

engine.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ const (
2323
AppName = "QuarkGo"
2424

2525
// 版本号
26-
Version = "3.9.7"
26+
Version = "3.9.8"
2727

2828
// 包名
2929
PkgName = "github.com/quarkcloudio/quark-go/v3"

template/admin/resource/requests/action.go

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -46,42 +46,36 @@ func (p *ActionRequest) Handle(ctx *quark.Context) error {
4646
for _, dropdownAction := range dropdownActioner.GetActions() {
4747
uriKey := dropdownActioner.GetUriKey(dropdownAction)
4848
if ctx.Param("uriKey") == uriKey {
49-
// 行为执行完之前回调
49+
// 执行前回调
5050
err := template.BeforeAction(ctx, uriKey, model)
5151
if err != nil {
52-
return err
52+
return ctx.CJSONError(err.Error())
5353
}
5454

5555
result = dropdownAction.(interface {
5656
Handle(*quark.Context, *gorm.DB) error
5757
}).Handle(ctx, model)
5858

59-
// 执行完后回调
60-
err = template.AfterAction(ctx, uriKey, model)
61-
if err != nil {
62-
return err
63-
}
59+
// 执行完回调
60+
template.AfterAction(ctx, uriKey, model)
6461

6562
return result
6663
}
6764
}
6865
} else {
6966
if ctx.Param("uriKey") == uriKey {
70-
// 行为执行完之前回调
67+
// 执行前回调
7168
err := template.BeforeAction(ctx, uriKey, model)
7269
if err != nil {
73-
return err
70+
return ctx.CJSONError(err.Error())
7471
}
7572

7673
result = v.(interface {
7774
Handle(*quark.Context, *gorm.DB) error
7875
}).Handle(ctx, model)
7976

80-
// 执行完后回调
81-
err = template.AfterAction(ctx, uriKey, model)
82-
if err != nil {
83-
return err
84-
}
77+
// 执行完回调
78+
template.AfterAction(ctx, uriKey, model)
8579

8680
return result
8781
}

template/admin/resource/requests/editable.go

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -50,33 +50,29 @@ func (p *EditableRequest) Handle(ctx *quark.Context) error {
5050
}
5151
}
5252

53-
if field == "" {
54-
return ctx.CJSONError("参数错误")
55-
}
56-
57-
if value == nil {
53+
if field == "" || value == nil {
5854
return ctx.CJSONError("参数错误")
5955
}
6056

6157
// 表格行内编辑执行完之前回调
62-
result := template.BeforeEditable(ctx, id, field, value)
63-
if result != nil {
64-
return result
58+
err := template.BeforeEditable(ctx, id, field, value)
59+
if err != nil {
60+
return ctx.CJSONError(err.Error())
6561
}
6662

6763
// 创建表格行内编辑查询
6864
query := template.BuildEditableQuery(ctx, model)
6965

7066
// 更新数据
71-
err := query.Update(field, value).Error
67+
err = query.Update(field, value).Error
7268
if err != nil {
7369
return ctx.CJSONError(err.Error())
7470
}
7571

7672
// 行为执行后回调
77-
result = template.AfterEditable(ctx, id, field, value)
78-
if result != nil {
79-
return result
73+
err = template.AfterEditable(ctx, id, field, value)
74+
if err != nil {
75+
return ctx.CJSONError(err.Error())
8076
}
8177

8278
return ctx.CJSONOk("操作成功")

0 commit comments

Comments
 (0)