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

@Transactional
@Component(value="personSuperviseRelationService")
public class PersonSuperviseRelationServiceImpl implements PersonSuperviseRelationService {
	@Resource(name="personSuperviseRelationDAO")
	private PersonSuperviseRelationDAO personSuperviseRelationDAO;

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

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

		return personSuperviseRelationDAO.insert(model);
	}

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

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

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

		return count > 0 ? true : false;
	}

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

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

        return page;
	}

	@Override
	public List<PersonSuperviseRelation> findByPersonPopedomId(String popedom) {
		return personSuperviseRelationDAO.findByPersonPopedomId(popedom);
	}
}