<?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.report.SalaryStatisticsReportMapper">
    <resultMap id="BaseResultMap" type="com.engine.salary.report.entity.po.SalaryStatisticsReportPO">
        <result column="create_time" property="createTime"/>
        <result column="creator" property="creator"/>
        <result column="delete_type" property="deleteType"/>
        <result column="depart_setting" property="departSetting"/>
        <result column="dimension" property="dimension"/>
        <result column="employee_setting" property="employeeSetting"/>
        <result column="grade_setting" property="gradeSetting"/>
        <result column="hiredate_setting" property="hiredateSetting"/>
        <result column="id" property="id"/>
        <result column="income_category_setting" property="incomeCategorySetting"/>
        <result column="leavedate_setting" property="leavedateSetting"/>
        <result column="position_setting" property="positionSetting"/>
        <result column="remark" property="remark"/>
        <result column="report_name" property="reportName"/>
        <result column="time_type" property="timeType"/>
        <result column="salary_end_month" property="salaryEndMonth"/>
        <result column="salary_start_month" property="salaryStartMonth"/>
        <result column="second_dimension" property="secondDimension"/>
        <result column="sort_index" property="sortIndex"/>
        <result column="sort_type" property="sortType"/>
        <result column="status_setting" property="statusSetting"/>
        <result column="sub_company_setting" property="subCompanySetting"/>
        <result column="tax_agent_setting" property="taxAgentSetting"/>
        <result column="salary_sob_setting" property="salarySobSetting"/>
        <result column="tenant_key" property="tenantKey"/>
        <result column="update_time" property="updateTime"/>
    </resultMap>

    <!-- 表字段 -->
    <sql id="baseColumns">
        t
        .
        create_time
        , t.creator
        , t.delete_type
        , t.depart_setting
        , t.dimension
        , t.employee_setting
        , t.grade_setting
        , t.hiredate_setting
        , t.id
        , t.income_category_setting
        , t.leavedate_setting
        , t.position_setting
        , t.remark
        , t.report_name
        , t.salary_end_month
        , t.salary_start_month
        , t.second_dimension
        , t.sort_index
        , t.sort_type
        , t.status_setting
        , t.sub_company_setting
        , t.tax_agent_setting
        , t.tenant_key
        , t.update_time
        , t.time_type
        , t.salary_sob_setting
    </sql>

    <!-- 查询全部 -->
    <select id="listAll" resultMap="BaseResultMap">
        SELECT
        <include refid="baseColumns"/>
        FROM hrsa_salary_stats_report t
        WHERE delete_type = 0
    </select>

    <!-- 根据主键获取单条记录 -->
    <select id="getById" resultMap="BaseResultMap" parameterType="Long">
        SELECT
        <include refid="baseColumns"/>
        FROM hrsa_salary_stats_report t
        WHERE id = #{id} AND delete_type = 0
    </select>

    <!-- 条件查询 -->
    <select id="listSome" resultMap="BaseResultMap"
            parameterType="com.engine.salary.report.entity.po.SalaryStatisticsReportPO">
        SELECT
        <include refid="baseColumns"/>
        FROM hrsa_salary_stats_report t
        WHERE delete_type = 0
        <if test="createTime != null">
            AND create_time = #{createTime}
        </if>
        <if test="creator != null">
            AND creator = #{creator}
        </if>
        <if test="deleteType != null">
            AND delete_type = #{deleteType}
        </if>
        <if test="departSetting != null">
            AND depart_setting = #{departSetting}
        </if>
        <if test="dimension != null">
            AND dimension = #{dimension}
        </if>
        <if test="employeeSetting != null">
            AND employee_setting = #{employeeSetting}
        </if>
        <if test="gradeSetting != null">
            AND grade_setting = #{gradeSetting}
        </if>
        <if test="hiredateSetting != null">
            AND hiredate_setting = #{hiredateSetting}
        </if>
        <if test="id != null">
            AND id = #{id}
        </if>
        <if test="incomeCategorySetting != null">
            AND income_category_setting = #{incomeCategorySetting}
        </if>
        <if test="leavedateSetting != null">
            AND leavedate_setting = #{leavedateSetting}
        </if>
        <if test="positionSetting != null">
            AND position_setting = #{positionSetting}
        </if>
        <if test="remark != null">
            AND remark = #{remark}
        </if>
        <if test="reportName != null">
            AND report_name = #{reportName}
        </if>
        <if test="timeType != null">
            AND time_type = #{timeType}
        </if>
        <if test="salaryEndMonth != null">
            AND salary_end_month = #{salaryEndMonth}
        </if>
        <if test="salaryStartMonth != null">
            AND salary_start_month = #{salaryStartMonth}
        </if>
        <if test="secondDimension != null">
            AND second_dimension = #{secondDimension}
        </if>
        <if test="sortIndex != null">
            AND sort_index = #{sortIndex}
        </if>
        <if test="sortType != null">
            AND sort_type = #{sortType}
        </if>
        <if test="statusSetting != null">
            AND status_setting = #{statusSetting}
        </if>
        <if test="subCompanySetting != null">
            AND sub_company_setting = #{subCompanySetting}
        </if>
        <if test="taxAgentSetting != null">
            AND tax_agent_setting = #{taxAgentSetting}
        </if>
        <if test="tenantKey != null">
            AND tenant_key = #{tenantKey}
        </if>
        <if test="updateTime != null">
            AND update_time = #{updateTime}
        </if>
        <if test="ids != null and ids.size()>0">
            AND id IN
            <foreach collection="ids" open="(" item="id" separator="," close=")">
                #{id}
            </foreach>
        </if>
        ORDER BY id DESC
    </select>


    <!-- 插入不为NULL的字段 -->
    <insert id="insertIgnoreNull" parameterType="com.engine.salary.report.entity.po.SalaryStatisticsReportPO">
        INSERT INTO hrsa_salary_stats_report
        <trim prefix="(" suffix=")" suffixOverrides=",">

            <if test="createTime != null">
                create_time,
            </if>
            <if test="creator != null">
                creator,
            </if>
            <if test="deleteType != null">
                delete_type,
            </if>
            <if test="departSetting != null">
                depart_setting,
            </if>
            <if test="dimension != null">
                dimension,
            </if>
            <if test="employeeSetting != null">
                employee_setting,
            </if>
            <if test="gradeSetting != null">
                grade_setting,
            </if>
            <if test="hiredateSetting != null">
                hiredate_setting,
            </if>
            <if test="id != null">
                id,
            </if>
            <if test="incomeCategorySetting != null">
                income_category_setting,
            </if>
            <if test="leavedateSetting != null">
                leavedate_setting,
            </if>
            <if test="positionSetting != null">
                position_setting,
            </if>
            <if test="remark != null">
                remark,
            </if>
            <if test="reportName != null">
                report_name,
            </if>
            <if test="timeType != null">
                time_type,
            </if>
            <if test="salaryEndMonth != null">
                salary_end_month,
            </if>
            <if test="salaryStartMonth != null">
                salary_start_month,
            </if>
            <if test="secondDimension != null">
                second_dimension,
            </if>
            <if test="sortIndex != null">
                sort_index,
            </if>
            <if test="sortType != null">
                sort_type,
            </if>
            <if test="statusSetting != null">
                status_setting,
            </if>
            <if test="subCompanySetting != null">
                sub_company_setting,
            </if>
            <if test="taxAgentSetting != null">
                tax_agent_setting,
            </if>
            <if test="salarySobSetting != null">
                salary_sob_setting,
            </if>
            <if test="tenantKey != null">
                tenant_key,
            </if>
            <if test="updateTime != null">
                update_time,
            </if>
        </trim>
        <trim prefix="VALUES (" suffix=")" suffixOverrides=",">
            <if test="createTime != null">
                #{createTime},
            </if>
            <if test="creator != null">
                #{creator},
            </if>
            <if test="deleteType != null">
                #{deleteType},
            </if>
            <if test="departSetting != null">
                #{departSetting},
            </if>
            <if test="dimension != null">
                #{dimension},
            </if>
            <if test="employeeSetting != null">
                #{employeeSetting},
            </if>
            <if test="gradeSetting != null">
                #{gradeSetting},
            </if>
            <if test="hiredateSetting != null">
                #{hiredateSetting},
            </if>
            <if test="id != null">
                #{id},
            </if>
            <if test="incomeCategorySetting != null">
                #{incomeCategorySetting},
            </if>
            <if test="leavedateSetting != null">
                #{leavedateSetting},
            </if>
            <if test="positionSetting != null">
                #{positionSetting},
            </if>
            <if test="remark != null">
                #{remark},
            </if>
            <if test="reportName != null">
                #{reportName},
            </if>
            <if test="timeType != null">
                #{timeType},
            </if>
            <if test="salaryEndMonth != null">
                #{salaryEndMonth},
            </if>
            <if test="salaryStartMonth != null">
                #{salaryStartMonth},
            </if>
            <if test="secondDimension != null">
                #{secondDimension},
            </if>
            <if test="sortIndex != null">
                #{sortIndex},
            </if>
            <if test="sortType != null">
                #{sortType},
            </if>
            <if test="statusSetting != null">
                #{statusSetting},
            </if>
            <if test="subCompanySetting != null">
                #{subCompanySetting},
            </if>
            <if test="taxAgentSetting != null">
                #{taxAgentSetting},
            </if>
            <if test="salarySobSetting != null">
                #{salarySobSetting},
            </if>
            <if test="tenantKey != null">
                #{tenantKey},
            </if>
            <if test="updateTime != null">
                #{updateTime},
            </if>
        </trim>
    </insert>

    <!-- 更新,更新全部字段 -->
    <update id="update" parameterType="com.engine.salary.report.entity.po.SalaryStatisticsReportPO">
        UPDATE hrsa_salary_stats_report
        <set>
            create_time=#{createTime},
            creator=#{creator},
            delete_type=#{deleteType},
            depart_setting=#{departSetting},
            dimension=#{dimension},
            employee_setting=#{employeeSetting},
            grade_setting=#{gradeSetting},
            hiredate_setting=#{hiredateSetting},
            income_category_setting=#{incomeCategorySetting},
            leavedate_setting=#{leavedateSetting},
            position_setting=#{positionSetting},
            remark=#{remark},
            report_name=#{reportName},
            time_type=#{timeType},
            salary_end_month=#{salaryEndMonth},
            salary_start_month=#{salaryStartMonth},
            second_dimension=#{secondDimension},
            sort_index=#{sortIndex},
            sort_type=#{sortType},
            status_setting=#{statusSetting},
            sub_company_setting=#{subCompanySetting},
            tax_agent_setting=#{taxAgentSetting},
            salary_sob_setting=#{salarySobSetting},
            tenant_key=#{tenantKey},
            update_time=#{updateTime},
        </set>
        WHERE id = #{id} AND delete_type = 0
    </update>


    <!-- 更新不为NULL的字段 -->
    <update id="updateIgnoreNull" parameterType="com.engine.salary.report.entity.po.SalaryStatisticsReportPO">
        UPDATE hrsa_salary_stats_report
        <set>
            <if test="createTime != null">
                create_time=#{createTime},
            </if>
            <if test="creator != null">
                creator=#{creator},
            </if>
            <if test="deleteType != null">
                delete_type=#{deleteType},
            </if>
            <if test="departSetting != null">
                depart_setting=#{departSetting},
            </if>
            <if test="dimension != null">
                dimension=#{dimension},
            </if>
            <if test="employeeSetting != null">
                employee_setting=#{employeeSetting},
            </if>
            <if test="gradeSetting != null">
                grade_setting=#{gradeSetting},
            </if>
            <if test="hiredateSetting != null">
                hiredate_setting=#{hiredateSetting},
            </if>
            <if test="incomeCategorySetting != null">
                income_category_setting=#{incomeCategorySetting},
            </if>
            <if test="leavedateSetting != null">
                leavedate_setting=#{leavedateSetting},
            </if>
            <if test="positionSetting != null">
                position_setting=#{positionSetting},
            </if>
            <if test="remark != null">
                remark=#{remark},
            </if>
            <if test="reportName != null">
                report_name=#{reportName},
            </if>
            <if test="timeType != null">
                time_type=#{timeType},
            </if>
            <if test="salaryEndMonth != null">
                salary_end_month=#{salaryEndMonth},
            </if>
            <if test="salaryStartMonth != null">
                salary_start_month=#{salaryStartMonth},
            </if>
            <if test="secondDimension != null">
                second_dimension=#{secondDimension},
            </if>
            <if test="sortIndex != null">
                sort_index=#{sortIndex},
            </if>
            <if test="sortType != null">
                sort_type=#{sortType},
            </if>
            <if test="statusSetting != null">
                status_setting=#{statusSetting},
            </if>
            <if test="subCompanySetting != null">
                sub_company_setting=#{subCompanySetting},
            </if>
            <if test="taxAgentSetting != null">
                tax_agent_setting=#{taxAgentSetting},
            </if>
            <if test="salarySobSetting != null">
                salary_sob_setting=#{salarySobSetting},
            </if>
            <if test="tenantKey != null">
                tenant_key=#{tenantKey},
            </if>
            <if test="updateTime != null">
                update_time=#{updateTime},
            </if>
        </set>
        WHERE id = #{id} AND delete_type = 0
    </update>


    <!-- 根据主键删除记录 -->
    <delete id="delete" parameterType="com.engine.salary.report.entity.po.SalaryStatisticsReportPO">
        UPDATE hrsa_salary_stats_report
        SET delete_type=1
        WHERE id = #{id}
          AND delete_type = 0
    </delete>

    <delete id="deleteByIds">
        UPDATE hrsa_salary_stats_report
        SET delete_type = 1
        WHERE delete_type = 0
        AND id IN
        <foreach collection="ids" open="(" item="id" separator="," close=")">
            #{id}
        </foreach>
    </delete>


</mapper>