<?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="com.ruoyi.web.modules.prosperity.mapper.BizCommonProsperityProjectOpImageMapper">

    <resultMap type="com.ruoyi.web.modules.prosperity.domain.BizCommonProsperityProjectOpImage" id="OpImageResult">
        <id     property="id"         column="id"/>
        <result property="projectId"  column="project_id"/>
        <result property="fileUrl"    column="file_url"/>
        <result property="filePath"   column="file_path"/>
        <result property="sortOrder"  column="sort_order"/>
        <result property="createTime" column="create_time"/>
    </resultMap>

    <select id="selectByProjectId" parameterType="long" resultMap="OpImageResult">
        select id, project_id, file_url, file_path, sort_order, create_time
        from biz_common_prosperity_project_op_image
        where project_id = #{projectId}
        order by sort_order asc, id asc
    </select>

    <select id="countByProjectId" parameterType="long" resultType="int">
        select count(*) from biz_common_prosperity_project_op_image where project_id = #{projectId}
    </select>

    <insert id="insertBatch" parameterType="java.util.List">
        insert into biz_common_prosperity_project_op_image (project_id, file_url, file_path, sort_order, create_time)
        values
        <foreach collection="list" item="item" separator=",">
            (#{item.projectId}, #{item.fileUrl}, #{item.filePath}, #{item.sortOrder}, sysdate())
        </foreach>
    </insert>

    <delete id="deleteByProjectId" parameterType="long">
        delete from biz_common_prosperity_project_op_image where project_id = #{projectId}
    </delete>

    <delete id="deleteByProjectIds" parameterType="long">
        delete from biz_common_prosperity_project_op_image where project_id in
        <foreach collection="array" item="id" open="(" separator="," close=")">
            #{id}
        </foreach>
    </delete>

    <select id="selectByProjectIds" resultMap="OpImageResult">
        select id, project_id, file_url, file_path, sort_order, create_time
        from biz_common_prosperity_project_op_image
        where project_id in
        <foreach collection="projectIds" item="pid" open="(" separator="," close=")">
            #{pid}
        </foreach>
        order by project_id asc, sort_order asc, id asc
    </select>
</mapper>
