<?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.ghy.worker.mapper.SpecialSkillMapper">

    <resultMap id="SpecialSkillResult"          type="com.ghy.worker.domain.SpecialSkill">
        <result property="specialSkillId"       column="special_skill_id"/>
        <result property="specialSkillName"     column="special_skill_name"/>
        <result property="goodsCategoryId"      column="goods_category_id"/>
        <result property="dangerous"            column="dangerous"/>
        <result property="createBy"             column="create_by"/>
        <result property="createTime"           column="create_time"/>
        <result property="updateBy"             column="update_by"/>
        <result property="updateTime"           column="update_time"/>
        <result property="remark"               column="remark"/>
    </resultMap>

    <insert id="insert" parameterType="com.ghy.worker.domain.SpecialSkill" useGeneratedKeys="true" keyProperty="specialSkillId">
        INSERT INTO special_skill(
        <if test="specialSkillName != null and specialSkillName !=''">special_skill_name,</if>
        <if test="goodsCategoryId != null and goodsCategoryId > 0">goods_category_id,</if>
        <if test="dangerous != null">dangerous,</if>
        <if test="createBy != null and createBy != ''">create_by,</if>
        <if test="remark != null and remark != ''">remark,</if>
        create_time
        )VALUES(
        <if test="specialSkillName != null and specialSkillName !=''">#{specialSkillName},</if>
        <if test="goodsCategoryId != null and goodsCategoryId > 0">#{goodsCategoryId},</if>
        <if test="dangerous != null">#{dangerous},</if>
        <if test="createBy != null and createBy != ''">#{createBy},</if>
        <if test="remark != null and remark != ''">#{remark},</if>
        sysdate()
        )
    </insert>

    <update id="update">
        UPDATE special_skill
        <set>
            <if test="specialSkillName != null and specialSkillName !=''">special_skill_name = #{specialSkillName},</if>
            <if test="goodsCategoryId != null and goodsCategoryId > 0">goods_category_id = #{goodsCategoryId},</if>
            <if test="dangerous != null">dangerous = #{dangerous},</if>
            <if test="remark != null and remark != ''">remark = #{remark},</if>
            create_time = sysdate()
        </set>
    </update>

    <delete id="delete" parameterType="Long">
        DELETE FROM special_skill WHERE special_skill_id IN
        <foreach collection="array" item="id" open="(" separator="," close=")">
            #{id}
        </foreach>
    </delete>

    <select id="list" parameterType="com.ghy.worker.domain.SpecialSkill" resultMap="SpecialSkillResult">
        SELECT * FROM special_skill
        <where>
            <if test="specialSkillId != null and specialSkillId > 0">special_skill_id = #{specialSkillId}</if>
            <if test="specialSkillName != null and specialSkillName !=''">special_skill_name = #{specialSkillName}</if>
            <if test="goodsCategoryId != null and goodsCategoryId > 0">goods_category_id = #{goodsCategoryId}</if>
        </where>
    </select>

</mapper>
