package com.jpsoft.shinestar.modules.business.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.business.dao.SupplementWorkPersonDAO;
import com.jpsoft.shinestar.modules.business.entity.SupplementWorkPerson;
import com.jpsoft.shinestar.modules.business.service.SupplementWorkPersonService;
import com.github.pagehelper.Page;
import com.jpsoft.shinestar.modules.common.dto.Sort;
import com.github.pagehelper.PageHelper;

@Transactional
@Component(value="supplementWorkPersonService")
public class SupplementWorkPersonServiceImpl implements SupplementWorkPersonService {
	@Resource(name="supplementWorkPersonDAO")
	private SupplementWorkPersonDAO supplementWorkPersonDAO;

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

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

		return supplementWorkPersonDAO.insert(model);
	}

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

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

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

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

		return count > 0 ? true : false;
	}

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

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

        return page;
	}

	@Override
	public List<SupplementWorkPerson> findByScheduleAttendanceId(String scheduleAttendanceId) {
		return supplementWorkPersonDAO.findByScheduleAttendanceId(scheduleAttendanceId);
	}

	@Override
	public List<SupplementWorkPerson> findBySupplementWorkId(String supplementWorkId) {
		return supplementWorkPersonDAO.findBySupplementWorkId(supplementWorkId);
	}
}