package com.yc.ship.module.marketing.dal.mysql.couponProduct;

import com.yc.ship.framework.mybatis.core.mapper.BaseMapperX;
import com.yc.ship.framework.mybatis.core.query.LambdaQueryWrapperX;
import com.yc.ship.module.marketing.controller.admin.couponProduct.vo.RelationRespVo;
import com.yc.ship.module.marketing.dal.dataobject.couponPorduct.CouponProductDo;
import org.apache.ibatis.annotations.Mapper;

import java.util.List;

/**
 * 优惠券关联产品 Mapper
 *
 * @author lfy
 */
@Mapper
public interface CouponProductMapper extends BaseMapperX<CouponProductDo> {


    /**
     * 根据优惠券ID删除优惠券关联产品
     * @param couponId
     */
    default void deleteByCouponId(Long couponId) {
        delete(CouponProductDo::getCouponId, couponId);
    }

    /**
     * 查询关联产品信息列表
     * @param couponId
     * @return
     */
    List<RelationRespVo> selectRelationProductList(Long couponId);

    /**
     * 根据优惠券ID列表查询关联产品信息
     * @param couponIds
     * @return
     */
    default List<CouponProductDo> selectListByCouponIds(List<Long> couponIds) {
        return selectList(new LambdaQueryWrapperX<CouponProductDo>()
                .in(CouponProductDo::getCouponId, couponIds));
    }
}