<?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.model.mapper.AppCheckImageMapper">
    
    <resultMap type="AppCheckImage" id="AppCheckImageResult">
        <result property="checkImageId"    column="check_image_id"    />
        <result property="checkId"    column="check_id"    />
        <result property="checkImageName"    column="check_image_name"    />
        <result property="checkImageTypeId"    column="check_image_type_id"    />
    </resultMap>

    <resultMap type="com.ruoyi.model.vo.AppCheckImageVo" id="AppCheckImageResultVo">
        <result property="checkImageId"    column="check_image_id"    />
        <result property="checkId"    column="check_id"    />
        <result property="checkImageName"    column="check_image_name"    />
        <result property="checkImageTypeId"    column="check_image_type_id"    />
        <collection property="children" ofType="com.ruoyi.model.domain.AppCheckImageType">
            <result property="checkImageTypeId"    column="check_image_type_id"    />
            <result property="checkImageTypeName"    column="check_image_type_name"    />
            <result property="checkImageTypeMax"    column="check_image_type_max"    />
            <result property="checkImageTypeMin"    column="check_image_type_min"    />
            <result property="createBy"    column="create_by"    />
            <result property="createTime"    column="create_time"    />
            <result property="updateBy"    column="update_by"    />
            <result property="updateTime"    column="update_time"    />
            <result property="delFlag"    column="del_flag"    />
        </collection>
    </resultMap>


    <sql id="selectAppCheckImageVo">
        select check_image_id, check_id, check_image_name, check_image_type_id from app_check_image
    </sql>

    <select id="selectAppCheckImageList" parameterType="AppCheckImage" resultMap="AppCheckImageResult">
        <include refid="selectAppCheckImageVo"/>
        <where>  
            <if test="checkId != null "> and check_id = #{checkId}</if>
            <if test="checkImageName != null  and checkImageName != ''"> and check_image_name like concat('%', #{checkImageName}, '%')</if>
            <if test="checkImageTypeId != null "> and check_image_type_id = #{checkImageTypeId}</if>
        </where>
    </select>
    
    <select id="selectAppCheckImageByCheckImageId" parameterType="Long" resultMap="AppCheckImageResult">
        <include refid="selectAppCheckImageVo"/>
        where check_image_id = #{checkImageId}
    </select>
    <select id="getAppCheckImageList" resultMap="AppCheckImageResultVo">
        select
            *
        from
            app_check_image image
                left join app_check_image_type type
                    on image.check_image_type_id = type.check_image_type_id
    </select>

    <insert id="insertAppCheckImage" parameterType="AppCheckImage">
        insert into app_check_image
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="checkImageId != null">check_image_id,</if>
            <if test="checkId != null">check_id,</if>
            <if test="checkImageName != null and checkImageName != ''">check_image_name,</if>
            <if test="checkImageTypeId != null">check_image_type_id,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="checkImageId != null">#{checkImageId},</if>
            <if test="checkId != null">#{checkId},</if>
            <if test="checkImageName != null and checkImageName != ''">#{checkImageName},</if>
            <if test="checkImageTypeId != null">#{checkImageTypeId},</if>
         </trim>
    </insert>

    <update id="updateAppCheckImage" parameterType="AppCheckImage">
        update app_check_image
        <trim prefix="SET" suffixOverrides=",">
            <if test="checkId != null">check_id = #{checkId},</if>
            <if test="checkImageName != null and checkImageName != ''">check_image_name = #{checkImageName},</if>
            <if test="checkImageTypeId != null">check_image_type_id = #{checkImageTypeId},</if>
        </trim>
        where check_image_id = #{checkImageId}
    </update>

    <delete id="deleteAppCheckImageByCheckImageId" parameterType="Long">
        delete from app_check_image where check_image_id = #{checkImageId}
    </delete>

    <delete id="deleteAppCheckImageByCheckImageIds" parameterType="String">
        delete from app_check_image where check_image_id in 
        <foreach item="checkImageId" collection="array" open="(" separator="," close=")">
            #{checkImageId}
        </foreach>
    </delete>
</mapper>