api层写法统一
This commit is contained in:
1 parent
fa30b8db95
commit
9bf9330410
40 files changed
+430
-316
No files matched your search
@@ -28,13 +28,13 @@ func DeleteAction(control dto.Control) gin.HandlerFunc {
|
||||
err = req.Bind(c)
|
||||
if err != nil {
|
||||
log.Errorf("MsgID[%s] Bind error: %s", msgID, err)
|
||||
app.Error(c, http.StatusUnprocessableEntity, err, "参数验证失败")
|
||||
response.Error(c, http.StatusUnprocessableEntity, err, "参数验证失败")
|
||||
return
|
||||
}
|
||||
var object models.ActiveRecord
|
||||
object, err = req.GenerateM()
|
||||
if err != nil {
|
||||
app.Error(c, http.StatusInternalServerError, err, "模型生成失败")
|
||||
response.Error(c, http.StatusInternalServerError, err, "模型生成失败")
|
||||
return
|
||||
}
|
||||
|
||||
@@ -48,14 +48,14 @@ func DeleteAction(control dto.Control) gin.HandlerFunc {
|
||||
).Where(req.GetId()).Delete(object)
|
||||
if db.Error != nil {
|
||||
log.Errorf("MsgID[%s] Delete error: %s", msgID, err)
|
||||
app.Error(c, http.StatusInternalServerError, err, "删除失败")
|
||||
response.Error(c, http.StatusInternalServerError, err, "删除失败")
|
||||
return
|
||||
}
|
||||
if db.RowsAffected == 0 {
|
||||
app.Error(c, http.StatusForbidden, nil, "无权删除该数据")
|
||||
response.Error(c, http.StatusForbidden, nil, "无权删除该数据")
|
||||
return
|
||||
}
|
||||
app.OK(c, object.GetId(), "删除成功")
|
||||
response.OK(c, object.GetId(), "删除成功")
|
||||
c.Next()
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user