package com.example.service;

import java.util.Collections;
import java.util.List;

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

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

//靴用サービス
@Service
public class ShoesService {
	@Autowired
	ShoesRepository shoesRepository;
	
	public List<Shoes> findAll(){
//		List<Shoes> list = shoesRepository. findAll();
//		//並べ替え処理
//		Collections.sort(list, Collections.reverseOrder());
//		//並べ替えたものを返す。
//		return list;
		return shoesRepository.findAll();
	}
	
	public Shoes findOne(Integer id){
		return shoesRepository.findOne(id);
	}
	
	public Shoes create(Shoes shoes){
		return shoesRepository.save(shoes);
	}
	
	public Shoes update(Shoes shoes){
		return shoesRepository.save(shoes);
	}
}
