package kcg.faics.equip.service.impl;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile;

import kcg.faics.equip.service.ApproveService;
import kcg.faics.equip.vo.ApproveVO;
import kcg.faics.equip.vo.EquipSearchVO;

/**
 * 장비 사용실적 결재관련 비즈니스 로직.
 * 
 * @author kimnomin
 *
 */
@Service("approveService")
public class ApproveServiceImpl implements ApproveService {

	/**
	 * 장비 사용실적 결재관련 Mapper.
	 */
	@Resource(name = "approveMapper")
	private ApproveMapper approveMapper;
	
	@Override
	public ApproveVO select(final ApproveVO dataVO) throws Exception {
		return approveMapper.select(dataVO);
	}

	@Override
	public List<ApproveVO> selectListAll(final EquipSearchVO searchVO)
			throws Exception {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public List<ApproveVO> selectList(final EquipSearchVO searchVO) throws Exception {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public int selectListCnt(final EquipSearchVO searchVO) throws Exception {
		// TODO Auto-generated method stub
		return 0;
	}

	@Override
	public int selectTotalCnt(final EquipSearchVO searchVO) throws Exception {
		// TODO Auto-generated method stub
		return 0;
	}

	@Override
	public HashMap<String, Object> insert(final ApproveVO dataVO,
			final Map<String, MultipartFile> fileMap) throws Exception {
		HashMap<String, Object> result = new HashMap<String, Object>();
		
		// 이미 결재 내역이 있으면 결재하지 않는다.
		ApproveVO vo = select(dataVO);
		if (vo == null) {
			result.put("result", approveMapper.insert(dataVO));	
		} else {
			result.put("result", 0);
		}
		
		return result;
	}

	@Override
	public HashMap<String, Object> update(final ApproveVO dataVO,
			final Map<String, MultipartFile> fileMap, final String[] deleteFiles)
			throws Exception {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public HashMap<String, Object> delete(final ApproveVO dataVO) throws Exception {
		// TODO Auto-generated method stub
		return null;
	}

}
