支持view自定义返回

This commit is contained in:
linwenxiang
2020-09-23 00:35:07 +08:00
parent 78bb246390
commit c0ac9a6397
12 changed files with 73 additions and 56 deletions
+3 -4
View File
@@ -5,7 +5,6 @@ import (
"github.com/gin-gonic/gin"
"go-admin/common/apis"
"go-admin/common/dto"
"go-admin/common/log"
"go-admin/common/models"
@@ -16,7 +15,7 @@ import (
// DeleteAction 通用删除动作
func DeleteAction(control dto.Control) gin.HandlerFunc {
return func(c *gin.Context) {
db, err := apis.GetOrm(c)
db, err := tools.GetOrm(c)
if err != nil {
log.Error(err)
return
@@ -27,7 +26,7 @@ func DeleteAction(control dto.Control) gin.HandlerFunc {
req := control.Generate()
err = req.Bind(c)
if err != nil {
log.Errorf("MsgID[%s] Bind error: %#v", msgID, err)
log.Errorf("MsgID[%s] Bind error: %s", msgID, err)
app.Error(c, http.StatusUnprocessableEntity, err, "参数验证失败")
return
}
@@ -47,7 +46,7 @@ func DeleteAction(control dto.Control) gin.HandlerFunc {
Permission(object.TableName(), p),
).Where(req.GetId()).Delete(object)
if db.Error != nil {
log.Errorf("MsgID[%s] Delete error: %#v", msgID, err)
log.Errorf("MsgID[%s] Delete error: %s", msgID, err)
app.Error(c, http.StatusInternalServerError, err, "删除失败")
return
}