<?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.AppDownloadMapper">

    <resultMap type="AppDownload" id="AppDownloadResult">
        <result property="id"    column="id"    />
        <result property="androidUrl"    column="android_url"    />
        <result property="iosUrl"    column="ios_url"    />
    </resultMap>

    <sql id="selectAppDownloadVo">
        select id, android_url, ios_url from app_download
    </sql>

    <select id="selectAppDownloadList" parameterType="AppDownload" resultMap="AppDownloadResult">
        <include refid="selectAppDownloadVo"/>
        <where>
            <if test="androidUrl != null  and androidUrl != ''"> and android_url = #{androidUrl}</if>
            <if test="iosUrl != null  and iosUrl != ''"> and ios_url = #{iosUrl}</if>
        </where>
    </select>

    <select id="selectAppDownloadById" parameterType="Long" resultMap="AppDownloadResult">
        <include refid="selectAppDownloadVo"/>
        where id = #{id}
    </select>

    <insert id="insertAppDownload" parameterType="AppDownload" useGeneratedKeys="true" keyProperty="id">
        insert into app_download
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="androidUrl != null">android_url,</if>
            <if test="iosUrl != null">ios_url,</if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="androidUrl != null">#{androidUrl},</if>
            <if test="iosUrl != null">#{iosUrl},</if>
        </trim>
    </insert>

    <update id="updateAppDownload" parameterType="AppDownload">
        update app_download
        <trim prefix="SET" suffixOverrides=",">
            <if test="androidUrl != null">android_url = #{androidUrl},</if>
            <if test="iosUrl != null">ios_url = #{iosUrl},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteAppDownloadById" parameterType="Long">
        delete from app_download where id = #{id}
    </delete>

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