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

@Transactional
@Component(value="addressInfoService")
public class AddressInfoServiceImpl implements AddressInfoService {
	@Resource(name="addressInfoDAO")
	private AddressInfoDAO addressInfoDAO;

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

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

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

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

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

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