feat(park):已完成删除指定园区的功能。

This commit is contained in:
徐涛
2022-08-15 21:29:37 +08:00
parent cd98d0917a
commit 04417c0fca
2 changed files with 35 additions and 0 deletions

View File

@@ -49,3 +49,17 @@ func (_ParkService) ChangeParkState(uid, pid string, state bool) error {
}
return nil
}
func (_ParkService) DeletePark(uid, pid string) error {
rows, err := global.DBConn.
Where(builder.Eq{"id": pid, "user_id": uid}).
Delete(&model.Park{})
if err != nil {
if rows == 0 {
return exceptions.NewNotFoundError("未能找到符合条件的园区。")
} else {
return err
}
}
return nil
}