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

@Transactional
@Component(value="meetingAddressService")
public class MeetingAddressServiceImpl implements MeetingAddressService {
	@Resource(name="meetingAddressDAO")
	private MeetingAddressDAO meetingAddressDAO;

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

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

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

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

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