<?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.appVersion.mapper.TAppVersionMapper">
    
    <resultMap type="TAppVersion" id="TAppVersionResult">
        <result property="fId"    column="f_id"    />
        <result property="fParamkey"    column="f_paramKey"    />
        <result property="fParamvalue"    column="f_paramValue"    />
        <result property="fStatus"    column="f_status"    />
        <result property="fParamlabel"    column="f_paramLabel"    />
        <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="remark"    column="remark"    />
    </resultMap>

    <sql id="selectTAppVersionVo">
        select f_id, f_paramKey, f_paramValue, f_status,
               CASE
                   WHEN f_status = '0' THEN
                       '正常'
                   WHEN f_status = '1' THEN
                       '停用'
                   END AS fStatusName,
               f_paramLabel, create_by, create_time, update_by, update_time, remark from t_app_version
    </sql>

    <select id="selectTAppVersionList" parameterType="TAppVersion" resultMap="TAppVersionResult">
        <include refid="selectTAppVersionVo"/>
        <where>  
            <if test="fParamkey != null  and fParamkey != ''"> and f_paramKey = #{fParamkey}</if>
            <if test="fParamvalue != null  and fParamvalue != ''"> and f_paramValue = #{fParamvalue}</if>
            <if test="fStatus != null "> and f_status = #{fStatus}</if>
            <if test="fParamlabel != null  and fParamlabel != ''"> and f_paramLabel = #{fParamlabel}</if>
        </where>
    </select>
    
    <select id="selectTAppVersionById" parameterType="Long" resultMap="TAppVersionResult">
        <include refid="selectTAppVersionVo"/>
        where f_id = #{fId}
    </select>
        
    <insert id="insertTAppVersion" parameterType="TAppVersion">
        insert into t_app_version
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="fId != null">f_id,</if>
            <if test="fParamkey != null">f_paramKey,</if>
            <if test="fParamvalue != null">f_paramValue,</if>
            <if test="fStatus != null">f_status,</if>
            <if test="fParamlabel != null">f_paramLabel,</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="remark != null">remark,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="fId != null">#{fId},</if>
            <if test="fParamkey != null">#{fParamkey},</if>
            <if test="fParamvalue != null">#{fParamvalue},</if>
            <if test="fStatus != null">#{fStatus},</if>
            <if test="fParamlabel != null">#{fParamlabel},</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="remark != null">#{remark},</if>
         </trim>
    </insert>

    <update id="updateTAppVersion" parameterType="TAppVersion">
        update t_app_version
        <trim prefix="SET" suffixOverrides=",">
            <if test="fParamkey != null">f_paramKey = #{fParamkey},</if>
            <if test="fParamvalue != null">f_paramValue = #{fParamvalue},</if>
            <if test="fStatus != null">f_status = #{fStatus},</if>
            <if test="fParamlabel != null">f_paramLabel = #{fParamlabel},</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="remark != null">remark = #{remark},</if>
        </trim>
        where f_id = #{fId}
    </update>

    <delete id="deleteTAppVersionById" parameterType="Long">
        delete from t_app_version where f_id = #{fId}
    </delete>
    <update id="updateTAppVersionFstatus" parameterType="TAppVersion">
        update t_app_version
        set f_status = 1
        where f_id in
        <foreach item="fId" collection="array" open="(" separator="," close=")">
            #{fId}
        </foreach>
    </update>

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