package kr.co.jinwoosi.clfd.conts.cont.service.impl;

import java.util.ArrayList;
import java.util.List;

import javax.annotation.Resource;

import kr.co.jinwoosi.clfd.conts.cont.mapper.ContItemHistMapper;
import kr.co.jinwoosi.clfd.conts.cont.model.ContItemHist;
import kr.co.jinwoosi.clfd.conts.cont.model.ContItemHistSearch;
import kr.co.jinwoosi.clfd.conts.cont.service.ContItemHistService;
import kr.co.jinwoosi.clfd.framework.base.service.impl.BaseServiceImpl;
import org.springframework.stereotype.Service;

import kr.co.jinwoosi.clfd.framework.security.model.UserSearch;
import kr.co.jinwoosi.clfd.framework.security.service.UserService;

@Service(value="contItemHistService")
public class ContItemHistServiceImpl extends BaseServiceImpl<ContItemHist, ContItemHistSearch, ContItemHistMapper> implements ContItemHistService {

	@Resource (name="userService")
	private UserService userService;
	
	@Override
	@Resource (name="contItemHistMapper")
	protected void setMapper (ContItemHistMapper mapper) {
		super.setMapper (mapper);
	}

	@Override
	public List<ContItemHist> selectList(ContItemHistSearch contItemHistSearch) {
		List<ContItemHist> result = new ArrayList<ContItemHist>();
		List<ContItemHist> contItemHistList = super.selectList(contItemHistSearch);
		UserSearch userSearch;
		for(ContItemHist contItemHist : contItemHistList) {
			userSearch = new UserSearch();
			userSearch.setUserId(contItemHist.getRegId());
			contItemHist.setUser(userService.select(userSearch));
			result.add(contItemHist);
		}
		return result;
	}
}
