<?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.goomood.phm.mapper.TechDataMapper">
    
    <resultMap type="TechData" id="TechDataResult">
        <result property="id"    column="id"    />
        <result property="typeId"    column="type_id"    />
        <result property="dataTitle"    column="data_title"    />
        <result property="dataAuthor"    column="data_author"    />
        <result property="dataKeyword"    column="data_keyword"    />
        <result property="dataModel"    column="data_model"    />
        <result property="dataSys"    column="data_sys"    />
        <result property="dataSpeciality"    column="data_speciality"    />
        <result property="filePath"    column="file_path"    />
        <result property="dataNum"    column="data_num"    />
        <result property="dataDescription"    column="data_description"    />
        <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>

    <sql id="selectTechDataVo">
        select id, type_id, data_title, data_author, data_keyword, data_model, data_sys, data_speciality, file_path, data_num, data_description, create_by, create_time, update_by, update_time, remark from tech_data
    </sql>

    <select id="selectTechDataList" parameterType="TechData" resultMap="TechDataResult">
        <include refid="selectTechDataVo"/>
        <where>
            <if test="typeId != null"> and type_id = #{typeId} </if>
            <if test="dataTitle != null  and dataTitle != ''"> and data_title = #{dataTitle}</if>
            <if test="dataAuthor != null  and dataAuthor != ''"> and data_author = #{dataAuthor}</if>
            <if test="dataKeyword != null  and dataKeyword != ''"> and data_keyword = #{dataKeyword}</if>
            <if test="dataModel != null  and dataModel != ''"> and data_model = #{dataModel}</if>
            <if test="dataSys != null  and dataSys != ''"> and data_sys = #{dataSys}</if>
            <if test="dataSpeciality != null "> and data_speciality = #{dataSpeciality}</if>
            <if test="dataNum != null "> and data_num = #{dataNum}</if>
        </where>
    </select>
    
    <select id="selectTechDataById" parameterType="Long" resultMap="TechDataResult">
        <include refid="selectTechDataVo"/>
        where id = #{id}
    </select>

    <insert id="insertTechData" parameterType="TechData" useGeneratedKeys="true" keyProperty="id">
        insert into tech_data
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="typeId != null">type_id,</if>
            <if test="dataTitle != null and dataTitle != ''">data_title,</if>
            <if test="dataAuthor != null">data_author,</if>
            <if test="dataKeyword != null">data_keyword,</if>
            <if test="dataModel != null">data_model,</if>
            <if test="dataSys != null">data_sys,</if>
            <if test="dataSpeciality != null">data_speciality,</if>
            <if test="filePath != null">file_path,</if>
            <if test="dataNum != null">data_num,</if>
            <if test="dataDescription != null">data_description,</if>
            <if test="createBy != null">create_by,</if>
            <if test="createTime != null">create_time,</if>
            <if test="updateBy != null">update_by,</if>
            <if test="updateTime != null">update_time,</if>
            <if test="remark != null">remark,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="typeId != null">#{typeId},</if>
            <if test="dataTitle != null and dataTitle != ''">#{dataTitle},</if>
            <if test="dataAuthor != null">#{dataAuthor},</if>
            <if test="dataKeyword != null">#{dataKeyword},</if>
            <if test="dataModel != null">#{dataModel},</if>
            <if test="dataSys != null">#{dataSys},</if>
            <if test="dataSpeciality != null">#{dataSpeciality},</if>
            <if test="filePath != null">#{filePath},</if>
            <if test="dataNum != null">#{dataNum},</if>
            <if test="dataDescription != null">#{dataDescription},</if>
            <if test="createBy != null">#{createBy},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="updateBy != null">#{updateBy},</if>
            <if test="updateTime != null">#{updateTime},</if>
            <if test="remark != null">#{remark},</if>
         </trim>
    </insert>

    <update id="updateTechData" parameterType="TechData">
        update tech_data
        <trim prefix="SET" suffixOverrides=",">
            <if test="typeId != null">type_id = #{typeId},</if>
            <if test="dataTitle != null and dataTitle != ''">data_title = #{dataTitle},</if>
            <if test="dataAuthor != null">data_author = #{dataAuthor},</if>
            <if test="dataKeyword != null">data_keyword = #{dataKeyword},</if>
            <if test="dataModel != null">data_model = #{dataModel},</if>
            <if test="dataSys != null">data_sys = #{dataSys},</if>
            <if test="dataSpeciality != null">data_speciality = #{dataSpeciality},</if>
            <if test="filePath != null">file_path = #{filePath},</if>
            <if test="dataNum != null">data_num = #{dataNum},</if>
            <if test="dataDescription != null">data_description = #{dataDescription},</if>
            <if test="createBy != null">create_by = #{createBy},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
            <if test="updateBy != null">update_by = #{updateBy},</if>
            <if test="updateTime != null">update_time = #{updateTime},</if>
            <if test="remark != null">remark = #{remark},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteTechDataById" parameterType="Long">
        delete from tech_data where id = #{id}
    </delete>

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