<?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.oa.mapper.CmcPostSalaryMapper">

    <resultMap type="CmcPostSalary" id="CmcPostSalaryResult">
        <result property="salaryId"    column="salary_id"    />
        <result property="postLevel"    column="post_level"    />
        <result property="salaryLevel"    column="salary_level"    />
        <result property="salary"    column="salary"    />
    </resultMap>

    <sql id="selectCmcPostSalaryVo">
        select salary_id, post_level, salary_level, salary from cmc_post_salary
    </sql>

    <select id="selectCmcPostSalaryList" parameterType="CmcPostSalary" resultMap="CmcPostSalaryResult">
        <include refid="selectCmcPostSalaryVo"/>
        <where>
            <if test="postLevel != null  and postLevel != ''"> and post_level = #{postLevel}</if>
            <if test="salaryLevel != null  and salaryLevel != ''"> and salary_level = #{salaryLevel}</if>
            <if test="salary != null "> and salary = #{salary}</if>
        </where>
    </select>

    <select id="selectCmcPostSalaryBySalaryId" parameterType="Integer" resultMap="CmcPostSalaryResult">
        <include refid="selectCmcPostSalaryVo"/>
        where salary_id = #{salaryId}
    </select>

    <insert id="insertCmcPostSalary" parameterType="CmcPostSalary" useGeneratedKeys="true" keyProperty="salaryId">
        insert into cmc_post_salary
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="postLevel != null">post_level,</if>
            <if test="salaryLevel != null">salary_level,</if>
            <if test="salary != null">salary,</if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="postLevel != null">#{postLevel},</if>
            <if test="salaryLevel != null">#{salaryLevel},</if>
            <if test="salary != null">#{salary},</if>
        </trim>
    </insert>

    <update id="updateCmcPostSalary" parameterType="CmcPostSalary">
        update cmc_post_salary
        <trim prefix="SET" suffixOverrides=",">
            <if test="postLevel != null">post_level = #{postLevel},</if>
            <if test="salaryLevel != null">salary_level = #{salaryLevel},</if>
            <if test="salary != null">salary = #{salary},</if>
        </trim>
        where salary_id = #{salaryId}
    </update>

    <delete id="deleteCmcPostSalaryBySalaryId" parameterType="Integer">
        delete from cmc_post_salary where salary_id = #{salaryId}
    </delete>

    <delete id="deleteCmcPostSalaryBySalaryIds" parameterType="String">
        delete from cmc_post_salary where salary_id in
        <foreach item="salaryId" collection="array" open="(" separator="," close=")">
            #{salaryId}
        </foreach>
    </delete>
</mapper>