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

import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.jpsoft.shinestar.modules.business.dao.FillAttendanceFilesDAO;
import com.jpsoft.shinestar.modules.business.entity.FillAttendanceFiles;
import com.jpsoft.shinestar.modules.business.service.FillAttendanceFilesService;
import com.jpsoft.shinestar.modules.common.dto.Sort;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

@Transactional
@Component(value="fillAttendanceFilesService")
public class FillAttendanceFilesServiceImpl implements FillAttendanceFilesService {
	@Resource(name="fillAttendanceFilesDAO")
	private FillAttendanceFilesDAO fillAttendanceFilesDAO;

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

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

		return fillAttendanceFilesDAO.insert(model);
	}

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

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

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

		return count > 0 ? true : false;
	}

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

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

        return page;
	}

	@Override
	public FillAttendanceFiles findByFillAttendanceId(String fillAttendanceId) {
		return fillAttendanceFilesDAO.findByFillAttendanceId(fillAttendanceId);
	}
}