Commit 9ffb6cbf authored by shoei.kanno's avatar shoei.kanno

Merge branch '購入履歴画面機能' into 'master'

購入履歴機能途中(日付、合計金額、詳細ボタンは表示できる)

See merge request !20
parents 724a0b36 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;
}
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);
}
......@@ -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 static Collection<GrantedAuthority> getAuthorities(String role) {
if (role.equals("ADMIN")) {
......
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);
}
}
......@@ -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";
}
}
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
......@@ -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%;
......
......@@ -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">Image</th>
<th class="th col-xl-4" id="productNameTh">Product Name</th>
<th class="th col-xl-4"id="priceTh">Price</th>
<th class="th" id="imageTh">Date</th>
<th class="th" id="productNameTh">Total Price</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">&yen;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">&yen;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">&yen;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">&yen;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="'&yen;' + ${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="login-footer">
<footer class="footer" id="log-footer">
<div class="container">
<div class="row">
<div class="col-md-12">
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment