兼容批量删除
This commit is contained in:
1 parent
560e650070
commit
0ae41f247c
5 files changed
+28
-7
No files matched your search
@@ -39,7 +39,7 @@ func DeleteAction(control dto.Control) gin.HandlerFunc {
|
||||
|
||||
db = db.WithContext(c).Scopes(
|
||||
Permission(object.TableName(), p),
|
||||
).Delete(object)
|
||||
).Where(req.GetId()).Delete(object)
|
||||
tools.HasError(db.Error, "删除失败", 500)
|
||||
if db.RowsAffected == 0 {
|
||||
err = errors.New("无权删除该数据")
|
||||
|
||||
@@ -38,7 +38,7 @@ func UpdateAction(control dto.Control) gin.HandlerFunc {
|
||||
|
||||
db = db.WithContext(c).Scopes(
|
||||
Permission(object.TableName(), p),
|
||||
).Updates(object)
|
||||
).Where(req.GetId()).Updates(object)
|
||||
tools.HasError(db.Error, "更新失败", 500)
|
||||
if db.RowsAffected == 0 {
|
||||
err = errors.New("无权更新该数据")
|
||||
|
||||
@@ -37,7 +37,7 @@ func ViewAction(control dto.Control) gin.HandlerFunc {
|
||||
|
||||
err = db.WithContext(c).Scopes(
|
||||
Permission(object.TableName(), p),
|
||||
).First(object).Error
|
||||
).Where(req.GetId()).First(object).Error
|
||||
if errors.Is(err, gorm.ErrRecordNotFound) {
|
||||
tools.HasError(err, "查看失败", 404)
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user