黑馬程序員Java項目實戰(zhàn)《瑞吉外賣》,輕松掌握springboot + myb

修改菜品狀態(tài)
①Cotroller
/** * 修改菜品狀態(tài) * @param status * @param ids * @return */ @PostMapping("/status/{status}") public R<String> status(@PathVariable int status,@RequestParam Long[] ids){ dishService.setStatus(status,ids); return R.success("修改菜品狀態(tài)成功"); }
②Impl
/** * 修改菜品狀態(tài) * * @param status * @param ids */ @Override @Transactional public void setStatus(int status, Long[] ids) { for (Long id : ids) { Dish dish = dishService.getById(id); if (dish.getStatus() != status) { dish.setStatus(status); } dishService.updateById(dish); } }
標(biāo)簽: