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

@Transactional
@Component(value="medicalRecordsService")
public class MedicalRecordsServiceImpl implements MedicalRecordsService {
	@Resource(name="medicalRecordsDAO")
	private MedicalRecordsDAO medicalRecordsDAO;

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

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

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

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

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