<?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.SalaryStatisticsEChartsSettingMapper">
    <resultMap id="BaseResultMap" type="com.engine.salary.report.entity.po.SalaryStatisticsEChartsSettingPO">
        <result column="charts_type" property="chartsType"/>
        <result column="create_time" property="createTime"/>
        <result column="creator" property="creator"/>
        <result column="delete_type" property="deleteType"/>
        <result column="dimension_range" property="dimensionRange"/>
        <result column="id" property="id"/>
        <result column="item_col_sort_value" property="itemColSortValue"/>
        <result column="item_col_value" property="itemColValue"/>
        <result column="item_sort_value" property="itemSortValue"/>
        <result column="item_values" property="itemValues"/>
        <result column="report_id" property="reportId"/>
        <result column="sort_num" property="sortNum"/>
        <result column="sort_type" property="sortType"/>
        <result column="tenant_key" property="tenantKey"/>
        <result column="update_time" property="updateTime"/>
    </resultMap>

    <!-- 表字段 -->
    <sql id="baseColumns">
        t
        .
        charts_type
        , t.create_time
        , t.creator
        , t.delete_type
        , t.dimension_range
        , t.id
        , t.item_col_sort_value
        , t.item_col_value
        , t.item_sort_value
        , t.item_values
        , t.report_id
        , t.sort_num
        , t.sort_type
        , t.tenant_key
        , t.update_time
    </sql>

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

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

    <!-- 条件查询 -->
    <select id="listSome" resultMap="BaseResultMap"
            parameterType="com.engine.salary.report.entity.po.SalaryStatisticsEChartsSettingPO">
        SELECT
        <include refid="baseColumns"/>
        FROM hrsa_salary_echarts_setting t
        WHERE delete_type = 0
        <if test="chartsType != null">
            AND charts_type = #{chartsType}
        </if>
        <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="dimensionRange != null">
            AND dimension_range = #{dimensionRange}
        </if>
        <if test="id != null">
            AND id = #{id}
        </if>
        <if test="itemColSortValue != null">
            AND item_col_sort_value = #{itemColSortValue}
        </if>
        <if test="itemColValue != null">
            AND item_col_value = #{itemColValue}
        </if>
        <if test="itemSortValue != null">
            AND item_sort_value = #{itemSortValue}
        </if>
        <if test="itemValues != null">
            AND item_values = #{itemValues}
        </if>
        <if test="reportId != null">
            AND report_id = #{reportId}
        </if>
        <if test="sortNum != null">
            AND sort_num = #{sortNum}
        </if>
        <if test="sortType != null">
            AND sort_type = #{sortType}
        </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.SalaryStatisticsEChartsSettingPO">
        INSERT INTO hrsa_salary_echarts_setting
        <trim prefix="(" suffix=")" suffixOverrides=",">

            <if test="chartsType != null">
                charts_type,
            </if>
            <if test="createTime != null">
                create_time,
            </if>
            <if test="creator != null">
                creator,
            </if>
            <if test="deleteType != null">
                delete_type,
            </if>
            <if test="dimensionRange != null">
                dimension_range,
            </if>
            <if test="id != null">
                id,
            </if>
            <if test="itemColSortValue != null">
                item_col_sort_value,
            </if>
            <if test="itemColValue != null">
                item_col_value,
            </if>
            <if test="itemSortValue != null">
                item_sort_value,
            </if>
            <if test="itemValues != null">
                item_values,
            </if>
            <if test="reportId != null">
                report_id,
            </if>
            <if test="sortNum != null">
                sort_num,
            </if>
            <if test="sortType != null">
                sort_type,
            </if>
            <if test="tenantKey != null">
                tenant_key,
            </if>
            <if test="updateTime != null">
                update_time,
            </if>
        </trim>
        <trim prefix="VALUES (" suffix=")" suffixOverrides=",">
            <if test="chartsType != null">
                #{chartsType},
            </if>
            <if test="createTime != null">
                #{createTime},
            </if>
            <if test="creator != null">
                #{creator},
            </if>
            <if test="deleteType != null">
                #{deleteType},
            </if>
            <if test="dimensionRange != null">
                #{dimensionRange},
            </if>
            <if test="id != null">
                #{id},
            </if>
            <if test="itemColSortValue != null">
                #{itemColSortValue},
            </if>
            <if test="itemColValue != null">
                #{itemColValue},
            </if>
            <if test="itemSortValue != null">
                #{itemSortValue},
            </if>
            <if test="itemValues != null">
                #{itemValues},
            </if>
            <if test="reportId != null">
                #{reportId},
            </if>
            <if test="sortNum != null">
                #{sortNum},
            </if>
            <if test="sortType != null">
                #{sortType},
            </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.SalaryStatisticsEChartsSettingPO">
        UPDATE hrsa_salary_echarts_setting
        <set>
            charts_type=#{chartsType},
            create_time=#{createTime},
            creator=#{creator},
            delete_type=#{deleteType},
            dimension_range=#{dimensionRange},
            item_col_sort_value=#{itemColSortValue},
            item_col_value=#{itemColValue},
            item_sort_value=#{itemSortValue},
            item_values=#{itemValues},
            report_id=#{reportId},
            sort_num=#{sortNum},
            sort_type=#{sortType},
            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.SalaryStatisticsEChartsSettingPO">
        UPDATE hrsa_salary_echarts_setting
        <set>
            <if test="chartsType != null">
                charts_type=#{chartsType},
            </if>
            <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="dimensionRange != null">
                dimension_range=#{dimensionRange},
            </if>
            <if test="itemColSortValue != null">
                item_col_sort_value=#{itemColSortValue},
            </if>
            <if test="itemColValue != null">
                item_col_value=#{itemColValue},
            </if>
            <if test="itemSortValue != null">
                item_sort_value=#{itemSortValue},
            </if>
            <if test="itemValues != null">
                item_values=#{itemValues},
            </if>
            <if test="reportId != null">
                report_id=#{reportId},
            </if>
            <if test="sortNum != null">
                sort_num=#{sortNum},
            </if>
            <if test="sortType != null">
                sort_type=#{sortType},
            </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">
        UPDATE hrsa_salary_echarts_setting
        SET delete_type=1
        WHERE id = #{id}
          AND delete_type = 0
    </delete>

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

    <delete id="deleteByReportId">
        UPDATE hrsa_salary_echarts_setting
        SET delete_type=1
        WHERE report_id = #{reportId}
          AND delete_type = 0
    </delete>


</mapper>