package com.pandoli365.bibimbap.mapper;

import com.pandoli365.bibimbap.data.UserBadgeKeyRow;
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 UserBadgesQueryMapper {

    @Select("""
            <script>
            SELECT
                user_id AS "userId",
                badge_key AS "badgeKey"
            FROM user_badges
            WHERE revoked_at IS NULL
              AND user_id IN
            <foreach item="uid" collection="userIds" open="(" separator="," close=")">#{uid}</foreach>
            </script>
            """)
    List<UserBadgeKeyRow> listActiveBadgeKeysByUserIds(@Param("userIds") List<Long> userIds);
}
