<?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.frequency.appversion.mapper.AppVersionMapper">

    <resultMap type="com.ruoyi.frequency.appversion.entity.AppVersion" id="AppVersionResult">
        <result property="id"    column="id"    />
        <result property="delFlag"    column="del_flag"    />
        <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="version"    column="version"    />
        <result property="isForce"    column="is_force"    />
        <result property="url"    column="url"    />
        <result property="sort"    column="sort"    />
        <result property="appType"    column="app_type"    />
        <result property="content"    column="content"    />
        <result property="title"    column="title"    />
        </resultMap>

    
    
    <sql id="selectAppVersionVo">
        select
            t.id ,
            t.del_flag ,
            t.create_by ,
            t.create_time ,
            t.update_by ,
            t.update_time ,
            t.version ,
            t.is_force ,
            t.url ,
            t.sort ,
            t.app_type ,
            t.content ,
            t.title 
        from t_app_version AS t
                
    </sql>

    <select id="selectAppVersionList" parameterType="com.ruoyi.frequency.appversion.entity.AppVersion" resultMap="AppVersionResult">
        <include refid="selectAppVersionVo"/>
        <where> AND t.del_flag != 2
            <if test="version != null  and version != ''"> and t.version = #{version}</if>
            <if test="isForce != null "> and t.is_force = #{isForce}</if>
            <if test="url != null  and url != ''"> and t.url = #{url}</if>
            <if test="sort != null  and sort != ''"> and t.sort = #{sort}</if>
            <if test="appType != null "> and t.app_type = #{appType}</if>
            <if test="content != null  and content != ''"> and t.content = #{content}</if>
            <if test="title != null  and title != ''"> and t.title = #{title}</if>
            <if test="delFlag != null and delFlag != ''"> and t.del_flag = #{delFlag}</if>
        </where>
        order by t.create_time desc
    </select>

    <select id="selectAppVersionById" parameterType="Long" resultMap="AppVersionResult">
        <include refid="selectAppVersionVo"/>
        where t.id = #{id}
    </select>

    <insert id="insertAppVersion" parameterType="com.ruoyi.frequency.appversion.entity.AppVersion">
        insert into t_app_version
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">id,</if>
            <if test="delFlag != null">del_flag,</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="version != null">version,</if>
            <if test="isForce != null">is_force,</if>
            <if test="url != null">url,</if>
            <if test="sort != null">sort,</if>
            <if test="appType != null">app_type,</if>
            <if test="content != null">content,</if>
            <if test="title != null">title,</if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="id != null">#{id},</if>
            <if test="delFlag != null">#{delFlag},</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="version != null">#{version},</if>
            <if test="isForce != null">#{isForce},</if>
            <if test="url != null">#{url},</if>
            <if test="sort != null">#{sort},</if>
            <if test="appType != null">#{appType},</if>
            <if test="content != null">#{content},</if>
            <if test="title != null">#{title},</if>
        </trim>
    </insert>

    <update id="updateAppVersion" parameterType="com.ruoyi.frequency.appversion.entity.AppVersion">
        update t_app_version
        <trim prefix="SET" suffixOverrides=",">
            <if test="delFlag != null">del_flag = #{delFlag},</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="version != null">version = #{version},</if>
            <if test="isForce != null">is_force = #{isForce},</if>
            <if test="url != null">url = #{url},</if>
            <if test="sort != null">sort = #{sort},</if>
            <if test="appType != null">app_type = #{appType},</if>
            <if test="content != null">content = #{content},</if>
            <if test="title != null">title = #{title},</if>
        </trim>
        where id = #{id}
    </update>
                                                                                                                        </mapper>