package com.example.service;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.example.domain.Items;
import com.example.domain.Shoes;
import com.example.repository.ShoesRepository;

import lombok.Data;

@Service
@Data
public class ItemsService {
	@Autowired
	ShoesRepository shoesRepository;
	
	public Items findOne(Integer shoesId, Integer quantity){
		Items items = new Items();
		Shoes shoes = new Shoes();
		shoes = shoesRepository.findOne(shoesId);
		items.setShoesId(shoesId);
		items.setPhoto(shoes.getPhoto());
		items.setShoesName(shoes.getName());
		items.setShoesSize(shoes.getSize());
		items.setQuantity(quantity);
		items.setPrice(shoes.getPrice() * quantity);
		items.setProductStatus(shoes.getProductStatus());
		return items;
	}
}
