質問編集履歴
4
item.stockのあるコードを追加。
title
CHANGED
File without changes
|
body
CHANGED
@@ -160,4 +160,53 @@
|
|
160
160
|
</body>
|
161
161
|
</html>
|
162
162
|
|
163
|
+
```
|
164
|
+
|
165
|
+
```item_detail.html
|
166
|
+
<!DOCTYPE html>
|
167
|
+
<html xmlns:th="http://www.thymeleaf.org"
|
168
|
+
xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout"
|
169
|
+
layout:decorator="common/layout_4block">
|
170
|
+
<head>
|
171
|
+
<title>商品詳細</title>
|
172
|
+
</head>
|
173
|
+
<body class="user item_detail">
|
174
|
+
<th:block layout:fragment="layout-main">
|
175
|
+
<h2 class="title">商品詳細</h2>
|
176
|
+
<div class="item_info_form_area">
|
177
|
+
<div class="item_detail_area">
|
178
|
+
<div class="item_image_area">
|
179
|
+
<span th:if="${item.image != null}">
|
180
|
+
<img th:src="@{/img/{image}(image=${item.image})}"></img>
|
181
|
+
</span>
|
182
|
+
<span th:if="${item.image == null}">
|
183
|
+
<img th:src="@{/img/common/no_image.jpg}"></img>
|
184
|
+
</span>
|
185
|
+
</div>
|
186
|
+
<dl class="item_detail_list">
|
187
|
+
<dt>商品名:</dt>
|
188
|
+
<dd th:text="${item.name}"></dd>
|
189
|
+
<dt>価格:</dt>
|
190
|
+
<dd th:text="${item.price}"></dd>
|
191
|
+
<dt>在庫:</dt>
|
192
|
+
<dd th:text="${item.stock}" th:if = "${item.stock != 0}"></dd>
|
193
|
+
<dd th:text="在庫なし" th:if = "${item.stock == 0}"></dd>
|
194
|
+
<dt>カテゴリ:</dt>
|
195
|
+
<dd th:text="${item.category.name}"></dd>
|
196
|
+
<dt>説明:</dt>
|
197
|
+
<dd th:text="${item.description}"></dd>
|
198
|
+
</dl>
|
199
|
+
</div>
|
200
|
+
<form method="post" class="user_info_form" th:action="@{/basket/add}">
|
201
|
+
<input type="hidden" name="id" th:value="${item.id}" />
|
202
|
+
<input type="hidden" name="name" th:value="${item.name}" />
|
203
|
+
<input type="submit" value="買い物かごに入れる" class="send_button" />
|
204
|
+
</form>
|
205
|
+
<form th:action="@{/}">
|
206
|
+
<input type="submit" value="戻る" class="back_button" />
|
207
|
+
</form>
|
208
|
+
</div> </th:block>
|
209
|
+
|
210
|
+
</body>
|
211
|
+
</html>
|
163
212
|
```
|
3
修正
title
CHANGED
File without changes
|
body
CHANGED
@@ -110,7 +110,7 @@
|
|
110
110
|
xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout"
|
111
111
|
layout:decorator="common/layout_5block">
|
112
112
|
<head>
|
113
|
-
<title>お届け先入力
|
113
|
+
<title>お届け先入力 </title>
|
114
114
|
</head>
|
115
115
|
<body class="user order_list">
|
116
116
|
<th:block layout:fragment="layout-main">
|
2
コード記述
title
CHANGED
File without changes
|
body
CHANGED
@@ -2,10 +2,162 @@
|
|
2
2
|
個数を指定、次の画面に遷移した際に在庫が足りなければエラーページに行かせたいです。
|
3
3
|
しかし、比較がうまくいかず、以下の文では文字列を演算子で処理できないと出ます。
|
4
4
|
|
5
|
+
```OrderRegistCustomerContoller
|
6
|
+
@Controller
|
7
|
+
public class OrderRegistCustomerContoller {
|
8
|
+
|
5
|
-
|
9
|
+
@Autowired
|
10
|
+
HttpSession session;
|
11
|
+
|
12
|
+
@Autowired
|
13
|
+
OrderItemRepository orderItemRepository;
|
14
|
+
|
15
|
+
@Autowired
|
16
|
+
OrderRepository orderRepository;
|
17
|
+
|
18
|
+
@Autowired
|
19
|
+
UserRepository userRepository;
|
20
|
+
|
21
|
+
@RequestMapping(path = "/address/input", method = RequestMethod.POST)
|
22
|
+
public String oderRegistAddressInput(Model model, @ModelAttribute BasketForm basketForm, UserForm userForm){
|
23
|
+
Order order = orderRepository.getOne(userForm.getId());
|
24
|
+
OrderBean orderBean = new OrderBean();
|
25
|
+
|
26
|
+
BeanUtils.copyProperties(order, orderBean);
|
27
|
+
|
28
|
+
model.addAttribute("order", orderBean);
|
29
|
+
|
30
|
+
/**
|
31
|
+
ここで比較しようとしています。
|
32
|
+
*/
|
33
|
+
|
6
34
|
if("${Basket.stock}"<="${item.stock}"){
|
7
35
|
return "order/regist/address_input";
|
8
36
|
}
|
37
|
+
}
|
38
|
+
|
39
|
+
}
|
9
40
|
```
|
10
41
|
|
42
|
+
```basket_list.html
|
11
|
-
|
43
|
+
<!DOCTYPE html>
|
44
|
+
|
45
|
+
<html xmlns:th="http://www.thymeleaf.org"
|
46
|
+
xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout"
|
47
|
+
layout:decorator="common/layout_5block">
|
48
|
+
<head></head>
|
49
|
+
<body class="user shopping_basket">
|
50
|
+
<th:block layout:fragment="layout-main" >
|
51
|
+
<h2 class="title" >買い物かご</h2>
|
52
|
+
<div th:if="${session.basketList == 1}">
|
53
|
+
<p>現在、お客様の買い物かごには商品がありません。商品をお選びください。</p>
|
54
|
+
</div>
|
55
|
+
<table class="list_table basket" th:if="${session.basketList == 0}">
|
56
|
+
<tr>
|
57
|
+
<th>商品名</th>
|
58
|
+
<th>個数</th>
|
59
|
+
<th>操作</th>
|
60
|
+
</tr>
|
61
|
+
|
62
|
+
<tr th:each = "Basket: ${session.basket}">
|
63
|
+
<td><a th:href="@{/item/detail/{id}(id=${Basket.id})}" th:text = "${Basket.name}" ></a></td>
|
64
|
+
<td th:text = "${Basket.stock}"></td>
|
65
|
+
<td >
|
66
|
+
<form method="post" th:action="@{/basket/subtractcount}">
|
67
|
+
<input type="hidden" name="id" th:value="${Basket.id}" />
|
68
|
+
<input type="hidden" name="orderNum" th:value="${Basket.stock}" />
|
69
|
+
<input type="submit" value="個数-1" />
|
70
|
+
</form>
|
71
|
+
<form method="post" th:action="@{/basket/addcount}">
|
72
|
+
<input type="hidden" name="id" th:value="${Basket.id}" />
|
73
|
+
<input type="hidden" name="orderNum" th:value="${Basket.stock}" />
|
74
|
+
<input type="submit" value="個数+1" />
|
75
|
+
</form>
|
76
|
+
<form method="post" th:action="@{/basket/delete}">
|
77
|
+
<input type="hidden" name="id" th:value="${Basket.id}" />
|
78
|
+
<input type="submit" value="削除" class="delete" />
|
79
|
+
</form>
|
80
|
+
</td>
|
81
|
+
</tr>
|
82
|
+
</table>
|
83
|
+
|
84
|
+
|
85
|
+
<div class="user_info_form_area" th:if="${session.basketList == 0}">
|
86
|
+
|
87
|
+
<form method="post" th:action="@{/address/input}" >
|
88
|
+
<span>
|
89
|
+
<input type="hidden" name="itemId" value="1" />
|
90
|
+
<input type="hidden" name="orderNum" value="1" />
|
91
|
+
<input type="hidden" name="id" th:value="${session.user.id}" />
|
92
|
+
</span>
|
93
|
+
<input type="submit" value="ご注文のお手続き" />
|
94
|
+
</form>
|
95
|
+
|
96
|
+
<form method="post" th:action="@{/basket/allDelete/}">
|
97
|
+
<input type="submit" value="買い物かごを空にする" class="delete" />
|
98
|
+
</form>
|
99
|
+
</div>
|
100
|
+
</th:block>
|
101
|
+
</body>
|
102
|
+
</html>
|
103
|
+
|
104
|
+
```
|
105
|
+
|
106
|
+
```address_input.html
|
107
|
+
<!DOCTYPE html>
|
108
|
+
|
109
|
+
<html xmlns:th="http://www.thymeleaf.org"
|
110
|
+
xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout"
|
111
|
+
layout:decorator="common/layout_5block">
|
112
|
+
<head>
|
113
|
+
<title>お届け先入力 | シェアードショップ</title>
|
114
|
+
</head>
|
115
|
+
<body class="user order_list">
|
116
|
+
<th:block layout:fragment="layout-main">
|
117
|
+
<h2 class="title">お届け先入力</h2>
|
118
|
+
<div class="user_info_form_area">
|
119
|
+
<form method="post" th:action="@{/payment/input}">
|
120
|
+
<ul class="input_list">
|
121
|
+
<li>
|
122
|
+
<label>
|
123
|
+
<span class="input_title">郵便番号</span>
|
124
|
+
<input type="text" name="postalCode" th:value="${order.postalCode}" />
|
125
|
+
</label>
|
126
|
+
|
127
|
+
</li>
|
128
|
+
<li>
|
129
|
+
<label>
|
130
|
+
<span class="input_title">住所</span>
|
131
|
+
<textarea name="address" rows="6" th:text="${order.address}"></textarea>
|
132
|
+
</label>
|
133
|
+
|
134
|
+
</li>
|
135
|
+
<li>
|
136
|
+
<label>
|
137
|
+
<span class="input_title">氏名</span>
|
138
|
+
<input type="text" name="name" th:value="${order.name}" />
|
139
|
+
</label>
|
140
|
+
|
141
|
+
</li>
|
142
|
+
<li>
|
143
|
+
<label>
|
144
|
+
<span class="input_title">電話番号</span>
|
145
|
+
<input type="text" name="phoneNumber" th:value="${order.phoneNumber}" />
|
146
|
+
</label>
|
147
|
+
|
148
|
+
</li>
|
149
|
+
</ul>
|
150
|
+
<input type="hidden" name="id" th:value="${session.user.id}" />
|
151
|
+
<input type="submit" value="次へ" class="send_button" />
|
152
|
+
</form>
|
153
|
+
<form th:action="@{/basket/list/1}">
|
154
|
+
<input type="submit" value="戻る" class="back_button" />
|
155
|
+
</form>
|
156
|
+
</div>
|
157
|
+
|
158
|
+
|
159
|
+
</th:block>
|
160
|
+
</body>
|
161
|
+
</html>
|
162
|
+
|
163
|
+
```
|
1
タイトルを変更しました。
title
CHANGED
@@ -1,1 +1,1 @@
|
|
1
|
-
|
1
|
+
数値を呼び出して比較がしたいです。
|
body
CHANGED
File without changes
|