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 com.jpsoft.shinestar.modules.business.dao.GuestFellowDAO;
import com.jpsoft.shinestar.modules.business.entity.GuestFellow;
import com.jpsoft.shinestar.modules.business.service.GuestFellowService;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
import com.github.pagehelper.Page;
import com.jpsoft.shinestar.modules.common.dto.Sort;
import com.github.pagehelper.PageHelper;

@Transactional
@Component(value="guestFellowService")
public class GuestFellowServiceImpl implements GuestFellowService {
	@Resource(name="guestFellowDAO")
	private GuestFellowDAO guestFellowDAO;

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

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

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

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

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

	@Override
	public List<GuestFellow> getList(String guestInfoRecordId) {
		// TODO Auto-generated method stub
		return guestFellowDAO.getList( guestInfoRecordId);
	}


	@Override
	public int findByGuestInfoRecordId(String guestInfoRecordId){
		return guestFellowDAO.findByGuestInfoRecordId(guestInfoRecordId);
	}
		
	@Override
	public Page<GuestFellow> pageSearch(Map<String, Object> searchParams, int pageNumber, int pageSize, List<Sort> sortList) {
        Page<GuestFellow> page = PageHelper.startPage(1,10).doSelectPage(()->{
            guestFellowDAO.search(searchParams,sortList);
        });
        
        return page;
	}
}