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

@Transactional
@Component(value="meetingTimeService")
public class MeetingTimeServiceImpl implements MeetingTimeService {
	@Resource(name="meetingTimeDAO")
	private MeetingTimeDAO meetingTimeDAO;

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

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

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

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

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

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