<?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.system.mapper.ImageDataMapper">

    <resultMap type="ImageDatas" id="ImageDataResult">
        <result property="imageId" column="image_id"/>
        <result property="imageName" column="image_name"/>
        <result property="imageContent" column="image_content"/>
        <result property="imageIntroduce" column="image_introduce"/>
        <result property="status" column="status"/>
        <result property="type" column="type"/>
        <result property="isDel" column="is_del"/>
        <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="remark" column="remark"/>
    </resultMap>

    <sql id="selectImageDataVo">
        select image_id, image_name, image_content, image_introduce, status, type, is_del, create_by, create_time, update_by, update_time, remark from image_data
    </sql>

    <select id="selectImageDatasList" parameterType="ImageDatas" resultMap="ImageDataResult">
        <include refid="selectImageDataVo"/>
        where
        is_del = 'N'
        <if test="imageName != null  and imageName != ''">and image_name like concat('%', #{imageName}, '%')</if>
        <if test="type != null  and type != ''">and type = #{type}</if>
        order by create_time DESC
    </select>

    <select id="selectImageDatasListMenHu" parameterType="ImageDatas" resultMap="ImageDataResult">
        select image_name,image_name, image_content, image_introduce,type from image_data
        <where>
            is_del = 'N'
            and status = '0'
            <if test="imageName != null  and imageName != ''">and image_name like concat('%', #{imageName}, '%')</if>
            <if test="type != null  and type != ''">and type = #{type}</if>
        </where>
        order by create_time DESC
    </select>

    <select id="selectImageDatasByImageId" parameterType="Long" resultMap="ImageDataResult">
        <include refid="selectImageDataVo"/>
        where image_id = #{imageId} and is_del = 'N'
    </select>

    <insert id="insertImageDatas" parameterType="ImageDatas" useGeneratedKeys="true" keyProperty="imageId">
        insert into image_data
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="imageName != null and imageName != ''">image_name,</if>
            <if test="imageContent != null">image_content,</if>
            <if test="imageIntroduce != null">image_introduce,</if>
            <if test="status != null">status,</if>
            <if test="type != null">type,</if>
            <if test="isDel != null">is_del,</if>
            <if test="createBy != null">create_by,</if>
            <if test="createTime != null">create_time,</if>
            <if test="updateBy != null">update_by,</if>
            <if test="updateTime != null">update_time,</if>
            <if test="remark != null">remark,</if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="imageName != null and imageName != ''">#{imageName},</if>
            <if test="imageContent != null">#{imageContent},</if>
            <if test="imageIntroduce != null">#{imageIntroduce},</if>
            <if test="status != null">#{status},</if>
            <if test="type != null">#{type},</if>
            <if test="isDel != null">#{isDel},</if>
            <if test="createBy != null">#{createBy},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="updateBy != null">#{updateBy},</if>
            <if test="updateTime != null">#{updateTime},</if>
            <if test="remark != null">#{remark},</if>
        </trim>
    </insert>

    <update id="updateImageDatas" parameterType="ImageDatas">
        update image_data
        <trim prefix="SET" suffixOverrides=",">
            <if test="imageName != null and imageName != ''">image_name = #{imageName},</if>
            <if test="imageContent != null">image_content = #{imageContent},</if>
            <if test="imageIntroduce != null">image_introduce = #{imageIntroduce},</if>
            <if test="status != null">status = #{status},</if>
            <if test="type != null">type = #{type},</if>
            <if test="isDel != null">is_del = #{isDel},</if>
            <if test="createBy != null">create_by = #{createBy},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
            <if test="updateBy != null">update_by = #{updateBy},</if>
            <if test="updateTime != null">update_time = #{updateTime},</if>
            <if test="remark != null">remark = #{remark},</if>
        </trim>
        where image_id = #{imageId}
    </update>

    <delete id="deleteImageDatasByImageId" parameterType="Long">
        delete from image_data where image_id = #{imageId}
    </delete>

    <delete id="deleteImageDatasByImageIds" parameterType="String">
        delete from image_data where image_id in
        <foreach item="imageId" collection="array" open="(" separator="," close=")">
            #{imageId}
        </foreach>
    </delete>
</mapper>