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

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

@Transactional
@Component(value="epidemicReportService")
public class EpidemicReportServiceImpl implements EpidemicReportService {
	@Resource(name="epidemicReportDAO")
	private EpidemicReportDAO epidemicReportDAO;

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

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

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

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

	@Override
	public boolean exist(String id) {
		// TODO Auto-generated method stub
		int count = epidemicReportDAO.exist(id);
		
		return count > 0 ? true : false;
	}
	
	@Override
	public List<EpidemicReport> list() {
		// TODO Auto-generated method stub
		return epidemicReportDAO.list();
	}
		
	@Override
	public Page<EpidemicReport> pageSearch(Map<String, Object> searchParams, int pageNumber, int pageSize,List<Sort> sortList) {
        Page<EpidemicReport> page = PageHelper.startPage(pageNumber,pageNumber).doSelectPage(()->{
            epidemicReportDAO.search(searchParams,sortList);
        });
        
        return page;
	}
}