package com.haha.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.haha.entity.TimedDiscountDevice;
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 TimedDiscountDeviceMapper extends BaseMapper<TimedDiscountDevice> {

    @Select("SELECT device_id FROM t_timed_discount_device WHERE activity_id = #{activityId}")
    List<String> selectDeviceIdsByActivityId(@Param("activityId") Long activityId);

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

    @Select("SELECT activity_id FROM t_timed_discount_device WHERE device_id = #{deviceId}")
    List<Long> selectActivityIdsByDeviceId(@Param("deviceId") String deviceId);
}
