<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
        PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
        "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="cn.fateverse.query.mapper.PortalMappingMapper">
    <sql id="selectPortalMapping">
        select mapping_id,
               portal_id,
               mapping_key,
               mapping_type,
               mapping_value,
               input_type,
               required,
               description
        from portal_mapping
    </sql>

    <select id="selectByPortalId" resultType="cn.fateverse.query.entity.PortalMapping">
        <include refid="selectPortalMapping"/>
        where portal_id = #{portalId}
    </select>

    <select id="selectByPortalIds" resultType="cn.fateverse.query.entity.PortalMapping">
        <include refid="selectPortalMapping"/>
        where portal_id in
        <foreach collection="list" item="portalId" open="(" separator="," close=")">
            #{portalId}
        </foreach>
    </select>

    <insert id="insertBatch">
        insert into portal_mapping (portal_id, mapping_key, mapping_type, mapping_value, input_type, required,
        description)
        values
        <foreach collection="list" item="item" separator=",">
            (#{item.portalId}, #{item.mappingKey}, #{item.mappingType}, #{item.mappingValue}, #{item.inputType},
            #{item.required},#{item.description})
        </foreach>
    </insert>

    <delete id="deleteByPortalId">
        delete
        from portal_mapping
        where portal_id = #{portalId}
    </delete>

</mapper>