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
190f9c8d
Commit
190f9c8d
authored
Oct 20, 2020
by
shoei.kanno
Browse files
Options
Browse Files
Download
Plain Diff
コンフリクト解消
parents
add7aed4
a5fd00e8
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
23 additions
and
3 deletions
+23
-3
EcsiteRestController.java
src/main/java/com/example/api/EcsiteRestController.java
+7
-1
EcsiteController.java
src/main/java/com/example/web/EcsiteController.java
+14
-0
index.html
src/main/resources/templates/index.html
+1
-1
list.html
src/main/resources/templates/list.html
+1
-1
No files found.
src/main/java/com/example/api/EcsiteRestController.java
View file @
190f9c8d
...
@@ -10,6 +10,7 @@ import javax.servlet.http.HttpSession;
...
@@ -10,6 +10,7 @@ import javax.servlet.http.HttpSession;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.security.core.annotation.AuthenticationPrincipal
;
import
org.springframework.security.core.annotation.AuthenticationPrincipal
;
import
org.springframework.security.crypto.password.Pbkdf2PasswordEncoder
;
import
org.springframework.security.crypto.password.Pbkdf2PasswordEncoder
;
import
org.springframework.ui.Model
;
import
org.springframework.web.bind.annotation.GetMapping
;
import
org.springframework.web.bind.annotation.GetMapping
;
import
org.springframework.web.bind.annotation.PostMapping
;
import
org.springframework.web.bind.annotation.PostMapping
;
import
org.springframework.web.bind.annotation.RequestBody
;
import
org.springframework.web.bind.annotation.RequestBody
;
...
@@ -52,19 +53,22 @@ public class EcsiteRestController {
...
@@ -52,19 +53,22 @@ public class EcsiteRestController {
}
}
@PostMapping
(
"inputCart"
)
@PostMapping
(
"inputCart"
)
public
void
inputCart
(
@RequestBody
ItemData
data
)
{
public
void
inputCart
(
@RequestBody
ItemData
data
,
Model
model
)
{
if
(
session
.
getAttribute
(
"cart"
)
==
null
){
if
(
session
.
getAttribute
(
"cart"
)
==
null
){
LinkedHashMap
<
String
,
Items
>
cart
=
new
LinkedHashMap
<
String
,
Items
>();
LinkedHashMap
<
String
,
Items
>
cart
=
new
LinkedHashMap
<
String
,
Items
>();
String
id
=
data
.
getShoesId
().
toString
();
String
id
=
data
.
getShoesId
().
toString
();
cart
.
put
(
id
,
itemsService
.
findOne
(
data
.
getShoesId
(),
data
.
getQuantity
()));
cart
.
put
(
id
,
itemsService
.
findOne
(
data
.
getShoesId
(),
data
.
getQuantity
()));
System
.
out
.
println
(
cart
);
System
.
out
.
println
(
cart
);
session
.
setAttribute
(
"cart"
,
cart
);
session
.
setAttribute
(
"cart"
,
cart
);
session
.
setAttribute
(
"cartValue"
,
data
.
getQuantity
());
}
else
{
}
else
{
LinkedHashMap
<
String
,
Items
>
cart
=
new
LinkedHashMap
<
String
,
Items
>();
LinkedHashMap
<
String
,
Items
>
cart
=
new
LinkedHashMap
<
String
,
Items
>();
String
id
=
data
.
getShoesId
().
toString
();
String
id
=
data
.
getShoesId
().
toString
();
cart
=
(
LinkedHashMap
<
String
,
Items
>)
session
.
getAttribute
(
"cart"
);
cart
=
(
LinkedHashMap
<
String
,
Items
>)
session
.
getAttribute
(
"cart"
);
cart
.
put
(
id
,
itemsService
.
findOne
(
data
.
getShoesId
(),
data
.
getQuantity
()));
cart
.
put
(
id
,
itemsService
.
findOne
(
data
.
getShoesId
(),
data
.
getQuantity
()));
session
.
setAttribute
(
"cart"
,
cart
);
session
.
setAttribute
(
"cart"
,
cart
);
int
nowQuantity
=
(
int
)
session
.
getAttribute
(
"cartValue"
);
session
.
setAttribute
(
"cartValue"
,
nowQuantity
+
data
.
getQuantity
());
}
}
}
}
...
@@ -77,5 +81,6 @@ public class EcsiteRestController {
...
@@ -77,5 +81,6 @@ public class EcsiteRestController {
//User user = userDetails.getUser();
//User user = userDetails.getUser();
//Integer userId = user.getId();
//Integer userId = user.getId();
salesLogService
.
update
(
1
,
cart
);
salesLogService
.
update
(
1
,
cart
);
session
.
removeAttribute
(
"cart"
);
}
}
}
}
\ No newline at end of file
src/main/java/com/example/web/EcsiteController.java
View file @
190f9c8d
...
@@ -75,6 +75,11 @@ HttpSession session;
...
@@ -75,6 +75,11 @@ HttpSession session;
public
String
top
(
Model
model
,
@AuthenticationPrincipal
LoginUser
userDetails
)
{
public
String
top
(
Model
model
,
@AuthenticationPrincipal
LoginUser
userDetails
)
{
User
user
=
userDetails
.
getUser
();
User
user
=
userDetails
.
getUser
();
model
.
addAttribute
(
"user"
,
user
);
model
.
addAttribute
(
"user"
,
user
);
if
(
session
.
getAttribute
(
"cartValue"
)
==
null
)
{
model
.
addAttribute
(
"cartValue"
,
0
);
}
else
{
model
.
addAttribute
(
"cartValue"
,
session
.
getAttribute
(
"cartValue"
));
}
//遷移先 設定済み
//遷移先 設定済み
return
"index"
;
return
"index"
;
}
}
...
@@ -99,6 +104,12 @@ HttpSession session;
...
@@ -99,6 +104,12 @@ HttpSession session;
//user情報取得、格納
//user情報取得、格納
User
user
=
userDetails
.
getUser
();
User
user
=
userDetails
.
getUser
();
model
.
addAttribute
(
"user"
,
user
);
model
.
addAttribute
(
"user"
,
user
);
//カート個数取得、格納
if
(
session
.
getAttribute
(
"cartValue"
)
==
null
)
{
model
.
addAttribute
(
"cartValue"
,
0
);
}
else
{
model
.
addAttribute
(
"cartValue"
,
session
.
getAttribute
(
"cartValue"
));
}
//遷移先 未設定
//遷移先 未設定
return
"list"
;
return
"list"
;
}
}
...
@@ -128,6 +139,9 @@ HttpSession session;
...
@@ -128,6 +139,9 @@ HttpSession session;
User
user
=
userDetails
.
getUser
();
User
user
=
userDetails
.
getUser
();
model
.
addAttribute
(
"user"
,
user
);
model
.
addAttribute
(
"user"
,
user
);
items
=
(
LinkedHashMap
<
String
,
Items
>)
session
.
getAttribute
(
"cart"
);
items
=
(
LinkedHashMap
<
String
,
Items
>)
session
.
getAttribute
(
"cart"
);
if
(
items
==
null
)
{
return
"Cart"
;
}
items
.
forEach
((
key
,
value
)
->
{
items
.
forEach
((
key
,
value
)
->
{
cart
.
add
(
value
);
cart
.
add
(
value
);
});
});
...
...
src/main/resources/templates/index.html
View file @
190f9c8d
...
@@ -69,7 +69,7 @@
...
@@ -69,7 +69,7 @@
</ul>
</ul>
<ul
class=
"nav navbar-nav navbar-right cart-menu"
>
<ul
class=
"nav navbar-nav navbar-right cart-menu"
>
<li><a
class=
"search-btn"
><i
class=
"fa fa-search"
aria-hidden=
"true"
></i></a></li>
<li><a
class=
"search-btn"
><i
class=
"fa fa-search"
aria-hidden=
"true"
></i></a></li>
<li><a
th:href=
"@{/limited/cart}"
><span>
Cart
</span>
<span
class=
"shoping-cart"
>
0
</span></a></li>
<li><a
th:href=
"@{/limited/cart}"
><span>
Cart
</span>
<span
class=
"shoping-cart"
th:text=
"${cartValue}"
>
0
</span></a></li>
</ul>
</ul>
</div>
<!-- /.navbar-collapse -->
</div>
<!-- /.navbar-collapse -->
...
...
src/main/resources/templates/list.html
View file @
190f9c8d
...
@@ -95,7 +95,7 @@
...
@@ -95,7 +95,7 @@
</ul>
</ul>
<ul
class=
"nav navbar-nav navbar-right cart-menu"
>
<ul
class=
"nav navbar-nav navbar-right cart-menu"
>
<li><a
class=
"search-btn"
><i
class=
"fa fa-search"
aria-hidden=
"true"
></i></a></li>
<li><a
class=
"search-btn"
><i
class=
"fa fa-search"
aria-hidden=
"true"
></i></a></li>
<li><a
th:href=
"@{/limited/cart}"
><span>
Cart
</span>
<span
class=
"shoping-cart"
>
0
</span></a></li>
<li><a
th:href=
"@{/limited/cart}"
><span>
Cart
</span>
<span
class=
"shoping-cart"
th:text=
"${cartValue}"
>
0
</span></a></li>
</ul>
</ul>
</div>
<!-- /.navbar-collapse -->
</div>
<!-- /.navbar-collapse -->
</div>
</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