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

@Transactional
@Component(value="rolePersonCheckOnService")
public class RolePersonCheckOnServiceImpl implements RolePersonCheckOnService {
	@Resource(name="rolePersonCheckOnDAO")
	private RolePersonCheckOnDAO rolePersonCheckOnDAO;

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

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

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

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

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

	@Override
	public RolePersonCheckOn findByPersonId(String personId){
		return rolePersonCheckOnDAO.findByPersonId(personId);
	}
		
	@Override
	public Page<RolePersonCheckOn> pageSearch(Map<String, Object> searchParams, int pageNumber, int pageSize,List<Sort> sortList) {
        Page<RolePersonCheckOn> page = PageHelper.startPage(1,10).doSelectPage(()->{
            rolePersonCheckOnDAO.search(searchParams,sortList);
        });
        
        return page;
	}

	@Override
	public RolePersonCheckOn findByRoleId(String roleId) {
		return rolePersonCheckOnDAO.findByRoleId(roleId);
	}
}