<?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.engine.salary.mapper.salarysob.SalarySobItemHideMapper">
    <delete id="deleteBySalarySobIds">
        delete from hrsa_salary_item_hide
        WHERE delete_type = 0
        AND salary_sob_id IN
        <foreach collection="ids" open="(" item="salarySobId" separator="," close=")">
        #{salarySobId}
        </foreach>
    </delete>


    <!-- 根据账套id获取关闭显示开关的itemID -->
    <select id="listHideItemIds" resultType="java.lang.Long">
        SELECT salary_item_id FROM hrsa_salary_item_hide
        where delete_type=0
          and salary_sob_id=#{salarySobId}
          and item_hide=1
          <if test="isGroup!=null">
              and is_group=#{isGroup}
          </if>
        <if test="salaryItemId!=null">
            and salary_item_id=#{salaryItemId}
        </if>
    </select>

    <select id="listSome" resultType="com.engine.salary.entity.salarysob.po.SalarySobItemHidePO">
        SELECT
          id
        , salary_sob_id
        , salary_item_id
        , is_group
        , item_hide
        FROM hrsa_salary_item_hide
        where delete_type=0
        <if test="param.id!=null">
            and id=#{param.id}
        </if>
        <if test="param.salarySobId!=null">
            and salary_sob_id=#{param.salarySobId}
        </if>
        <if test="param.itemHide!=null">
            and item_hide=#{param.itemHide}
        </if>
        <if test="param.isGroup!=null">
            and is_group=#{param.isGroup}
        </if>
        <if test="param.salaryItemId!=null">
            and salary_item_id=#{param.salaryItemId}
        </if>
    </select>


    <!-- 更新,更新全部字段 -->
    <update id="update" parameterType="com.engine.salary.entity.salarysob.po.SalarySobItemHidePO">
        UPDATE hrsa_salary_item_hide
        <set>
            item_hide=#{itemHide},
            update_time=#{updateTime}
        </set>
        WHERE id = #{id} AND delete_type = 0
    </update>

    <!-- 更新,更新全部字段 -->
    <update id="updateByItemId" parameterType="com.engine.salary.entity.salarysob.po.SalarySobItemHidePO">
        UPDATE hrsa_salary_item_hide
        <set>
            item_hide=#{itemHide},
            update_time=#{updateTime}
        </set>
        WHERE salary_sob_id = #{salarySobId} AND salary_item_id= #{salaryItemId}  AND delete_type = 0
    </update>

</mapper>