package com.iamberry.wechat.service.coupon;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.iamberry.wechat.core.entity.coupon.AdminCouponItemDto;
import com.iamberry.wechat.face.coupon.AdminCouponItemService;
import com.iamberry.wechat.service.mapper.AdminCouponItemMapper;

@Service
public class AdminCouponItemServiceImpl implements AdminCouponItemService {

	@Autowired
	private AdminCouponItemMapper adminCouponItemMapper;
	
	@Override
	public List<AdminCouponItemDto> getAllCouponItem(AdminCouponItemDto adminCouponItemDto) {
		// TODO Auto-generated method stub
		return adminCouponItemMapper.getAllCouponItem(adminCouponItemDto);
	}

	@Override
	public Integer getCouponItemCount(AdminCouponItemDto adminCouponItemDto) {
		// TODO Auto-generated method stub
		int count = adminCouponItemMapper.getCouponItemCount(adminCouponItemDto);
		return	count = count % adminCouponItemDto.getPage().getPageSize() == 0? count/adminCouponItemDto.getPage().getPageSize():(count/adminCouponItemDto.getPage().getPageSize())+1;
	}

	@Override
	public AdminCouponItemDto getCouponItemByCouponItemId(String couponItemId) {
		// TODO Auto-generated method stub
		return adminCouponItemMapper.getCouponItemByCouponItemId(couponItemId);
	}

	@Override
	public Integer updateCouponItem(AdminCouponItemDto adminCouponItemDto) {
		// TODO Auto-generated method stub
		return adminCouponItemMapper.updateCouponItem(adminCouponItemDto);
	}
	
	
}
