<?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.system.mapper.UpdateAppMapper">
    
    <resultMap type="UpdateApp" id="UpdateAppResult">
        <result property="id"    column="id"    />
        <result property="model"    column="model"    />
        <result property="name"    column="name"    />
        <result property="code"    column="code"    />
        <result property="description"    column="description"    />
        <result property="path"    column="path"    />
        <result property="isDel"    column="is_del"    />
        <result property="createTime"    column="create_time"    />
    </resultMap>

    <sql id="selectUpdateAppVo">
        select id, model, name, code, description, path, is_del, create_time from update_app
    </sql>

    <select id="selectUpdateAppList" parameterType="UpdateApp" resultMap="UpdateAppResult">
        <include refid="selectUpdateAppVo"/>
        <where>  
            <if test="model != null  and model != ''"> and model = #{model}</if>
            <if test="name != null  and name != ''"> and name like concat('%', #{name}, '%')</if>
            <if test="code != null  and code != ''"> and code = #{code}</if>
            <if test="description != null  and description != ''"> and description = #{description}</if>
            <if test="path != null  and path != ''"> and path = #{path}</if>
            <if test="isDel != null  and isDel != ''"> and is_del = #{isDel}</if>
        </where>
    </select>
    
    <select id="selectUpdateAppById" parameterType="Long" resultMap="UpdateAppResult">
        <include refid="selectUpdateAppVo"/>
        where id = #{id}
    </select>
        
    <insert id="insertUpdateApp" parameterType="UpdateApp">
        insert into update_app
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">id,</if>
            <if test="model != null">model,</if>
            <if test="name != null">name,</if>
            <if test="code != null">code,</if>
            <if test="description != null">description,</if>
            <if test="path != null">path,</if>
            <if test="isDel != null">is_del,</if>
            <if test="createTime != null">create_time,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="id != null">#{id},</if>
            <if test="model != null">#{model},</if>
            <if test="name != null">#{name},</if>
            <if test="code != null">#{code},</if>
            <if test="description != null">#{description},</if>
            <if test="path != null">#{path},</if>
            <if test="isDel != null">#{isDel},</if>
            <if test="createTime != null">#{createTime},</if>
         </trim>
    </insert>

    <update id="updateUpdateApp" parameterType="UpdateApp">
        update update_app
        <trim prefix="SET" suffixOverrides=",">
            <if test="model != null">model = #{model},</if>
            <if test="name != null">name = #{name},</if>
            <if test="code != null">code = #{code},</if>
            <if test="description != null">description = #{description},</if>
            <if test="path != null">path = #{path},</if>
            <if test="isDel != null">is_del = #{isDel},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteUpdateAppById" parameterType="Long">
        delete from update_app where id = #{id}
    </delete>

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

    <select id="getInfo" parameterType="UpdateApp" resultMap="UpdateAppResult">
        <include refid="selectUpdateAppVo"/>
        <where>
            <if test="model != null  and model != ''"> and model = #{model}</if>
            <if test="name != null  and name != ''"> and name like concat('%', #{name}, '%')</if>
            <if test="code != null  and code != ''"> and code = #{code}</if>
            <if test="description != null  and description != ''"> and description = #{description}</if>
            <if test="path != null  and path != ''"> and path = #{path}</if>
            <if test="isDel != null  and isDel != ''"> and is_del = #{isDel}</if>
        </where>
    </select>
    <update id="updateUpdateAppAll" parameterType="UpdateApp">
        update update_app set is_del = #{isDel}
        where model = #{model}
    </update>
</mapper>