package com.ycwl.basic.service.pc.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ycwl.basic.mapper.CouponMapper;
import com.ycwl.basic.model.pc.coupon.entity.CouponEntity;
import com.ycwl.basic.model.pc.coupon.req.CouponQueryReq;
import com.ycwl.basic.model.pc.coupon.resp.CouponRespVO;
import com.ycwl.basic.service.pc.CouponService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class CouponServiceImpl extends ServiceImpl<CouponMapper, CouponEntity> implements CouponService {

    @Autowired
    private CouponMapper couponMapper;

    @Override
    public Integer add(CouponEntity coupon) {
        return couponMapper.insert(coupon);
    }

    @Override
    public Boolean update(CouponEntity coupon) {
        return couponMapper.updateById(coupon) > 0;
    }

    @Override
    public Boolean delete(Integer id) {
        return removeById(id);
    }

    @Override
    public CouponEntity getById(Integer id) {
        return couponMapper.selectById(id);
    }

    @Override
    public List<CouponRespVO> list(CouponQueryReq query) {
        List<CouponRespVO> list = couponMapper.selectByQuery(query);
        return list;
    }

    @Override
    public Boolean updateStatus(Integer id) {
        return couponMapper.updateStatus(id) > 0;
    }
}