<?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.zcxk.dao.SceneImageMapper">


    <resultMap type="SceneImageEntity" id="SceneImageResult">
        <result property="id" column="id"/>
        <result property="imageType" column="image_type"/>
        <result property="imagePath" column="image_path"/>
        <result property="sceneId" column="scene_id"/>
        <result property="status" column="status"/>
        <result property="dateCreate" column="date_create"/>
        <result property="createBy" column="create_by"/>
        <result property="dateUpdate" column="date_update"/>
        <result property="updateBy" column="update_by"/>
    </resultMap>

    <!--  实体栏位  -->
    <sql id="sceneImageColumns">
         a.id as "id" ,
         a.image_type as "imageType" ,
         a.image_path as "imagePath" ,
         a.scene_id as "sceneId" ,
         a.status as "status" ,
         a.date_create as "dateCreate" ,
         a.create_by as "createBy" ,
         a.date_update as "dateUpdate" ,
         a.update_by as "updateBy" 
     </sql>


    <!--  根据主键获取实体   -->
    <select id="findSceneImageById" resultType="com.zcxk.entity.SceneImageEntity">
        SELECT
        <include refid="sceneImageColumns"/>
        FROM sms_scene_image a
        WHERE a.id = #{id}
    </select>

    <!--  根据获取实体List   -->
    <select id="findList" resultType="com.zcxk.entity.SceneImageEntity">
        SELECT
        <include refid="sceneImageColumns"/>
        FROM sms_scene_image a
        <where>
             a.status=1
            <if test="imageType != null ">and a.image_type = #{imageType}</if>
            <if test="imagePath != null  and imagePath != ''">and a.image_path = #{imagePath}</if>
            <if test="sceneId != null ">and a.scene_id = #{sceneId}</if>
            <if test="dateUpdate != null ">and a.date_update = #{dateUpdate}</if>
        </where>
    </select>

    <!--  根据获取实体 page   -->
    <select id="findPage" resultType="com.zcxk.entity.SceneImageEntity">
        SELECT
        <include refid="sceneImageColumns"/>
        FROM sms_scene_image a
        <where>
            a.status=1
            <if test="sceneImage.imageType != null ">and a.image_type = #{sceneImage.imageType}</if>
            <if test="sceneImage.imagePath != null  and sceneImage.imagePath != ''">and a.image_path =
                #{sceneImage.imagePath}
            </if>
            <if test="sceneImage.sceneId != null ">and a.scene_id = #{sceneImage.sceneId}</if>
            <if test="sceneImage.dateUpdate != null ">and a.date_update = #{sceneImage.dateUpdate}</if>
        </where>
    </select>
    <update id="updateBySceneId">
        update sms_scene_image  set STATUS=0 where SCENE_ID=#{id}
    </update>
</mapper>