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

import java.math.BigDecimal;
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.ApplicationExamineDAO;
import com.jpsoft.shinestar.modules.base.entity.ApplicationExamine;
import com.jpsoft.shinestar.modules.base.service.ApplicationExamineService;
import com.github.pagehelper.Page;
import com.jpsoft.shinestar.modules.common.dto.Sort;
import com.github.pagehelper.PageHelper;

@Transactional
@Component(value="applicationExamineService")
public class ApplicationExamineServiceImpl implements ApplicationExamineService {
	@Resource(name="applicationExamineDAO")
	private ApplicationExamineDAO applicationExamineDAO;

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

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

		return applicationExamineDAO.insert(model);
	}

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

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

	@Override
	public boolean exist(String id) {
		// TODO Auto-generated method stub
		int count = applicationExamineDAO.exist(id);

		return count > 0 ? true : false;
	}

	@Override
	public List<ApplicationExamine> list() {
		// TODO Auto-generated method stub
		return applicationExamineDAO.list();
	}

	@Override
	public Page<ApplicationExamine> pageSearch(Map<String, Object> searchParams, int pageNumber, int pageSize,boolean count,List<Sort> sortList) {
        Page<ApplicationExamine> page = PageHelper.startPage(pageNumber,pageSize,count).doSelectPage(()->{
            applicationExamineDAO.search(searchParams,sortList);
        });

        return page;
	}

	@Override
	public List<ApplicationExamine> findByApplicationCompanyAndRole(String applicationCompanyId, String applicationRoleId) {
		return applicationExamineDAO.findByApplicationCompanyAndRole(applicationCompanyId,applicationRoleId);
	}

	@Override
	public List<ApplicationExamine> findByApplicationCompanyAndRoleAndType(String companyId, String personRoleId, String type) {
		return applicationExamineDAO.findByApplicationCompanyAndRoleAndType(companyId,personRoleId,type);
	}

	@Override
	public List<ApplicationExamine> findByApplicationCompanyAndRoleAndTypeAndDays(String companyId, String personRoleId, String type,Integer level, BigDecimal days) {
		return applicationExamineDAO.findByApplicationCompanyAndRoleAndTypeAndDays(companyId,personRoleId,type,level,days);
	}
}