<?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.sy.mapper.SyVocationalPostMapper">
    
    <resultMap type="SyVocationalPost" id="SyVocationalPostResult">
        <result property="id"    column="id"    />
        <result property="code"    column="code"    />
        <result property="name"    column="name"    />
        <result property="salaryMax"    column="salary_max"    />
        <result property="salaryMin"    column="salary_min"    />
        <result property="salaryUnit"    column="salary_unit"    />
        <result property="createTime"    column="create_time"    />
    </resultMap>

    <sql id="selectSyVocationalPostVo">
        select id, code, name, salary_max, salary_min, salary_unit, create_time from sy_vocational_post
    </sql>

    <select id="selectSyVocationalPostList" parameterType="SyVocationalPost" resultMap="SyVocationalPostResult">
        <include refid="selectSyVocationalPostVo"/>
        <where>  
            <if test="code != null  and code != ''"> and code = #{, '%')}</if>
            <if test="name != null  and name != ''"> and name like concat('%', #{name}, '%')</if>
            <if test="salaryMax != null  and salaryMax != ''"> and salary_max = #{salaryMax}</if>
            <if test="salaryMin != null  and salaryMin != ''"> and salary_min = #{salaryMin}</if>
            <if test="salaryUnit != null  and salaryUnit != ''"> and salary_unit = #{salaryUnit}</if>
        </where>
    </select>
    
    <select id="selectSyVocationalPostById" parameterType="Long" resultMap="SyVocationalPostResult">
        <include refid="selectSyVocationalPostVo"/>
        where id = #{id}
    </select>

    <select id="selectSyVocationalPostByVocationalCode" parameterType="String" resultMap="SyVocationalPostResult">
        <include refid="selectSyVocationalPostVo"/>
        where code = #{code}
    </select>
        
    <insert id="insertSyVocationalPost" parameterType="SyVocationalPost" useGeneratedKeys="true" keyProperty="id">
        insert into sy_vocational_post
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="name != null">name,</if>
            <if test="salaryMax != null">salary_max,</if>
            <if test="salaryMin != null">salary_min,</if>
            <if test="salaryUnit != null">salary_unit,</if>
            <if test="createTime != null">create_time,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="name != null">#{name},</if>
            <if test="salaryMax != null">#{salaryMax},</if>
            <if test="salaryMin != null">#{salaryMin},</if>
            <if test="salaryUnit != null">#{salaryUnit},</if>
            <if test="createTime != null">#{createTime},</if>
         </trim>
    </insert>

    <update id="updateSyVocationalPost" parameterType="SyVocationalPost">
        update sy_vocational_post
        <trim prefix="SET" suffixOverrides=",">
            <if test="name != null">name = #{name},</if>
            <if test="salaryMax != null">salary_max = #{salaryMax},</if>
            <if test="salaryMin != null">salary_min = #{salaryMin},</if>
            <if test="salaryUnit != null">salary_unit = #{salaryUnit},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteSyVocationalPostById" parameterType="Long">
        delete from sy_vocational_post where id = #{id}
    </delete>

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