package com.jpsoft.shinestar.modules.workflow.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.workflow.dao.ProcessActUserDAO;
import com.jpsoft.shinestar.modules.workflow.entity.ProcessActUser;
import com.jpsoft.shinestar.modules.workflow.service.ProcessActUserService;
import com.github.pagehelper.Page;
import com.jpsoft.shinestar.modules.common.dto.Sort;
import com.github.pagehelper.PageHelper;

@Transactional
@Component(value="processActUserService")
public class ProcessActUserServiceImpl implements ProcessActUserService {
	@Resource(name="processActUserDAO")
	private ProcessActUserDAO processActUserDAO;

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

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

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

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

	@Override
	public boolean exist(String id) {
		// TODO Auto-generated method stub
		int count = processActUserDAO.exist(id);
		
		return count > 0 ? true : false;
	}
	
	@Override
	public List<ProcessActUser> list() {
		// TODO Auto-generated method stub
		return processActUserDAO.list();
	}

	@Override
	public List<ProcessActUser> findByActivityId(String activityId) {
		// TODO Auto-generated method stub
		return processActUserDAO.findByActivityId(activityId);
	}
	@Override
	public List<String> findByActIdAndUserType(String actId,String userType){
		return processActUserDAO.findByActIdAndUserType(actId,userType);
	}


	@Override
	public List<ProcessActUser> findItemByActIdAndUserType(String actId,String userType){
		return processActUserDAO.findItemByActIdAndUserType(actId,userType);
	}

	@Override
	public List<ProcessActUser> findItemByActIdAndUserTypeAndSource(String actId,String userType,String source){
		return processActUserDAO.findItemByActIdAndUserTypeAndSource(actId,userType,source);
	}

	@Override
	public List<String> findRelativePositionByActIdAndUserType(String actId,String userType){
		return processActUserDAO.findRelativePositionByActIdAndUserType(actId,userType);
	}

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

	@Override
	public List<ProcessActUser> findByActivityIdAndUserType(String activityId, String userType) {
		return processActUserDAO.findByActivityIdAndUserType(activityId,userType);
	}
}