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

@Transactional
@Component(value="guestInfoRecordService")
public class GuestInfoRecordServiceImpl implements GuestInfoRecordService {
	@Resource(name="guestInfoRecordDAO")
	private GuestInfoRecordDAO guestInfoRecordDAO;

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

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

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

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

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

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

	@Override
	public Map getScanNum(Map<String, Object> searchParams) {
		return         guestInfoRecordDAO.getScanNum(searchParams);

	}

	@Override
	public GuestInfoRecord findByOpenId(String openId) {
		return guestInfoRecordDAO.findByOpenId(openId);
	}
}