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

@Transactional
@Component(value="parkingMerchantBinderService")
public class ParkingMerchantBinderServiceImpl implements ParkingMerchantBinderService {
	@Resource(name="parkingMerchantBinderDAO")
	private ParkingMerchantBinderDAO parkingMerchantBinderDAO;

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

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

		return parkingMerchantBinderDAO.insert(model);
	}

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

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

	@Override
	public boolean exist(String id) {
		// TODO Auto-generated method stub
		int count = parkingMerchantBinderDAO.exist(id);

		return count > 0 ? true : false;
	}

	@Override
	public List<ParkingMerchantBinder> list() {
		// TODO Auto-generated method stub
		return parkingMerchantBinderDAO.list();
	}

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

        return page;
	}

	@Override
	public ParkingMerchantBinder findByOpenIdAndMerchantId(String openid,String merchantId) {
		return parkingMerchantBinderDAO.findByOpenIdAndMerchantId(openid,merchantId);
	}
}