|
|
@ -71,14 +71,17 @@ public class WebController { |
|
|
|
@GetMapping("/order") |
|
|
|
@GetMapping("/order") |
|
|
|
public String getOrder(Model model){ |
|
|
|
public String getOrder(Model model){ |
|
|
|
model.addAttribute(Constants.SPAN_NAME,"点餐画面"); |
|
|
|
model.addAttribute(Constants.SPAN_NAME,"点餐画面"); |
|
|
|
|
|
|
|
model.addAttribute(Constants.ACTION_NAME,"/api/order"); |
|
|
|
model.addAttribute(Constants.FENLEI,menuRepository.getFenlei()); |
|
|
|
model.addAttribute(Constants.FENLEI,menuRepository.getFenlei()); |
|
|
|
Diancan diancan= new Diancan(); |
|
|
|
Diancan diancan= new Diancan(); |
|
|
|
diancan.setRenshu(1); |
|
|
|
diancan.setRenshu(1); |
|
|
|
model.addAttribute(Constants.QUERY,diancan); |
|
|
|
model.addAttribute(Constants.QUERY,diancan); |
|
|
|
|
|
|
|
|
|
|
|
return "order"; |
|
|
|
return "order"; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@PostMapping("/order") |
|
|
|
@PostMapping("/order") |
|
|
|
|
|
|
|
@Transactional |
|
|
|
public void postOrder(Model model, HttpServletResponse response, DiancanForm diancanForm) throws IOException, ParseException { |
|
|
|
public void postOrder(Model model, HttpServletResponse response, DiancanForm diancanForm) throws IOException, ParseException { |
|
|
|
Diancan diancan=new Diancan(); |
|
|
|
Diancan diancan=new Diancan(); |
|
|
|
diancan.setZhuohao(diancanForm.getZhuohao()); |
|
|
|
diancan.setZhuohao(diancanForm.getZhuohao()); |
|
|
@ -106,6 +109,7 @@ public class WebController { |
|
|
|
@GetMapping("/order/{id}") |
|
|
|
@GetMapping("/order/{id}") |
|
|
|
public String getEditOrder(Model model,@PathVariable String id){ |
|
|
|
public String getEditOrder(Model model,@PathVariable String id){ |
|
|
|
model.addAttribute(Constants.SPAN_NAME,"修改画面"); |
|
|
|
model.addAttribute(Constants.SPAN_NAME,"修改画面"); |
|
|
|
|
|
|
|
model.addAttribute(Constants.ACTION_NAME,"/api/order/"+id); |
|
|
|
Diancan diancan=diancanRespository.getOne(id); |
|
|
|
Diancan diancan=diancanRespository.getOne(id); |
|
|
|
model.addAttribute(Constants.QUERY,diancan); |
|
|
|
model.addAttribute(Constants.QUERY,diancan); |
|
|
|
List<DiancanDetail> diancanDetails=diancanDetailRespository.findByZhuohao(diancan.getZhuohao()); |
|
|
|
List<DiancanDetail> diancanDetails=diancanDetailRespository.findByZhuohao(diancan.getZhuohao()); |
|
|
@ -115,7 +119,29 @@ public class WebController { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@PostMapping("/order/{id}") |
|
|
|
@PostMapping("/order/{id}") |
|
|
|
public void postEditOrder(Model model,@PathVariable String id,HttpServletResponse response) throws IOException { |
|
|
|
@Transactional |
|
|
|
|
|
|
|
public void postEditOrder(Model model,@PathVariable String id,HttpServletResponse response, DiancanForm diancanForm) throws IOException, ParseException { |
|
|
|
|
|
|
|
Diancan diancan=diancanRespository.getOne(diancanForm.getZhuohao()); |
|
|
|
|
|
|
|
diancan.setZhuohao(diancanForm.getZhuohao()); |
|
|
|
|
|
|
|
diancan.setXingming(diancanForm.getXingming()); |
|
|
|
|
|
|
|
diancan.setYuding(true); |
|
|
|
|
|
|
|
if("2".equals(diancanForm.getBirthday())&&!StringUtils.isEmpty(diancanForm.getShijian())) { |
|
|
|
|
|
|
|
Date date= new SimpleDateFormat("yyyyMMdd HHmm").parse(diancanForm.getShijian()); |
|
|
|
|
|
|
|
diancan.setBirthday(date); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
diancan.setRenshu(diancanForm.getRenshu()); |
|
|
|
|
|
|
|
diancan.setTel(diancanForm.getTel()); |
|
|
|
|
|
|
|
diancan.setJine(diancanForm.getJine()); |
|
|
|
|
|
|
|
diancan.setBeizhu(diancanForm.getBeizhu()); |
|
|
|
|
|
|
|
diancanRespository.save(diancan); |
|
|
|
|
|
|
|
diancanDetailRespository.deleteByZhuohao(diancan.getZhuohao()); |
|
|
|
|
|
|
|
for (CaiDan caiDan:diancanForm.getDiancans()){ |
|
|
|
|
|
|
|
DiancanDetail diancanDetail=new DiancanDetail(); |
|
|
|
|
|
|
|
diancanDetail.setZhuohao(diancan.getZhuohao()); |
|
|
|
|
|
|
|
diancanDetail.setSum(caiDan.getSum()); |
|
|
|
|
|
|
|
diancanDetail.setMenuId(caiDan.getCailiao()); |
|
|
|
|
|
|
|
diancanDetailRespository.save(diancanDetail); |
|
|
|
|
|
|
|
} |
|
|
|
response.sendRedirect("/api/index"); |
|
|
|
response.sendRedirect("/api/index"); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|