package com.haha.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.haha.entity.ActivityProduct;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface ActivityProductMapper extends BaseMapper<ActivityProduct> {

    @Select("SELECT product_id FROM t_activity_product WHERE activity_id = #{activityId}")
    List<Long> selectProductIdsByActivityId(@Param("activityId") Long activityId);

    @Delete("DELETE FROM t_activity_product WHERE activity_id = #{activityId}")
    int deleteByActivityId(@Param("activityId") Long activityId);

    @Select("SELECT activity_id FROM t_activity_product WHERE product_id = #{productId}")
    List<Long> selectActivityIdsByProductId(@Param("productId") Long productId);
}
