Commit 08483dad authored by keita.onoguchi's avatar keita.onoguchi

Merge branch 'カート機能' into 'master'

カート機能途中

See merge request !30
parents 28152373 0aedb57d
//package com.example;
//
//import org.springframework.context.annotation.Bean;
//import org.springframework.security.config.annotation.web.builders.HttpSecurity;
//import org.springframework.security.config.annotation.web.builders.WebSecurity;
//import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
//import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
//import org.springframework.security.crypto.password.PasswordEncoder;
//import org.springframework.security.crypto.password.Pbkdf2PasswordEncoder;
//
//
//@EnableWebSecurity
//public class SecurityConfig extends WebSecurityConfigurerAdapter{
//
// @Override
// public void configure(WebSecurity web) throws Exception{
// web.debug(false).ignoring().antMatchers("/images/**", "/js/**", "/css/**", "/fonts/**");
// }
//
// @Override
// protected void configure(HttpSecurity http) throws Exception {
// http
// .authorizeRequests()
// .mvcMatchers("/limited/login","/limited/signUp").permitAll() //ログイン前でもアクセス可能なURLの指定
// .mvcMatchers("/limited/admin/**").hasRole("ADMIN")//ADMIN権限のユーザーのみアクセスできるURLの指定
// .anyRequest().authenticated()//ログイン前は他のアドレスにログインできないよう指定s
// .and()
// .formLogin()
// .loginProcessingUrl("/login") //ログイン処理でpostするURL
// .loginPage("/limited/login") //ログインページのURL
// .defaultSuccessUrl("/limited/top", true) //ログイン成功時のURL
// .usernameParameter("email").passwordParameter("password") //ログインのパラメーター指定
// .and()
// .logout()
// .invalidateHttpSession(true)
// .deleteCookies("JSESSIONID") //ログアウト時キャッシュを削除する処理
// .logoutSuccessUrl("/limited/login"); //ログアウト後に表示するURL
// }
//
// @Bean //パスワードのハッシュか
// PasswordEncoder passwordEncoder(){
// return new Pbkdf2PasswordEncoder();
// }
//}
package com.example;
import org.springframework.context.annotation.Bean;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.builders.WebSecurity;
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
import org.springframework.security.crypto.password.PasswordEncoder;
import org.springframework.security.crypto.password.Pbkdf2PasswordEncoder;
@EnableWebSecurity
public class SecurityConfig extends WebSecurityConfigurerAdapter{
@Override
public void configure(WebSecurity web) throws Exception{
web.debug(false).ignoring().antMatchers("/images/**", "/js/**", "/css/**", "/fonts/**");
}
@Override
protected void configure(HttpSecurity http) throws Exception {
http
.authorizeRequests()
.mvcMatchers("/limited/login","/limited/signUp").permitAll() //ログイン前でもアクセス可能なURLの指定
.mvcMatchers("/limited/admin/**").hasRole("ADMIN")//ADMIN権限のユーザーのみアクセスできるURLの指定
.anyRequest().authenticated()//ログイン前は他のアドレスにログインできないよう指定s
.and()
.formLogin()
.loginProcessingUrl("/login") //ログイン処理でpostするURL
.loginPage("/limited/login") //ログインページのURL
.defaultSuccessUrl("/limited/top", true) //ログイン成功時のURL
.usernameParameter("email").passwordParameter("password") //ログインのパラメーター指定
.and()
.logout()
.invalidateHttpSession(true)
.deleteCookies("JSESSIONID") //ログアウト時キャッシュを削除する処理
.logoutSuccessUrl("/limited/login"); //ログアウト後に表示するURL
}
@Bean //パスワードのハッシュか
PasswordEncoder passwordEncoder(){
return new Pbkdf2PasswordEncoder();
}
}
......@@ -21,7 +21,7 @@ import com.example.service.LoginUserDetailsService;
@RestController
@RequestMapping("limited")
@SessionAttributes(names ="cart")
//@SessionAttributes(names ="cart")
public class EcsiteRestController {
@Autowired
LoginUserDetailsService loginUserDetailsService;
......@@ -44,8 +44,8 @@ public class EcsiteRestController {
}
@PostMapping("inputCart")
public void inputCart(@RequestBody CartData data, Model model, Cart cart) {
System.out.print(data.getShoesId());
public void inputCart(@RequestBody CartData data, Model model) {
Cart cart = new Cart();
cart.setCart(data.getShoesId(), data.getQuantity());
//return cart.getCart();
}
......
......@@ -3,7 +3,6 @@ package com.example.domain;
import java.io.Serializable;
import java.util.ArrayList;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.context.annotation.ScopedProxyMode;
import org.springframework.stereotype.Component;
......@@ -13,17 +12,15 @@ import com.example.service.ShoesService;
import lombok.Getter;
import lombok.Setter;
//@Component
//@Scope(value= "session", proxyMode = ScopedProxyMode.TARGET_CLASS)
@Component
@Scope(value= "session", proxyMode = ScopedProxyMode.TARGET_CLASS)
@Getter
@Setter
public class Cart /*implements Serializable*/{
public class Cart implements Serializable{
/**
*
*/
//private static final long serialVersionUID = 1L;
@Autowired
ShoesService shoesService;
private static final long serialVersionUID = 1L;
private Integer shoesId;
private String photo;
......@@ -37,14 +34,16 @@ public class Cart /*implements Serializable*/{
public void setCart(Integer shoesId, Integer quantity) {
System.out.println(shoesId);
Shoes shoes = new Shoes();
ShoesService shoesService = new ShoesService();
shoes = shoesService.findOne(shoesId);
this.shoesId = shoesId;
this.photo = shoes.getPhoto();
this.shoesName = shoes.getName();
this.shoesSize = shoes.getSize();
this.quantity = quantity;
this.price = shoes.getPrice() * quantity;
System.out.print(this.price);
//System.out.println(shoes);
// this.shoesId = shoesId;
// this.photo = shoes.getPhoto();
// this.shoesName = shoes.getName();
// this.shoesSize = shoes.getSize();
// this.quantity = quantity;
// this.price = shoes.getPrice() * quantity;
// System.out.print(this.price);
}
public ArrayList<Cart> getCart(){
......
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