<?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.BaseCabinetInfoMapper">

    <resultMap type="BaseCabinetInfo" id="BaseCabinetInfoResult">
        <result property="objId"    column="obj_id"    />
        <result property="cabinetCode"    column="cabinet_code"    />
        <result property="cabinetAlias"    column="cabinet_alias"    />
        <result property="isChecked"    column="is_checked"    />
        <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="isRotate"    column="is_rotate"    />
        <result property="rotateAngle"    column="rotate_angle"    />
    </resultMap>

    <sql id="selectBaseCabinetInfoVo">
        select bci.obj_id,
               bci.cabinet_code,
               bci.cabinet_alias,
               bci.is_checked,
               bci.is_flag,
               bci.remark,
               bci.created_by,
               bci.created_time,
               bci.updated_by,
               bci.updated_time,
               bci.is_rotate,
               bci.rotate_angle
        from base_cabinet_info bci

    </sql>

    <select id="selectBaseCabinetInfoList" parameterType="BaseCabinetInfo" resultMap="BaseCabinetInfoResult">
        <include refid="selectBaseCabinetInfoVo"/>
        <where>
            <if test="objId != null "> and bci.obj_id = #{objId}</if>
            <if test="cabinetCode != null "> and bci.cabinet_code = #{cabinetCode}</if>
            <if test="cabinetAlias != null  and cabinetAlias != ''"> and bci.cabinet_alias = #{cabinetAlias}</if>
            <if test="isChecked != null "> and bci.is_checked = #{isChecked}</if>
            <if test="isFlag != null "> and bci.is_flag = #{isFlag}</if>
            <if test="remark != null  and remark != ''"> and bci.remark = #{remark}</if>
            <if test="createdBy != null  and createdBy != ''"> and bci.created_by = #{createdBy}</if>
            <if test="params.beginCreatedTime != null and params.beginCreatedTime != '' and params.endCreatedTime != null and params.endCreatedTime != ''"> and bci.created_time between #{params.beginCreatedTime} and #{params.endCreatedTime}</if>
            <if test="updatedBy != null  and updatedBy != ''"> and bci.updated_by = #{updatedBy}</if>
            <if test="params.beginUpdatedTime != null and params.beginUpdatedTime != '' and params.endUpdatedTime != null and params.endUpdatedTime != ''"> and bci.updated_time between #{params.beginUpdatedTime} and #{params.endUpdatedTime}</if>
            <if test="isRotate != null "> and bci.is_rotate = #{isRotate}</if>
            <if test="rotateAngle != null "> and bci.rotate_angle = #{rotateAngle}</if>
        </where>
    </select>

    <select id="selectBaseCabinetInfoByObjId" parameterType="Long" resultMap="BaseCabinetInfoResult">
        <include refid="selectBaseCabinetInfoVo"/>
        where bci.obj_id = #{objId}
    </select>

    <insert id="insertBaseCabinetInfo" parameterType="BaseCabinetInfo" useGeneratedKeys="true" keyProperty="objId">
        insert into base_cabinet_info
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="cabinetCode != null">cabinet_code,</if>
            <if test="cabinetAlias != null">cabinet_alias,</if>
            <if test="isChecked != null">is_checked,</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="isRotate != null">is_rotate,</if>
            <if test="rotateAngle != null">rotate_angle,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="cabinetCode != null">#{cabinetCode},</if>
            <if test="cabinetAlias != null">#{cabinetAlias},</if>
            <if test="isChecked != null">#{isChecked},</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="isRotate != null">#{isRotate},</if>
            <if test="rotateAngle != null">#{rotateAngle},</if>
         </trim>
    </insert>

    <update id="updateBaseCabinetInfo" parameterType="BaseCabinetInfo">
        update base_cabinet_info
        <trim prefix="SET" suffixOverrides=",">
            <if test="cabinetCode != null">cabinet_code = #{cabinetCode},</if>
            <if test="cabinetAlias != null">cabinet_alias = #{cabinetAlias},</if>
            <if test="isChecked != null">is_checked = #{isChecked},</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="isRotate != null">is_rotate = #{isRotate},</if>
            <if test="rotateAngle != null">rotate_angle = #{rotateAngle},</if>
        </trim>
        where obj_id = #{objId}
    </update>

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

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

    <select id="countBaseCabinetInfo" resultType="Integer">
        select count(1) from base_cabinet_info
    </select>

</mapper>
