質問編集履歴

4

item.stockのあるコードを追加。

2018/06/18 04:05

投稿

akuram
akuram

スコア8

test CHANGED
File without changes
test CHANGED
@@ -323,3 +323,101 @@
323
323
 
324
324
 
325
325
  ```
326
+
327
+
328
+
329
+ ```item_detail.html
330
+
331
+ <!DOCTYPE html>
332
+
333
+ <html xmlns:th="http://www.thymeleaf.org"
334
+
335
+ xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout"
336
+
337
+ layout:decorator="common/layout_4block">
338
+
339
+ <head>
340
+
341
+ <title>商品詳細</title>
342
+
343
+ </head>
344
+
345
+ <body class="user item_detail">
346
+
347
+ <th:block layout:fragment="layout-main">
348
+
349
+ <h2 class="title">商品詳細</h2>
350
+
351
+ <div class="item_info_form_area">
352
+
353
+ <div class="item_detail_area">
354
+
355
+ <div class="item_image_area">
356
+
357
+ <span th:if="${item.image != null}">
358
+
359
+ <img th:src="@{/img/{image}(image=${item.image})}"></img>
360
+
361
+ </span>
362
+
363
+ <span th:if="${item.image == null}">
364
+
365
+ <img th:src="@{/img/common/no_image.jpg}"></img>
366
+
367
+ </span>
368
+
369
+ </div>
370
+
371
+ <dl class="item_detail_list">
372
+
373
+ <dt>商品名:</dt>
374
+
375
+ <dd th:text="${item.name}"></dd>
376
+
377
+ <dt>価格:</dt>
378
+
379
+ <dd th:text="${item.price}"></dd>
380
+
381
+ <dt>在庫:</dt>
382
+
383
+ <dd th:text="${item.stock}" th:if = "${item.stock != 0}"></dd>
384
+
385
+ <dd th:text="在庫なし" th:if = "${item.stock == 0}"></dd>
386
+
387
+ <dt>カテゴリ:</dt>
388
+
389
+ <dd th:text="${item.category.name}"></dd>
390
+
391
+ <dt>説明:</dt>
392
+
393
+ <dd th:text="${item.description}"></dd>
394
+
395
+ </dl>
396
+
397
+ </div>
398
+
399
+ <form method="post" class="user_info_form" th:action="@{/basket/add}">
400
+
401
+ <input type="hidden" name="id" th:value="${item.id}" />
402
+
403
+ <input type="hidden" name="name" th:value="${item.name}" />
404
+
405
+ <input type="submit" value="買い物かごに入れる" class="send_button" />
406
+
407
+ </form>
408
+
409
+ <form th:action="@{/}">
410
+
411
+ <input type="submit" value="戻る" class="back_button" />
412
+
413
+ </form>
414
+
415
+ </div> </th:block>
416
+
417
+
418
+
419
+ </body>
420
+
421
+ </html>
422
+
423
+ ```

3

修正

2018/06/18 04:05

投稿

akuram
akuram

スコア8

test CHANGED
File without changes
test CHANGED
@@ -222,7 +222,7 @@
222
222
 
223
223
  <head>
224
224
 
225
- <title>お届け先入力 | シェアードショップ</title>
225
+ <title>お届け先入力 </title>
226
226
 
227
227
  </head>
228
228
 

2

コード記述

2018/06/18 03:01

投稿

akuram
akuram

スコア8

test CHANGED
File without changes
test CHANGED
@@ -6,7 +6,63 @@
6
6
 
7
7
 
8
8
 
9
+ ```OrderRegistCustomerContoller
10
+
11
+ @Controller
12
+
13
+ public class OrderRegistCustomerContoller {
14
+
15
+
16
+
9
- ```Spring
17
+ @Autowired
18
+
19
+ HttpSession session;
20
+
21
+
22
+
23
+ @Autowired
24
+
25
+ OrderItemRepository orderItemRepository;
26
+
27
+
28
+
29
+ @Autowired
30
+
31
+ OrderRepository orderRepository;
32
+
33
+
34
+
35
+ @Autowired
36
+
37
+ UserRepository userRepository;
38
+
39
+
40
+
41
+ @RequestMapping(path = "/address/input", method = RequestMethod.POST)
42
+
43
+ public String oderRegistAddressInput(Model model, @ModelAttribute BasketForm basketForm, UserForm userForm){
44
+
45
+ Order order = orderRepository.getOne(userForm.getId());
46
+
47
+ OrderBean orderBean = new OrderBean();
48
+
49
+
50
+
51
+ BeanUtils.copyProperties(order, orderBean);
52
+
53
+
54
+
55
+ model.addAttribute("order", orderBean);
56
+
57
+
58
+
59
+ /**
60
+
61
+ ここで比較しようとしています。
62
+
63
+ */
64
+
65
+
10
66
 
11
67
  if("${Basket.stock}"<="${item.stock}"){
12
68
 
@@ -14,8 +70,256 @@
14
70
 
15
71
  }
16
72
 
73
+ }
74
+
75
+
76
+
77
+ }
78
+
17
79
  ```
18
80
 
19
81
 
20
82
 
83
+ ```basket_list.html
84
+
21
- どのような形で比較すればよいのでしょうか?
85
+ <!DOCTYPE html>
86
+
87
+
88
+
89
+ <html xmlns:th="http://www.thymeleaf.org"
90
+
91
+ xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout"
92
+
93
+ layout:decorator="common/layout_5block">
94
+
95
+ <head></head>
96
+
97
+ <body class="user shopping_basket">
98
+
99
+ <th:block layout:fragment="layout-main" >
100
+
101
+ <h2 class="title" >買い物かご</h2>
102
+
103
+ <div th:if="${session.basketList == 1}">
104
+
105
+ <p>現在、お客様の買い物かごには商品がありません。商品をお選びください。</p>
106
+
107
+ </div>
108
+
109
+ <table class="list_table basket" th:if="${session.basketList == 0}">
110
+
111
+ <tr>
112
+
113
+ <th>商品名</th>
114
+
115
+ <th>個数</th>
116
+
117
+ <th>操作</th>
118
+
119
+ </tr>
120
+
121
+
122
+
123
+ <tr th:each = "Basket: ${session.basket}">
124
+
125
+ <td><a th:href="@{/item/detail/{id}(id=${Basket.id})}" th:text = "${Basket.name}" ></a></td>
126
+
127
+ <td th:text = "${Basket.stock}"></td>
128
+
129
+ <td >
130
+
131
+ <form method="post" th:action="@{/basket/subtractcount}">
132
+
133
+ <input type="hidden" name="id" th:value="${Basket.id}" />
134
+
135
+ <input type="hidden" name="orderNum" th:value="${Basket.stock}" />
136
+
137
+ <input type="submit" value="個数-1" />
138
+
139
+ </form>
140
+
141
+ <form method="post" th:action="@{/basket/addcount}">
142
+
143
+ <input type="hidden" name="id" th:value="${Basket.id}" />
144
+
145
+ <input type="hidden" name="orderNum" th:value="${Basket.stock}" />
146
+
147
+ <input type="submit" value="個数+1" />
148
+
149
+ </form>
150
+
151
+ <form method="post" th:action="@{/basket/delete}">
152
+
153
+ <input type="hidden" name="id" th:value="${Basket.id}" />
154
+
155
+ <input type="submit" value="削除" class="delete" />
156
+
157
+ </form>
158
+
159
+ </td>
160
+
161
+ </tr>
162
+
163
+ </table>
164
+
165
+
166
+
167
+
168
+
169
+ <div class="user_info_form_area" th:if="${session.basketList == 0}">
170
+
171
+
172
+
173
+ <form method="post" th:action="@{/address/input}" >
174
+
175
+ <span>
176
+
177
+ <input type="hidden" name="itemId" value="1" />
178
+
179
+ <input type="hidden" name="orderNum" value="1" />
180
+
181
+ <input type="hidden" name="id" th:value="${session.user.id}" />
182
+
183
+ </span>
184
+
185
+ <input type="submit" value="ご注文のお手続き" />
186
+
187
+ </form>
188
+
189
+
190
+
191
+ <form method="post" th:action="@{/basket/allDelete/}">
192
+
193
+ <input type="submit" value="買い物かごを空にする" class="delete" />
194
+
195
+ </form>
196
+
197
+ </div>
198
+
199
+ </th:block>
200
+
201
+ </body>
202
+
203
+ </html>
204
+
205
+
206
+
207
+ ```
208
+
209
+
210
+
211
+ ```address_input.html
212
+
213
+ <!DOCTYPE html>
214
+
215
+
216
+
217
+ <html xmlns:th="http://www.thymeleaf.org"
218
+
219
+ xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout"
220
+
221
+ layout:decorator="common/layout_5block">
222
+
223
+ <head>
224
+
225
+ <title>お届け先入力 | シェアードショップ</title>
226
+
227
+ </head>
228
+
229
+ <body class="user order_list">
230
+
231
+ <th:block layout:fragment="layout-main">
232
+
233
+ <h2 class="title">お届け先入力</h2>
234
+
235
+ <div class="user_info_form_area">
236
+
237
+ <form method="post" th:action="@{/payment/input}">
238
+
239
+ <ul class="input_list">
240
+
241
+ <li>
242
+
243
+ <label>
244
+
245
+ <span class="input_title">郵便番号</span>
246
+
247
+ <input type="text" name="postalCode" th:value="${order.postalCode}" />
248
+
249
+ </label>
250
+
251
+
252
+
253
+ </li>
254
+
255
+ <li>
256
+
257
+ <label>
258
+
259
+ <span class="input_title">住所</span>
260
+
261
+ <textarea name="address" rows="6" th:text="${order.address}"></textarea>
262
+
263
+ </label>
264
+
265
+
266
+
267
+ </li>
268
+
269
+ <li>
270
+
271
+ <label>
272
+
273
+ <span class="input_title">氏名</span>
274
+
275
+ <input type="text" name="name" th:value="${order.name}" />
276
+
277
+ </label>
278
+
279
+
280
+
281
+ </li>
282
+
283
+ <li>
284
+
285
+ <label>
286
+
287
+ <span class="input_title">電話番号</span>
288
+
289
+ <input type="text" name="phoneNumber" th:value="${order.phoneNumber}" />
290
+
291
+ </label>
292
+
293
+
294
+
295
+ </li>
296
+
297
+ </ul>
298
+
299
+ <input type="hidden" name="id" th:value="${session.user.id}" />
300
+
301
+ <input type="submit" value="次へ" class="send_button" />
302
+
303
+ </form>
304
+
305
+ <form th:action="@{/basket/list/1}">
306
+
307
+ <input type="submit" value="戻る" class="back_button" />
308
+
309
+ </form>
310
+
311
+ </div>
312
+
313
+
314
+
315
+
316
+
317
+ </th:block>
318
+
319
+ </body>
320
+
321
+ </html>
322
+
323
+
324
+
325
+ ```

1

タイトルを変更しました。

2018/06/18 03:00

投稿

akuram
akuram

スコア8

test CHANGED
@@ -1 +1 @@
1
- ショッピングサイトのかごシステム作っていす。
1
+ 数値呼び出し比較がしたす。
test CHANGED
File without changes