<?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.business.mapper.HwSceneModeMapper">
    
    <resultMap type="HwSceneMode" id="HwSceneModeResult">
        <result property="sceneModeId"    column="scene_mode_id"    />
        <result property="sceneModeName"    column="scene_mode_name"    />
        <result property="customFlag"    column="custom_flag"    />
        <result property="tenantId"    column="tenant_id"    />
        <result property="languageCode"    column="language_code"    />
        <result property="remark"    column="remark"    />
        <result property="sceneModeStatus"    column="scene_mode_status"    />
        <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="sceneModeField"    column="scene_mode_field"    />
    </resultMap>

    <sql id="selectHwSceneModeVo">
        select scene_mode_id, scene_mode_name, custom_flag, tenant_id, language_code, remark, scene_mode_status, create_by, create_time, update_by, update_time, scene_mode_field from hw_scene_mode
    </sql>

    <select id="selectHwSceneModeList" parameterType="HwSceneMode" resultMap="HwSceneModeResult">
        <include refid="selectHwSceneModeVo"/>
        <where>  
            <if test="sceneModeName != null  and sceneModeName != ''"> and scene_mode_name like concat('%', #{sceneModeName}, '%')</if>
            <if test="customFlag != null "> and custom_flag = #{customFlag}</if>
            <if test="tenantId != null "> and tenant_id = #{tenantId}</if>
            <if test="languageCode != null  and languageCode != ''"> and language_code = #{languageCode}</if>
            <if test="sceneModeStatus != null "> and scene_mode_status = #{sceneModeStatus}</if>
            <if test="sceneModeField != null  and sceneModeField != ''"> and scene_mode_field = #{sceneModeField}</if>
        </where>
    </select>
    
    <select id="selectHwSceneModeBySceneModeId" parameterType="Long" resultMap="HwSceneModeResult">
        <include refid="selectHwSceneModeVo"/>
        where scene_mode_id = #{sceneModeId}
    </select>
        
    <insert id="insertHwSceneMode" parameterType="HwSceneMode" useGeneratedKeys="true" keyProperty="sceneModeId">
        insert into hw_scene_mode
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="sceneModeName != null and sceneModeName != ''">scene_mode_name,</if>
            <if test="customFlag != null">custom_flag,</if>
            <if test="tenantId != null">tenant_id,</if>
            <if test="languageCode != null and languageCode != ''">language_code,</if>
            <if test="remark != null">remark,</if>
            <if test="sceneModeStatus != null">scene_mode_status,</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="sceneModeField != null">scene_mode_field,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="sceneModeName != null and sceneModeName != ''">#{sceneModeName},</if>
            <if test="customFlag != null">#{customFlag},</if>
            <if test="tenantId != null">#{tenantId},</if>
            <if test="languageCode != null and languageCode != ''">#{languageCode},</if>
            <if test="remark != null">#{remark},</if>
            <if test="sceneModeStatus != null">#{sceneModeStatus},</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="sceneModeField != null">#{sceneModeField},</if>
         </trim>
    </insert>

    <update id="updateHwSceneMode" parameterType="HwSceneMode">
        update hw_scene_mode
        <trim prefix="SET" suffixOverrides=",">
            <if test="sceneModeName != null and sceneModeName != ''">scene_mode_name = #{sceneModeName},</if>
            <if test="customFlag != null">custom_flag = #{customFlag},</if>
            <if test="tenantId != null">tenant_id = #{tenantId},</if>
            <if test="languageCode != null and languageCode != ''">language_code = #{languageCode},</if>
            <if test="remark != null">remark = #{remark},</if>
            <if test="sceneModeStatus != null">scene_mode_status = #{sceneModeStatus},</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="sceneModeField != null">scene_mode_field = #{sceneModeField},</if>
        </trim>
        where scene_mode_id = #{sceneModeId}
    </update>

    <delete id="deleteHwSceneModeBySceneModeId" parameterType="Long">
        delete from hw_scene_mode where scene_mode_id = #{sceneModeId}
    </delete>

    <delete id="deleteHwSceneModeBySceneModeIds" parameterType="String">
        delete from hw_scene_mode where scene_mode_id in 
        <foreach item="sceneModeId" collection="array" open="(" separator="," close=")">
            #{sceneModeId}
        </foreach>
    </delete>
</mapper>