<?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.model.mapper.AppInviteMapper">
    
    <resultMap type="AppInvite" id="AppInviteResult">
        <result property="id"    column="id"    />
        <result property="uid"    column="uid"    />
        <result property="inviteImage"    column="invite_image"    />
        <result property="remark"    column="remark"    />
        <result property="createTime"    column="create_time"    />
        <result property="createBy"    column="create_by"    />
        <result property="updateTime"    column="update_time"    />
        <result property="updateBy"    column="update_by"    />
        <result property="delFlag"    column="del_flag"    />
    </resultMap>

    <sql id="selectAppInviteVo">
        select id, uid, invite_image, remark, create_time, create_by, update_time, update_by, del_flag from app_invite
    </sql>

    <select id="selectAppInviteList" parameterType="AppInvite" resultMap="AppInviteResult">
        <include refid="selectAppInviteVo"/>
        <where>  
            <if test="uid != null "> and uid = #{uid}</if>
            <if test="inviteImage != null  and inviteImage != ''"> and invite_image = #{inviteImage}</if>
        </where>
    </select>
    
    <select id="selectAppInviteById" parameterType="Long" resultMap="AppInviteResult">
        <include refid="selectAppInviteVo"/>
        where id = #{id}
    </select>

    <insert id="insertAppInvite" parameterType="AppInvite">
        insert into app_invite
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">id,</if>
            <if test="uid != null">uid,</if>
            <if test="inviteImage != null">invite_image,</if>
            <if test="remark != null">remark,</if>
            <if test="createTime != null">create_time,</if>
            <if test="createBy != null">create_by,</if>
            <if test="updateTime != null">update_time,</if>
            <if test="updateBy != null">update_by,</if>
            <if test="delFlag != null">del_flag,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="id != null">#{id},</if>
            <if test="uid != null">#{uid},</if>
            <if test="inviteImage != null">#{inviteImage},</if>
            <if test="remark != null">#{remark},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="createBy != null">#{createBy},</if>
            <if test="updateTime != null">#{updateTime},</if>
            <if test="updateBy != null">#{updateBy},</if>
            <if test="delFlag != null">#{delFlag},</if>
         </trim>
    </insert>

    <update id="updateAppInvite" parameterType="AppInvite">
        update app_invite
        <trim prefix="SET" suffixOverrides=",">
            <if test="uid != null">uid = #{uid},</if>
            <if test="inviteImage != null">invite_image = #{inviteImage},</if>
            <if test="remark != null">remark = #{remark},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
            <if test="createBy != null">create_by = #{createBy},</if>
            <if test="updateTime != null">update_time = #{updateTime},</if>
            <if test="updateBy != null">update_by = #{updateBy},</if>
            <if test="delFlag != null">del_flag = #{delFlag},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteAppInviteById" parameterType="Long">
        delete from app_invite where id = #{id}
    </delete>

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