<?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.zehong.system.mapper.TEnterpriseSystemMapper">

    <resultMap type="TEnterpriseSystem" id="TEnterpriseSystemResult">
        <result property="systemId"    column="system_id"    />
        <result property="systemTitle"    column="system_title"    />
        <result property="systemType"    column="system_type"    />
        <result property="hierarchy"    column="hierarchy"    />
        <result property="referenceNum"    column="reference_num"    />
        <result property="issueDept"    column="issue_dept"    />
        <result property="availability"    column="availability"    />
        <result property="contentType"    column="content_type"    />
        <result property="content"    column="content"    />
        <result property="fileName"    column="file_name"    />
        <result property="fileUrl"    column="file_url"    />
        <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="status"    column="status"    />
        <result property="isDel"    column="is_del"    />
        <result property="remark"    column="remark"    />
    </resultMap>

    <sql id="selectTEnterpriseSystemVo">
        select system_id, system_title, system_type, hierarchy, reference_num, issue_dept, availability, content_type, content, file_name, file_url, create_by, create_time, update_by, update_time, status, is_del, remark from t_enterprise_system
    </sql>

    <select id="selectTEnterpriseSystemList" parameterType="TEnterpriseSystem" resultMap="TEnterpriseSystemResult">
        <include refid="selectTEnterpriseSystemVo"/>
        <where>
            <if test="systemTitle != null  and systemTitle != ''"> and system_title = #{systemTitle}</if>
            <if test="systemType != null  and systemType != ''"> and system_type = #{systemType}</if>
            <if test="hierarchy != null  and hierarchy != ''"> and hierarchy = #{hierarchy}</if>
            <if test="referenceNum != null  and referenceNum != ''"> and reference_num = #{referenceNum}</if>
            <if test="issueDept != null  and issueDept != ''"> and issue_dept = #{issueDept}</if>
            <if test="availability != null  and availability != ''"> and availability = #{availability}</if>
            <if test="contentType != null  and contentType != ''"> and content_type = #{contentType}</if>
            <if test="content != null  and content != ''"> and content = #{content}</if>
            <if test="fileName != null  and fileName != ''"> and file_name like concat('%', #{fileName}, '%')</if>
            <if test="fileUrl != null  and fileUrl != ''"> and file_url = #{fileUrl}</if>
            <if test="status != null  and status != ''"> and status = #{status}</if>
            <if test="isDel != null  and isDel != ''"> and is_del = #{isDel}</if>
        </where>
    </select>

    <select id="selectTEnterpriseSystemById" parameterType="Long" resultMap="TEnterpriseSystemResult">
        <include refid="selectTEnterpriseSystemVo"/>
        where system_id = #{systemId}
    </select>

    <insert id="insertTEnterpriseSystem" parameterType="TEnterpriseSystem" useGeneratedKeys="true" keyProperty="systemId">
        insert into t_enterprise_system
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="systemTitle != null">system_title,</if>
            <if test="systemType != null">system_type,</if>
            <if test="hierarchy != null">hierarchy,</if>
            <if test="referenceNum != null">reference_num,</if>
            <if test="issueDept != null">issue_dept,</if>
            <if test="availability != null">availability,</if>
            <if test="contentType != null">content_type,</if>
            <if test="content != null">content,</if>
            <if test="fileName != null">file_name,</if>
            <if test="fileUrl != null">file_url,</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="status != null">status,</if>
            <if test="isDel != null">is_del,</if>
            <if test="remark != null">remark,</if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="systemTitle != null">#{systemTitle},</if>
            <if test="systemType != null">#{systemType},</if>
            <if test="hierarchy != null">#{hierarchy},</if>
            <if test="referenceNum != null">#{referenceNum},</if>
            <if test="issueDept != null">#{issueDept},</if>
            <if test="availability != null">#{availability},</if>
            <if test="contentType != null">#{contentType},</if>
            <if test="content != null">#{content},</if>
            <if test="fileName != null">#{fileName},</if>
            <if test="fileUrl != null">#{fileUrl},</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="status != null">#{status},</if>
            <if test="isDel != null">#{isDel},</if>
            <if test="remark != null">#{remark},</if>
        </trim>
    </insert>

    <update id="updateTEnterpriseSystem" parameterType="TEnterpriseSystem">
        update t_enterprise_system
        <trim prefix="SET" suffixOverrides=",">
            <if test="systemTitle != null">system_title = #{systemTitle},</if>
            <if test="systemType != null">system_type = #{systemType},</if>
            <if test="hierarchy != null">hierarchy = #{hierarchy},</if>
            <if test="referenceNum != null">reference_num = #{referenceNum},</if>
            <if test="issueDept != null">issue_dept = #{issueDept},</if>
            <if test="availability != null">availability = #{availability},</if>
            <if test="contentType != null">content_type = #{contentType},</if>
            <if test="content != null">content = #{content},</if>
            <if test="fileName != null">file_name = #{fileName},</if>
            <if test="fileUrl != null">file_url = #{fileUrl},</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="status != null">status = #{status},</if>
            <if test="isDel != null">is_del = #{isDel},</if>
            <if test="remark != null">remark = #{remark},</if>
        </trim>
        where system_id = #{systemId}
    </update>

    <delete id="deleteTEnterpriseSystemById" parameterType="Long">
        delete from t_enterprise_system where system_id = #{systemId}
    </delete>

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