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
584701b2
Commit
584701b2
authored
Oct 18, 2020
by
shoei.kanno
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
購入履歴機能途中(日付、合計金額、詳細ボタンは表示できる)
parent
a9e42fea
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
72 additions
and
37 deletions
+72
-37
SalesLog.java
src/main/java/com/example/domain/SalesLog.java
+7
-0
SalesLogRepository.java
src/main/java/com/example/repository/SalesLogRepository.java
+4
-0
LoginUser.java
src/main/java/com/example/service/LoginUser.java
+5
-0
SalesLogService.java
src/main/java/com/example/service/SalesLogService.java
+5
-0
EcsiteController.java
src/main/java/com/example/web/EcsiteController.java
+5
-5
application.properties
src/main/resources/application.properties
+1
-1
style.css
src/main/resources/static/css/style.css
+32
-3
log.html
src/main/resources/templates/log.html
+13
-28
No files found.
src/main/java/com/example/domain/SalesLog.java
View file @
584701b2
...
...
@@ -5,6 +5,8 @@ import java.sql.Date;
import
javax.persistence.Entity
;
import
javax.persistence.GeneratedValue
;
import
javax.persistence.Id
;
import
javax.persistence.JoinColumn
;
import
javax.persistence.ManyToOne
;
import
javax.persistence.Table
;
import
lombok.Getter
;
...
...
@@ -22,4 +24,9 @@ public class SalesLog {
private
Integer
shoesId
;
private
Integer
price
;
private
Date
created
;
@ManyToOne
@JoinColumn
(
name
=
"shoesId"
,
insertable
=
false
,
updatable
=
false
)
Shoes
shoes
;
}
src/main/java/com/example/repository/SalesLogRepository.java
View file @
584701b2
package
com
.
example
.
repository
;
import
java.sql.Date
;
import
java.util.List
;
import
org.springframework.data.jpa.repository.JpaRepository
;
...
...
@@ -13,4 +14,7 @@ public interface SalesLogRepository extends JpaRepository<SalesLog, Integer>{
@Query
(
value
=
"SELECT id,user_id, shoes_id, SUM(price) AS price, created FROM sales_logs AS sl WHERE sl.user_id = ?1 GROUP BY sl.created"
,
nativeQuery
=
true
)
public
List
<
SalesLog
>
history
(
Integer
id
);
@Query
(
value
=
"SELECT id, user_id, shoes_id, price, created FROM sales_logs AS sl WHERE sl.created = ?1"
,
nativeQuery
=
true
)
public
List
<
SalesLog
>
historyShoes
(
Date
created
);
}
src/main/java/com/example/service/LoginUser.java
View file @
584701b2
...
...
@@ -23,6 +23,11 @@ public class LoginUser extends org.springframework.security.core.userdetails.Use
return
user
;
}
//idのgetter
public
Integer
getId
(){
return
user
.
getId
();
}
//ログイン権限、文字列変更
private
Collection
<
GrantedAuthority
>
getAuthorities
(
String
role
)
{
if
(
role
.
equals
(
"ADMIN"
))
{
...
...
src/main/java/com/example/service/SalesLogService.java
View file @
584701b2
package
com
.
example
.
service
;
import
java.sql.Date
;
import
java.util.List
;
import
org.springframework.beans.factory.annotation.Autowired
;
...
...
@@ -32,4 +33,8 @@ public class SalesLogService {
public
List
<
SalesLog
>
history
(
Integer
id
)
{
return
salesLogRepository
.
history
(
id
);
}
public
List
<
SalesLog
>
historyShoes
(
Date
created
)
{
return
salesLogRepository
.
historyShoes
(
created
);
}
}
src/main/java/com/example/web/EcsiteController.java
View file @
584701b2
...
...
@@ -2,6 +2,7 @@ package com.example.web;
import
java.io.ByteArrayOutputStream
;
import
java.io.FileInputStream
;
import
java.sql.Date
;
import
java.util.ArrayList
;
import
java.util.List
;
...
...
@@ -92,12 +93,11 @@ public class EcsiteController {
//購入履歴画面
@GetMapping
(
"log/{id}"
)
public
String
History
(
@PathVariable
Integer
id
,
Model
model
,
SalesLog
salesLog
)
{
public
String
History
(
@PathVariable
Integer
id
,
Model
model
,
SalesLog
salesLog
,
@AuthenticationPrincipal
LoginUser
userDetails
)
{
User
user
=
userDetails
.
getUser
();
model
.
addAttribute
(
"user"
,
user
);
List
<
SalesLog
>
list
=
salesLogService
.
history
(
id
);
for
(
SalesLog
value
:
list
)
{
System
.
out
.
println
(
value
);
}
model
.
addAttribute
(
"log"
,
list
);
return
"
fistory
"
;
return
"
log
"
;
}
}
src/main/resources/application.properties
View file @
584701b2
spring.datasource.url
=
jdbc:mysql://localhost:3306/limited
spring.datasource.username
=
root
spring.datasource.password
=
kanikani7
spring.datasource.password
=
security.basic.enabled
=
false
spring.datasource.driverClassName
=
com.mysql.jdbc.Driver
src/main/resources/static/css/style.css
View file @
584701b2
...
...
@@ -1756,22 +1756,51 @@ label {
}
/* 購入履歴画面 */
#
history
-p-text
{
#
log
-p-text
{
font-size
:
40px
;
text-align
:
center
;
margin
:
100px
0
;
}
#
history
-text
{
#
log
-text
{
border-bottom
:
2px
solid
#1abc9c
;
color
:
#555252
;
}
#
history
-table
{
#
log
-table
{
color
:
#000
;
width
:
100%
;
}
.th
,
.td
{
width
:
33%
;
text-align
:
center
;
}
.th
{
padding
:
20px
0
;
}
.textP
{
margin
:
50px
0
;
}
#log-footer
{
margin-top
:
100px
;
}
.details-btn
{
width
:
150px
;
height
:
50px
;
margin
:
50px
0
;
font-weight
:
bold
;
font-size
:
small
;
background-color
:
#1abc9c
;
border-radius
:
3px
;
border
:
none
;
color
:
#000
;
}
/* 管理画面(宮嶋) */
#management_wrapper
{
height
:
100%
;
...
...
src/main/resources/templates/
fistory
.html
→
src/main/resources/templates/
log
.html
View file @
584701b2
...
...
@@ -8,8 +8,8 @@
<link
rel=
"icon"
href=
"images/favicon.png"
th:href=
"@{/images/favicon.png}"
/>
<link
rel=
"stylesheet"
href=
"css/style.css"
th:href=
"@{/css/style.css}"
/>
<
link
rel=
"stylesheet"
href=
"https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta/css/bootstrap.min.css"
integrity=
"sha384-/Y6pD6FV/Vv2HJnA6t+vslU6fwYXjCFtcEpHbNJ0lyAFsXTsjBbfaDjzALeQsN6M"
crossorigin=
"anonymous"
/
>
<
!-- <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta/css/bootstrap.min.css" integrity="sha384-/Y6pD6FV/Vv2HJnA6t+vslU6fwYXjCFtcEpHbNJ0lyAFsXTsjBbfaDjzALeQsN6M" crossorigin="anonymous"/>
<link href="http://maxcdn.bootstrapcdn.com/font-awesome/latest/css/font-awesome.min.css" rel="stylesheet"/>--
>
<title>
Limited History
</title>
<!--[if lt IE 9]>
...
...
@@ -66,7 +66,7 @@
<!-- ログインフォーム -->
<div
class=
"container"
>
<p
id=
"
history-p-text"
><span
id=
"history
-text"
>
Purchase History
</span></p>
<p
id=
"
log-p-text"
><span
id=
"log
-text"
>
Purchase History
</span></p>
<!--<form id="login-form" method="post" th:action="@{/login}">
<div id="email-form">
<label for="login-email">Email</label>
...
...
@@ -84,35 +84,20 @@
</form>-->
<!-- 購入履歴一覧 -->
<div
id=
"
history
"
>
<table
id=
"
history
-table"
>
<div
id=
"
log
"
>
<table
id=
"
log
-table"
>
<thead
class=
"thead"
>
<tr
class=
"row"
id=
"theadTr"
>
<th
class=
"th
col-xl-4"
id=
"imageTh"
>
Imag
e
</th>
<th
class=
"th
col-xl-4"
id=
"productNameTh"
>
Product Nam
e
</th>
<th
class=
"th
col-xl-4"
id=
"priceTh"
>
Price
</th>
<th
class=
"th
"
id=
"imageTh"
>
Dat
e
</th>
<th
class=
"th
"
id=
"productNameTh"
>
Total Pric
e
</th>
<th
class=
"th
"
id=
"priceTh"
>
</th>
</tr>
</thead>
<tbody>
<tr
class=
"row tr"
>
<td
class=
"td col-xl-4"
><img
src=
"images/スニーカー2.jpg"
/></td>
<td
class=
"td col-xl-4"
><p
class=
"textP"
>
Convers All Star
</p></td>
<td
class=
"td col-xl-4"
><p
class=
"textP"
>
¥
10000
</p></td>
</tr>
<tr
class=
"row tr"
>
<td
class=
"td col-xl-4"
><img
src=
"images/スニーカー2.jpg"
/></td>
<td
class=
"td col-xl-4"
><p
class=
"textP"
>
Convers All Star
</p></td>
<td
class=
"td col-xl-4"
><p
class=
"textP"
>
¥
10000
</p></td>
</tr>
<tr
class=
"row tr"
>
<td
class=
"td col-xl-4"
><img
src=
"images/スニーカー2.jpg"
/></td>
<td
class=
"td col-xl-4"
><p
class=
"textP"
>
Convers All Star
</p></td>
<td
class=
"td col-xl-4"
><p
class=
"textP"
>
¥
10000
</p></td>
</tr>
<tr
class=
"row tr"
>
<td
class=
"td col-xl-4"
><img
src=
"images/スニーカー2.jpg"
/></td>
<td
class=
"td col-xl-4"
><p
class=
"textP"
>
Convers All Star
</p></td>
<td
class=
"td col-xl-4"
><p
class=
"textP"
>
¥
10000
</p></td>
<tr
class=
"row tr"
th:each=
"log : ${log}"
>
<td
class=
"td"
><p
class=
"textP"
th:text=
"${log.created}"
>
Convers All Star
</p></td>
<td
class=
"td"
><p
class=
"textP"
th:text=
"'¥' + ${log.price}"
>
10000
</p></td>
<td
class=
"td"
><button
class=
"details-btn"
>
Details
</button></td>
</tr>
</tbody>
</table>
...
...
@@ -121,7 +106,7 @@
</div>
<!-- footer -->
<footer
class=
"footer"
id=
"log
in
-footer"
>
<footer
class=
"footer"
id=
"log-footer"
>
<div
class=
"container"
>
<div
class=
"row"
>
<div
class=
"col-md-12"
>
...
...
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