package com.jpsoft.shinestar.modules.base.service.impl;

import java.util.List;
import java.util.Map;
import javax.annotation.Resource;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
import com.jpsoft.shinestar.modules.base.dao.CompanyGoodInfoDAO;
import com.jpsoft.shinestar.modules.base.entity.CompanyGoodInfo;
import com.jpsoft.shinestar.modules.base.service.CompanyGoodInfoService;
import com.github.pagehelper.Page;
import com.jpsoft.shinestar.modules.common.dto.Sort;
import com.github.pagehelper.PageHelper;

@Transactional
@Component(value="companyGoodTypeService")
public class CompanyGoodInfoServiceImpl implements CompanyGoodInfoService {
	@Resource(name= "companyGoodInfoDAO")
	private CompanyGoodInfoDAO companyGoodInfoDAO;

	@Override
	public CompanyGoodInfo get(String id) {
		// TODO Auto-generated method stub
		return companyGoodInfoDAO.get(id);
	}

	@Override
	public int insert(CompanyGoodInfo model) {
		// TODO Auto-generated method stub
		//model.setId(UUID.randomUUID().toString());
		
		return companyGoodInfoDAO.insert(model);
	}

	@Override
	public int update(CompanyGoodInfo model) {
		// TODO Auto-generated method stub
		return companyGoodInfoDAO.update(model);
	}

	@Override
	public int delete(String id) {
		// TODO Auto-generated method stub
		return companyGoodInfoDAO.delete(id);
	}

	@Override
	public boolean exist(String id) {
		// TODO Auto-generated method stub
		int count = companyGoodInfoDAO.exist(id);
		
		return count > 0 ? true : false;
	}
	
	@Override
	public List<CompanyGoodInfo> list() {
		// TODO Auto-generated method stub
		return companyGoodInfoDAO.list();
	}

	@Override
	public List<CompanyGoodInfo> findByCompanyId(String companyId){
		return companyGoodInfoDAO.findByCompanyId(companyId);
	}

	@Override
	public CompanyGoodInfo findByCompanyIdAndGoodsId(String companyId,String GoodsId){
		return companyGoodInfoDAO.findByCompanyIdAndGoodsId(companyId,GoodsId);
	}
		
	@Override
	public Page<CompanyGoodInfo> pageSearch(Map<String, Object> searchParams, int pageNumber, int pageSize, List<Sort> sortList) {
        Page<CompanyGoodInfo> page = PageHelper.startPage(1,10).doSelectPage(()->{
            companyGoodInfoDAO.search(searchParams,sortList);
        });
        
        return page;
	}
}