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;

import com.example.service.ShoesService;

import lombok.Getter;
import lombok.Setter;

@Component
@Scope(value= "session", proxyMode = ScopedProxyMode.TARGET_CLASS)
@Setter
@Getter
public class SessionData implements Serializable{
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	@Autowired
	ShoesService shoesService;
	private Integer shoesId;
	private String photo;
	private String shoesName;
	private Integer shoesSize;
	private Integer quantity;
	private Integer price;
	
	
	public void setSesionData(Integer shoesId, Integer quantity) {
		Shoes shoes = new Shoes();
		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;
	}
	
	public ArrayList<SessionData> getCart(){
		ArrayList<SessionData> cartList = new ArrayList<SessionData>();
		SessionData data = new SessionData();
		data.getShoesId();
		data.getPhoto();
		data.getShoesName();
		data.getShoesSize();
		data.getQuantity();
		data.getPrice();
		cartList.add(data);
		return cartList;
		
	}
}