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.MedicalPersonDAO;
import com.jpsoft.shinestar.modules.business.service.MedicalPersonService;
import com.github.pagehelper.Page;
import com.jpsoft.shinestar.modules.common.dto.Sort;
import com.github.pagehelper.PageHelper;

@Transactional
@Component(value="medicalPersonService")
public class MedicalPersonServiceImpl implements MedicalPersonService {
	@Resource(name="medicalPersonDAO")
	private MedicalPersonDAO medicalPersonDAO;

	@Override
	public com.jpsoft.shinestar.modules.business.entity.MedicalPerson get(String id) {
		// TODO Auto-generated method stub
		return medicalPersonDAO.get(id);
	}

	@Override
	public int insert(com.jpsoft.shinestar.modules.business.entity.MedicalPerson model) {
		// TODO Auto-generated method stub
		//model.setId(UUID.randomUUID().toString());
		
		return medicalPersonDAO.insert(model);
	}

	@Override
	public int update(com.jpsoft.shinestar.modules.business.entity.MedicalPerson model) {
		// TODO Auto-generated method stub
		return medicalPersonDAO.update(model);		
	}

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

	@Override
	public com.jpsoft.shinestar.modules.business.entity.MedicalPerson findByPersonId(Long personId){
		return medicalPersonDAO.findByPersonId(personId);
	}

	@Override
	public boolean exist(String id) {
		// TODO Auto-generated method stub
		int count = medicalPersonDAO.exist(id);
		
		return count > 0 ? true : false;
	}
	
	@Override
	public List<com.jpsoft.shinestar.modules.business.entity.MedicalPerson> list() {
		// TODO Auto-generated method stub
		return medicalPersonDAO.list();
	}
		
	@Override
	public Page<com.jpsoft.shinestar.modules.business.entity.MedicalPerson> pageSearch(Map<String, Object> searchParams, int pageNumber, int pageSize, List<Sort> sortList) {
        Page<com.jpsoft.shinestar.modules.business.entity.MedicalPerson> page = PageHelper.startPage(1,10).doSelectPage(()->{
            medicalPersonDAO.search(searchParams,sortList);
        });
        
        return page;
	}
}