|
|
@@ -71,24 +71,19 @@ func (ctrl *CategoriesController) Update(c *gin.Context) {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-// func (ctrl *CategoriesController) Delete(c *gin.Context) {
|
|
|
-//
|
|
|
-// categoryModel := category.Get(c.Param("id"))
|
|
|
-// if categoryModel.ID == 0 {
|
|
|
-// response.Abort404(c)
|
|
|
-// return
|
|
|
-// }
|
|
|
-//
|
|
|
-// if ok := policies.CanModifyCategory(c, categoryModel); !ok {
|
|
|
-// response.Abort403(c)
|
|
|
-// return
|
|
|
-// }
|
|
|
-//
|
|
|
-// rowsAffected := categoryModel.Delete()
|
|
|
-// if rowsAffected > 0 {
|
|
|
-// response.Success(c)
|
|
|
-// return
|
|
|
-// }
|
|
|
-//
|
|
|
-// response.Abort500(c, "删除失败,请稍后尝试~")
|
|
|
-// }
|
|
|
+func (ctrl *CategoriesController) Delete(c *gin.Context) {
|
|
|
+
|
|
|
+ categoryModel := category.Get(c.Param("id"))
|
|
|
+ if categoryModel.ID == 0 {
|
|
|
+ response.Abort404(c)
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ rowsAffected := categoryModel.Delete()
|
|
|
+ if rowsAffected > 0 {
|
|
|
+ response.Success(c)
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ response.Abort500(c, "删除失败,请稍后尝试~")
|
|
|
+}
|