Commit a9e42fea authored by keita.onoguchi's avatar keita.onoguchi

Merge branch '購入履歴表示処理' into 'master'

購入履歴処理途中

See merge request !18
parents 62cb19b1 bf991611
package com.example.domain;
public class SalesLog {
import java.sql.Date;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Table;
import lombok.Getter;
import lombok.Setter;
@Entity
@Getter
@Setter
@Table(name="sales_logs")
public class SalesLog {
@Id
@GeneratedValue
private Integer id;
private Integer userId;
private Integer shoesId;
private Integer price;
private Date created;
}
package com.example.domain;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
......@@ -16,7 +17,9 @@ import lombok.Setter;
public class Wallets {
@Id
@GeneratedValue
private Integer Id;
private Integer id;
@Column(nullable=false)
private Integer userId;
@Column(nullable=false)
private Integer amount;
}
package com.example.repository;
import java.util.List;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;
import com.example.domain.SalesLog;
@Repository
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);
}
package com.example.service;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.example.domain.SalesLog;
import com.example.repository.SalesLogRepository;
@Service
public class SalesLogService {
@Autowired
SalesLogRepository salesLogRepository;
public List<SalesLog> findAll(){
return salesLogRepository.findAll();
}
public SalesLog findOne(Integer id){
return salesLogRepository.findOne(id);
}
public SalesLog create(SalesLog salesLog){
return salesLogRepository.save(salesLog);
}
public SalesLog update(SalesLog salesLog){
return salesLogRepository.save(salesLog);
}
public List<SalesLog> history(Integer id) {
return salesLogRepository.history(id);
}
}
......@@ -10,11 +10,14 @@ import org.springframework.security.core.annotation.AuthenticationPrincipal;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import com.example.domain.SalesLog;
import com.example.domain.Shoes;
import com.example.domain.User;
import com.example.service.LoginUser;
import com.example.service.SalesLogService;
import com.example.service.ShoesService;
@Controller
......@@ -23,6 +26,9 @@ public class EcsiteController {
@Autowired
ShoesService shoesService;
@Autowired
SalesLogService salesLogService;
//写真の表示用メソッド
public String photoView(String Photo) {
// 画像を検索してbyteとしてViewへ受け渡す
......@@ -83,4 +89,15 @@ public class EcsiteController {
//遷移先 未設定
return "Hello world";
}
//購入履歴画面
@GetMapping("log/{id}")
public String History (@PathVariable Integer id, Model model, SalesLog salesLog) {
List<SalesLog> list = salesLogService.history(id);
for(SalesLog value : list) {
System.out.println(value);
}
model.addAttribute("log", list);
return "fistory";
}
}
spring.datasource.url=jdbc:mysql://localhost:3306/limited
spring.datasource.username=root
spring.datasource.password=kanikani7
security.basic.enabled=false
spring.datasource.driverClassName=com.mysql.jdbc.Driver
......@@ -1770,4 +1770,65 @@ label {
#history-table {
color: #000;
width: 100%;
}
/* 管理画面(宮嶋) */
#management_wrapper {
height: 100%;
width: 100%;
display: flex;
}
#sidebar {
height: 100%;
width: 20%;
border-right: 1px gray solid;
}
.sidebar_title {
margin:10px;
}
.sidebar_title_name {
display: block;
margin: 0 auto;
}
#mainbody {
height: 100%;
width: 80%;
}
.ma_header {
border-bottom: 1px gray solid;
height: 10%;
padding: 5px;
font-size: large;
font-weight: bold;
}
#user_list {
padding: 20px;
}
th, td {
padding: 10px;
}
#roleBtn {
margin: 10px;
}
#newShoesForm {
border-bottom: 1px gray solid;
height: 15%;
padding: 10px;
}
#newShoesFormTitle, #shoesListTitle {
padding: 5px;
font-size: large;
font-weight: bold;
}
#newShoesFormBtn, #ShoesEditBtn {
display: block;
margin: 0 0 0 auto;
padding: 5px;
margin-bottom: 5px;
margin-right: 5px;
}
#ShoesEditForm {
border-bottom: 1px gray dashed;
height: 15%;
padding: 10px;
}
\ No newline at end of file
$('#shoe_management').hide();
//ユーザー管理
$('#user_button').on('click', function(){
$('#user_management').show();
$('#shoe_management').hide();
})
//権限変更の確認アラート
$('#roleBtn').on('click', function(){
if(!confirm('本当に権限を変更しますか?')) {
return false;
}else{
//権限書き換え機能
}
})
//商品管理
$('#shoe_button').on('click', function(){
$('#user_management').hide();
$('#shoe_management').show();
})
\ No newline at end of file
......@@ -78,8 +78,8 @@
</div>
<div id="submit-form">
<input type="submit" class="login" id="btn" value="Login"/>
<!-- 会員登録ボタン -->
<!--<button class="js-modal-open" id="sign-up">Sign Up</button>
会員登録ボタン
<button class="js-modal-open" id="sign-up">Sign Up</button>
</div>
</form>-->
......
<!DOCTYPE html>
<html class="no-js" lang="ja" xmlns:th="http://www.thymeleaf.org">
<html class="no-js" lang="ja" xmlns:th="http://www.thymeleaf.org"
xmlns:sec="http://www.thymeleaf.org/extras/spring-security">
<head>
<meta charset="utf-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"/>
......@@ -33,7 +34,7 @@
<div class="header-top-menu">
<ul class="nav nav-pills navbar-right">
<!-- 履歴ページへ遷移 -->
<li><a th:href="@{/log/{id}(id=${user.id})}">My Purchase Log</a></li>
<li><a th:href="@{/limited/log/{id}(id=${user.id})}">My Purchase Log</a></li>
<!-- カートページへ遷移 -->
<li><a th:href="@{/cart/{id}(id=${user.id})}">Cart</a></li>
<!-- ログアウト -->
......
<!doctype html>
<html class="no-js" lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<title>Limited</title>
<meta name="description" content="">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="icon" href="images/favicon.png">
<link rel="stylesheet" href="css/style.css">
<!--[if lt IE 9]>
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<script>window.html5 || document.write('<script src="js/vendor/html5shiv.js"><\/script>')</script>
<![endif]-->
</head>
<body>
<div id="management_wrapper">
<div id="sidebar">
<div class="sidebar_title"><button th:href="http://localhost:8080/limited">TOPへ戻る</button></div>
<div class="sidebar_title"><button id="user_button" type="button">ユーザー管理</button></div>
<div class="sidebar_title"><button id="shoe_button" type="button">商品管理</button></div>
</div>
<div id="mainbody">
<!-- ユーザー管理 -->
<div id="user_management">
<!-- ヘッダー -->
<div class="ma_header">
<p>ユーザー管理</p>
</div>
<div id="user_list">
<table id="user_list_table" border="1">
<tr>
<th>ID</th>
<th>名前</th>
<th>権限</th>
</tr>
<tr>
<td>1</td>
<td>demo</td>
<td><input name="roles" th:text="admin"/><button id="roleBtn">権限変更</button></td>
</tr>
</table>
</div>
</div>
<!-- 商品管理 -->
<div id="shoe_management">
<!-- ヘッダー -->
<div class="ma_header">
<p>商品管理</p>
</div>
<!-- 新規登録フォーム -->
<div id="newShoesFormTitle">商品新規登録</div>
<form id="newShoesForm">
<span>商品名:<input type="text" name="name" placeholder="name"/></span>
<span>価格:<input type="text" name="price" placeholder="price"/></span>
<!-- <span>在庫数:<select name="stock">
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
<option value="6">6</option>
<option value="7">7</option>
<option value="8">8</option>
<option value="9">9</option>
<option value="10">10</option>
</select></span> -->
<span>在庫数:<input type="number" name="stock"/></span>
<span>サイズ:<select name="size_id">
<option value="1">24</option>
<option value="2">24.5</option>
<option value="3">25</option>
<option value="4">25.5</option>
<option value="5">26</option>
<option value="6">26.5</option>
<option value="7">27</option>
<option value="8">27.5</option>
<option value="9">28</option>
<option value="10">28.5</option>
</select></span>
<div>商品画像<input type="file" name="photo"></div>
<button type="button" id="newShoesFormBtn">登録確定</button>
</form>
<!-- 在庫一覧 eachで繰り返し -->
<div id="shoesListTitle">在庫一覧</div>
<form id="ShoesEditForm">
<span>ID:<div name="id" th:text=""></div></span>
<span>商品名:<input type="text" name="name" placeholder="name"/></span>
<span>価格:<input type="text" name="price" placeholder="price"/></span>
<!-- <span>在庫数:<select name="stock">
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
<option value="6">6</option>
<option value="7">7</option>
<option value="8">8</option>
<option value="9">9</option>
<option value="10">10</option>
</select></span> -->
<span>在庫数:<input type="number" name="stock"/></span>
<span>サイズ:<select name="size_id">
<option value="1">24</option>
<option value="2">24.5</option>
<option value="3">25</option>
<option value="4">25.5</option>
<option value="5">26</option>
<option value="6">26.5</option>
<option value="7">27</option>
<option value="8">27.5</option>
<option value="9">28</option>
<option value="10">28.5</option>
</select></span>
<div>商品画像<input type="file" name="photo"></div>
<button type="button" id="ShoesEditBtn">変更確定</button>
</form>
</div>
</div>
</div>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<!-- <script src="js/vendor/bootstrap.min.js"></script>
<script src="js/isotope.pkgd.min.js"></script>
<script src="js/owl.carousel.min.js"></script>
<script src="js/wow.min.js"></script>
<script src="js/custom.js"></script> -->
<script type="text/javascript" src="js/management.js"></script>
</body>
</html>
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