質問編集履歴
1
Controllerの処理を追加
test
CHANGED
File without changes
|
test
CHANGED
@@ -27,6 +27,54 @@
|
|
27
27
|
```
|
28
28
|
|
29
29
|
|
30
|
+
|
31
|
+
### Controller
|
32
|
+
|
33
|
+
```
|
34
|
+
|
35
|
+
@RequestMapping(value = "/pizza/customer", method = RequestMethod.POST)
|
36
|
+
|
37
|
+
public String findCustomer(Model model, @RequestParam((String) "phone") String phone,@Validated(Shop.class) Shop shop) {
|
38
|
+
|
39
|
+
|
40
|
+
|
41
|
+
if(pizzaService.find(phone) != null) {//電話番号が見つかったら注文画面に進む
|
42
|
+
|
43
|
+
Customer customer = pizzaService.find(phone);
|
44
|
+
|
45
|
+
List<Product> products = pizzaService.findProducts();//商品リストを抽出
|
46
|
+
|
47
|
+
|
48
|
+
|
49
|
+
model.addAttribute("customer",customer);
|
50
|
+
|
51
|
+
model.addAttribute("orderRequest", new OrderRequest());
|
52
|
+
|
53
|
+
model.addAttribute("products", products);//商品リストをadd
|
54
|
+
|
55
|
+
|
56
|
+
|
57
|
+
return "/pizza/orderproduct";
|
58
|
+
|
59
|
+
}else {//見つからなかったら新規登録をする
|
60
|
+
|
61
|
+
CustomerCreateRequest createRequest = new CustomerCreateRequest();//顧客情報登録フォームをnewする
|
62
|
+
|
63
|
+
createRequest.setShopId(shop.getShopId());//どの店舗の顧客なのかshopIdをセットして判断する
|
64
|
+
|
65
|
+
|
66
|
+
|
67
|
+
model.addAttribute("createRequest",createRequest);//createcustomer.htmlににaddする
|
68
|
+
|
69
|
+
return "/pizza/createcustomer";
|
70
|
+
|
71
|
+
}
|
72
|
+
|
73
|
+
|
74
|
+
|
75
|
+
}
|
76
|
+
|
77
|
+
```
|
30
78
|
|
31
79
|
### htmlファイル
|
32
80
|
|