質問編集履歴
1
Controllerの処理を追加
title
CHANGED
File without changes
|
body
CHANGED
@@ -13,6 +13,30 @@
|
|
13
13
|
(anonymous) @ customer:12
|
14
14
|
```
|
15
15
|
|
16
|
+
### Controller
|
17
|
+
```
|
18
|
+
@RequestMapping(value = "/pizza/customer", method = RequestMethod.POST)
|
19
|
+
public String findCustomer(Model model, @RequestParam((String) "phone") String phone,@Validated(Shop.class) Shop shop) {
|
20
|
+
|
21
|
+
if(pizzaService.find(phone) != null) {//電話番号が見つかったら注文画面に進む
|
22
|
+
Customer customer = pizzaService.find(phone);
|
23
|
+
List<Product> products = pizzaService.findProducts();//商品リストを抽出
|
24
|
+
|
25
|
+
model.addAttribute("customer",customer);
|
26
|
+
model.addAttribute("orderRequest", new OrderRequest());
|
27
|
+
model.addAttribute("products", products);//商品リストをadd
|
28
|
+
|
29
|
+
return "/pizza/orderproduct";
|
30
|
+
}else {//見つからなかったら新規登録をする
|
31
|
+
CustomerCreateRequest createRequest = new CustomerCreateRequest();//顧客情報登録フォームをnewする
|
32
|
+
createRequest.setShopId(shop.getShopId());//どの店舗の顧客なのかshopIdをセットして判断する
|
33
|
+
|
34
|
+
model.addAttribute("createRequest",createRequest);//createcustomer.htmlににaddする
|
35
|
+
return "/pizza/createcustomer";
|
36
|
+
}
|
37
|
+
|
38
|
+
}
|
39
|
+
```
|
16
40
|
### htmlファイル
|
17
41
|
|
18
42
|
```ここに言語名を入力
|