Commit 0aedb57d authored by keita.onoguchi's avatar keita.onoguchi

カート機能途中

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