<?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.sf.system.deployment.mapper.DeploymentModuleListMapper">

    <resultMap type="DeploymentModuleList" id="DeploymentModuleListResult">
        <result property="id" column="id"/>
        <result property="appId" column="app_id"/>
        <result property="appCode" column="app_code"/>
        <result property="uploadingType" column="uploading_type"/>
        <result property="moduleName" column="module_name"/>
        <result property="version" column="version"/>
        <result property="moduleUrl" column="module_url"/>
        <result property="moduleSize" column="module_size"/>
        <result property="sysType" column="sys_type"/>
        <result property="moduleType" column="module_type"/>
        <result property="uploadingStatus" column="uploading_status"/>
        <result property="uploadingLogId" column="uploading_log_id"/>
        <result property="orderNum" column="order_num"/>
        <result property="isDelete" column="is_delete"/>
        <result property="created" column="created"/>
        <result property="modified" column="modified"/>
        <result property="createTime" column="create_time"/>
        <result property="updateTime" column="update_time"/>
    </resultMap>

    <sql id="selectDeploymentModuleListVo">
        select id, app_id, app_code, uploading_type, module_name, version, module_url, module_size, sys_type, module_type, uploading_status, uploading_log_id, order_num, is_delete, created, modified, create_time, update_time from DEPLOYMENT_MODULE_LIST
    </sql>

    <select id="selectDeploymentModuleListList" parameterType="DeploymentModuleList"
            resultMap="DeploymentModuleListResult">
        <include refid="selectDeploymentModuleListVo"/>
        <where>
            <if test="appCode != null  and appCode != ''">and app_code = #{appCode}</if>
            <if test="sysType != null  and sysType != ''">and sys_type= #{sysType}</if>
            <if test="moduleName != null  and moduleName != ''">and module_name like concat('%', #{moduleName}, '%')</if>
            <if test="version != null  and version != ''">and version = #{version}</if>
            <if test="uploadingStatus != null  and uploadingStatus != ''">and uploading_status = #{uploadingStatus}</if>
            <if test="createTime != null ">and create_time = #{createTime}</if>
        </where>
    </select>

    <select id="selectDeploymentModuleListById" parameterType="Long" resultMap="DeploymentModuleListResult">
        <include refid="selectDeploymentModuleListVo"/>
        where id = #{id}
    </select>

    <insert id="insertDeploymentModuleList" parameterType="DeploymentModuleList" useGeneratedKeys="true"
            keyProperty="id">
        insert into DEPLOYMENT_MODULE_LIST
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="appId != null">app_id,</if>
            <if test="appCode != null">app_code,</if>
            <if test="uploadingType != null">uploading_type,</if>
            <if test="moduleName != null and moduleName != ''">module_name,</if>
            <if test="version != null and version != ''">version,</if>
            <if test="moduleUrl != null">module_url,</if>
            <if test="moduleSize != null">module_size,</if>
            <if test="sysType != null and sysType != ''">sys_type,</if>
            <if test="moduleType != null and moduleType != ''">module_type,</if>
            <if test="uploadingStatus != null and uploadingStatus != ''">uploading_status,</if>
            <if test="uploadingLogId != null">uploading_log_id,</if>
            <if test="orderNum != null">order_num,</if>
            <if test="isDelete != null">is_delete,</if>
            <if test="created != null">created,</if>
            <if test="modified != null">modified,</if>
            <if test="createTime != null">create_time,</if>
            <if test="updateTime != null">update_time,</if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="appId != null">#{appId},</if>
            <if test="appCode != null">#{appCode},</if>
            <if test="uploadingType != null">#{uploadingType},</if>
            <if test="moduleName != null and moduleName != ''">#{moduleName},</if>
            <if test="version != null and version != ''">#{version},</if>
            <if test="moduleUrl != null">#{moduleUrl},</if>
            <if test="moduleSize != null">#{moduleSize},</if>
            <if test="sysType != null and sysType != ''">#{sysType},</if>
            <if test="moduleType != null and moduleType != ''">#{moduleType},</if>
            <if test="uploadingStatus != null and uploadingStatus != ''">#{uploadingStatus},</if>
            <if test="uploadingLogId != null">#{uploadingLogId},</if>
            <if test="orderNum != null">#{orderNum},</if>
            <if test="isDelete != null">#{isDelete},</if>
            <if test="created != null">#{created},</if>
            <if test="modified != null">#{modified},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="updateTime != null">#{updateTime},</if>
        </trim>
    </insert>

    <update id="updateDeploymentModuleList" parameterType="DeploymentModuleList">
        update DEPLOYMENT_MODULE_LIST
        <trim prefix="SET" suffixOverrides=",">
            <if test="appId != null">app_id = #{appId},</if>
            <if test="appCode != null">app_code = #{appCode},</if>
            <if test="uploadingType != null">uploading_type = #{uploadingType},</if>
            <if test="moduleName != null and moduleName != ''">module_name = #{moduleName},</if>
            <if test="version != null and version != ''">version = #{version},</if>
            <if test="moduleUrl != null">module_url = #{moduleUrl},</if>
            <if test="moduleSize != null">module_size = #{moduleSize},</if>
            <if test="sysType != null and sysType != ''">sys_type = #{sysType},</if>
            <if test="moduleType != null and moduleType != ''">module_type = #{moduleType},</if>
            <if test="uploadingStatus != null and uploadingStatus != ''">uploading_status = #{uploadingStatus},</if>
            <if test="uploadingLogId != null">uploading_log_id = #{uploadingLogId},</if>
            <if test="orderNum != null">order_num = #{orderNum},</if>
            <if test="isDelete != null">is_delete = #{isDelete},</if>
            <if test="created != null">created = #{created},</if>
            <if test="modified != null">modified = #{modified},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
            <if test="updateTime != null">update_time = #{updateTime},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteDeploymentModuleListById" parameterType="Long">
        delete
        from DEPLOYMENT_MODULE_LIST
        where id = #{id}
    </delete>

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