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

@Transactional
@Component(value="checkinInfoService")
public class CheckinInfoServiceImpl implements CheckinInfoService {
	@Resource(name="checkinInfoDAO")
	private CheckinInfoDAO checkinInfoDAO;

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

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

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

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

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

	@Override
	public List<CheckinInfo> findBypropertyId(String propertyId) {
		// TODO Auto-generated method stub
		return checkinInfoDAO.findBypropertyId(propertyId);
	}

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