Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
E
Ecsite
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
shoei.kanno
Ecsite
Commits
fbfe7bf2
Commit
fbfe7bf2
authored
Oct 21, 2020
by
keita.onoguchi
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'カート画面js' into 'master'
カート画面編集途中 See merge request
!50
parents
61493dbd
1831cf9a
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
22 additions
and
6 deletions
+22
-6
EcsiteRestController.java
src/main/java/com/example/api/EcsiteRestController.java
+15
-3
cart.js
src/main/resources/static/js/cart.js
+6
-2
cart.html
src/main/resources/templates/cart.html
+1
-1
No files found.
src/main/java/com/example/api/EcsiteRestController.java
View file @
fbfe7bf2
...
...
@@ -44,6 +44,7 @@ public class EcsiteRestController {
@Autowired
ShoesService
shoesService
;
int
totalPrice
;
String
sameId
;
//アカウント新規登録
@PostMapping
(
"signUp"
)
...
...
@@ -81,12 +82,22 @@ public class EcsiteRestController {
//セッションがnull出ない場合
}
else
{
//HashMapを生成
ArrayList
<
String
>
list
=
new
ArrayList
<
String
>
();
LinkedHashMap
<
String
,
Items
>
cart
=
new
LinkedHashMap
<
String
,
Items
>();
String
id
=
data
.
getShoesId
().
toString
();
//生成したHashMapにセッションにもともとある情報を照会させる。
cart
=
(
LinkedHashMap
<
String
,
Items
>)
session
.
getAttribute
(
"cart"
);
//HashMapに靴のIdをKeyとして、Valueに靴の情報を入れる。
cart
.
put
(
id
,
itemsService
.
findOne
(
data
.
getShoesId
(),
data
.
getQuantity
()));
cart
.
forEach
((
key
,
value
)
->{
if
(
key
.
equals
(
id
)){
sameId
=
key
;
}
});
if
(
sameId
.
equals
(
id
)){
cart
.
put
(
id
,
itemsService
.
findOne
(
data
.
getShoesId
(),
data
.
getQuantity
()
+
cart
.
get
(
id
).
getQuantity
()));
}
else
{
cart
.
put
(
id
,
itemsService
.
findOne
(
data
.
getShoesId
(),
data
.
getQuantity
()));
}
//HashMapをセッションに追加
session
.
setAttribute
(
"cart"
,
cart
);
int
nowQuantity
=
(
int
)
session
.
getAttribute
(
"cartValue"
);
...
...
@@ -96,7 +107,7 @@ public class EcsiteRestController {
}
@GetMapping
(
"buy"
)
public
String
buy
(
@AuthenticationPrincipal
LoginUser
userDetails
,
LinkedHashMap
<
String
,
Items
>
items
,
ArrayList
<
Items
>
cart
){
public
void
buy
(
@AuthenticationPrincipal
LoginUser
userDetails
,
LinkedHashMap
<
String
,
Items
>
items
,
ArrayList
<
Items
>
cart
){
items
=
(
LinkedHashMap
<
String
,
Items
>)
session
.
getAttribute
(
"cart"
);
items
.
forEach
((
key
,
value
)
->
{
cart
.
add
(
value
);
...
...
@@ -105,6 +116,6 @@ public class EcsiteRestController {
//Integer userId = user.getId();
salesLogService
.
update
(
1
,
cart
);
session
.
removeAttribute
(
"cart"
);
return
"index"
;
session
.
removeAttribute
(
"cartValue"
)
;
}
}
\ No newline at end of file
src/main/resources/static/js/cart.js
View file @
fbfe7bf2
...
...
@@ -16,6 +16,9 @@ $('#ok-btn').on('click',function(){
type
:
'GET'
,
url
:
'/limited/buy'
})
.
done
()
return
false
;
.
done
(
function
(){
$
(
'.js-modal'
).
fadeOut
();
alert
(
"購入が完了しました。"
);
window
.
location
.
href
=
"/limited/top"
;
})
});
\ No newline at end of file
src/main/resources/templates/cart.html
View file @
fbfe7bf2
...
...
@@ -111,7 +111,7 @@
<tr
class=
"row tr"
>
<td
class=
"tdCart"
><img
th:src=
"@{/upload/{photo}(photo=${cart.photo})}"
width=
"300"
height=
"200"
/></td>
<td
class=
"tdCart"
><p
th:text=
"${cart.shoesName}"
class=
"textP"
>
Convers All Star
</p></td>
<td
class=
"tdCart"
><
p
th:text=
"${cart.quantity}"
class=
"textP"
></p
></td>
<td
class=
"tdCart"
><
input
type=
"number"
th:value=
"${cart.quantity}"
class=
"textP"
></input
></td>
<td
class=
"tdCart"
><p
th:text=
"${cart.price}"
class=
"textP"
>
¥
10000
</p></td>
</tr>
</div>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment