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

@Transactional
@Component(value="parkingCouponService")
public class ParkingCouponServiceImpl implements ParkingCouponService {
	@Resource(name="parkingCouponDAO")
	private ParkingCouponDAO parkingCouponDAO;

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

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

		return parkingCouponDAO.insert(model);
	}

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

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

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

		return count > 0 ? true : false;
	}

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

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

        return page;
	}

	@Override
	public ParkingCoupon findByParkingRecordIdAndStatus(String id,Boolean status) {
		return parkingCouponDAO.findByParkingRecordIdAndStatus(id,status);
	}
}