<?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.base.mapper.BaseBusbarInfoMapper">
    
    <resultMap type="BaseBusbarInfo" id="BaseBusbarInfoResult">
        <result property="objId"    column="obj_id"    />
        <result property="busbarCode"    column="busbar_code"    />
        <result property="busbarAlias"    column="busbar_alias"    />
        <result property="cabinetCode"    column="cabinet_code"    />
        <result property="busbarDist"    column="busbar_dist"    />
        <result property="isChecked"    column="is_checked"    />
        <result property="isEnd"    column="is_end"    />
        <result property="isFlag"    column="is_flag"    />
        <result property="remark"    column="remark"    />
        <result property="createdBy"    column="created_by"    />
        <result property="createdTime"    column="created_time"    />
        <result property="updatedBy"    column="updated_by"    />
        <result property="updatedTime"    column="updated_time"    />
        <result property="isPictures"    column="is_pictures"    />
        <result property="wPanPos"    column="wPanPos"    />
        <result property="wTiltPos"    column="wTiltPos"    />
        <result property="wZoomPos"    column="wZoomPos"    />
        <result property="isRotate"    column="is_rotate"    />
    </resultMap>

    <sql id="selectBaseBusbarInfoVo">
        select obj_id, busbar_code, busbar_alias, cabinet_code, busbar_dist, is_checked, is_end, is_flag, remark, created_by, created_time, updated_by, updated_time, is_pictures, wPanPos, wTiltPos, wZoomPos, is_rotate from base_busbar_info
    </sql>

    <select id="selectBaseBusbarInfoList" parameterType="BaseBusbarInfo" resultMap="BaseBusbarInfoResult">
        <include refid="selectBaseBusbarInfoVo"/>
        <where>  
            <if test="objId != null "> and obj_id = #{objId}</if>
            <if test="busbarCode != null "> and busbar_code = #{busbarCode}</if>
            <if test="busbarAlias != null  and busbarAlias != ''"> and busbar_alias like concat('%', #{busbarAlias}, '%')</if>
            <if test="cabinetCode != null "> and cabinet_code = #{cabinetCode}</if>
            <if test="busbarDist != null "> and busbar_dist = #{busbarDist}</if>
            <if test="isChecked != null "> and is_checked = #{isChecked}</if>
            <if test="isEnd != null "> and is_end = #{isEnd}</if>
            <if test="isFlag != null "> and is_flag = #{isFlag}</if>
            <if test="remark != null  and remark != ''"> and remark = #{remark}</if>
            <if test="createdBy != null  and createdBy != ''"> and created_by = #{createdBy}</if>
            <if test="params.beginCreatedTime != null and params.beginCreatedTime != '' and params.endCreatedTime != null and params.endCreatedTime != ''"> and created_time between #{params.beginCreatedTime} and #{params.endCreatedTime}</if>
            <if test="updatedBy != null  and updatedBy != ''"> and updated_by = #{updatedBy}</if>
            <if test="params.beginUpdatedTime != null and params.beginUpdatedTime != '' and params.endUpdatedTime != null and params.endUpdatedTime != ''"> and updated_time between #{params.beginUpdatedTime} and #{params.endUpdatedTime}</if>
            <if test="isPictures != null "> and is_pictures = #{isPictures}</if>
            <if test="wPanPos != null  and wPanPos != ''"> and wPanPos = #{wPanPos}</if>
            <if test="wTiltPos != null  and wTiltPos != ''"> and wTiltPos = #{wTiltPos}</if>
            <if test="wZoomPos != null  and wZoomPos != ''"> and wZoomPos = #{wZoomPos}</if>
            <if test="isRotate != null "> and is_rotate = #{isRotate}</if>
        </where>
    </select>
    
    <select id="selectBaseBusbarInfoByObjId" parameterType="Long" resultMap="BaseBusbarInfoResult">
        <include refid="selectBaseBusbarInfoVo"/>
        where obj_id = #{objId}
    </select>

    <insert id="insertBaseBusbarInfo" parameterType="BaseBusbarInfo" useGeneratedKeys="true" keyProperty="objId">
        insert into base_busbar_info
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="busbarCode != null">busbar_code,</if>
            <if test="busbarAlias != null">busbar_alias,</if>
            <if test="cabinetCode != null">cabinet_code,</if>
            <if test="busbarDist != null">busbar_dist,</if>
            <if test="isChecked != null">is_checked,</if>
            <if test="isEnd != null">is_end,</if>
            <if test="isFlag != null">is_flag,</if>
            <if test="remark != null">remark,</if>
            <if test="createdBy != null">created_by,</if>
            <if test="createdTime != null">created_time,</if>
            <if test="updatedBy != null">updated_by,</if>
            <if test="updatedTime != null">updated_time,</if>
            <if test="isPictures != null">is_pictures,</if>
            <if test="wPanPos != null">wPanPos,</if>
            <if test="wTiltPos != null">wTiltPos,</if>
            <if test="wZoomPos != null">wZoomPos,</if>
            <if test="isRotate != null">is_rotate,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="busbarCode != null">#{busbarCode},</if>
            <if test="busbarAlias != null">#{busbarAlias},</if>
            <if test="cabinetCode != null">#{cabinetCode},</if>
            <if test="busbarDist != null">#{busbarDist},</if>
            <if test="isChecked != null">#{isChecked},</if>
            <if test="isEnd != null">#{isEnd},</if>
            <if test="isFlag != null">#{isFlag},</if>
            <if test="remark != null">#{remark},</if>
            <if test="createdBy != null">#{createdBy},</if>
            <if test="createdTime != null">#{createdTime},</if>
            <if test="updatedBy != null">#{updatedBy},</if>
            <if test="updatedTime != null">#{updatedTime},</if>
            <if test="isPictures != null">#{isPictures},</if>
            <if test="wPanPos != null">#{wPanPos},</if>
            <if test="wTiltPos != null">#{wTiltPos},</if>
            <if test="wZoomPos != null">#{wZoomPos},</if>
            <if test="isRotate != null">#{isRotate},</if>
         </trim>
    </insert>

    <update id="updateBaseBusbarInfo" parameterType="BaseBusbarInfo">
        update base_busbar_info
        <trim prefix="SET" suffixOverrides=",">
            <if test="busbarCode != null">busbar_code = #{busbarCode},</if>
            <if test="busbarAlias != null">busbar_alias = #{busbarAlias},</if>
            <if test="cabinetCode != null">cabinet_code = #{cabinetCode},</if>
            <if test="busbarDist != null">busbar_dist = #{busbarDist},</if>
            <if test="isChecked != null">is_checked = #{isChecked},</if>
            <if test="isEnd != null">is_end = #{isEnd},</if>
            <if test="isFlag != null">is_flag = #{isFlag},</if>
            <if test="remark != null">remark = #{remark},</if>
            <if test="createdBy != null">created_by = #{createdBy},</if>
            <if test="createdTime != null">created_time = #{createdTime},</if>
            <if test="updatedBy != null">updated_by = #{updatedBy},</if>
            <if test="updatedTime != null">updated_time = #{updatedTime},</if>
            <if test="isPictures != null">is_pictures = #{isPictures},</if>
            <if test="wPanPos != null">wPanPos = #{wPanPos},</if>
            <if test="wTiltPos != null">wTiltPos = #{wTiltPos},</if>
            <if test="wZoomPos != null">wZoomPos = #{wZoomPos},</if>
            <if test="isRotate != null">is_rotate = #{isRotate},</if>
        </trim>
        where obj_id = #{objId}
    </update>

    <delete id="deleteBaseBusbarInfoByObjId" parameterType="Long">
        delete from base_busbar_info where obj_id = #{objId}
    </delete>

    <delete id="deleteBaseBusbarInfoByObjIds" parameterType="String">
        delete from base_busbar_info where obj_id in 
        <foreach item="objId" collection="array" open="(" separator="," close=")">
            #{objId}
        </foreach>
    </delete>
</mapper>