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.WorkShiftCompanyDAO;
import com.jpsoft.shinestar.modules.base.entity.WorkShiftCompany;
import com.jpsoft.shinestar.modules.base.service.WorkShiftCompanyService;
import com.github.pagehelper.Page;
import com.jpsoft.shinestar.modules.common.dto.Sort;
import com.github.pagehelper.PageHelper;

@Transactional
@Component(value="workShiftCompanyService")
public class WorkShiftCompanyServiceImpl implements WorkShiftCompanyService {
	@Resource(name="workShiftCompanyDAO")
	private WorkShiftCompanyDAO workShiftCompanyDAO;

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

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

		return workShiftCompanyDAO.insert(model);
	}

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

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

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

		return count > 0 ? true : false;
	}

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

	@Override
	public List<WorkShiftCompany> findByShiftId(String shiftId){
		return workShiftCompanyDAO.findByShiftId(shiftId);
	}

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

        return page;
	}

	@Override
	public List<String> findDistinctCompanyId() {
		return workShiftCompanyDAO.findDistinctCompanyId();
	}
}