<?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.ximai.mes.pro.mapper.AppConfigMapper">

    <resultMap type="AppConfig" id="AppConfigResult">
        <result property="id" column="id"/>
        <result property="version" column="version"/>
        <result property="lastVersion" column="last_version"/>
        <result property="url" column="url"/>
        <result property="updateState" column="update_state"/>
        <result property="updateDesc" column="update_desc"/>
        <result property="createBy" column="create_by"/>
        <result property="updateBy" column="update_by"/>
        <result property="updateTime" column="update_time"/>
        <result property="createTime" column="create_time"/>
    </resultMap>

    <sql id="selectAppConfigVo">
        select id,
               version,
               last_version,
               url,
               update_state,
               update_desc,
               create_by,
               update_by,
               update_time,
               create_time
        from app_config
    </sql>

    <select id="selectAppConfigList" parameterType="AppConfig" resultMap="AppConfigResult">
        <include refid="selectAppConfigVo"/>
        <where>
            <if test="version != null  and version != ''">and version = #{version}</if>
            <if test="url != null  and url != ''">and url = #{url}</if>
            <if test="updateState != null ">and update_state = #{updateState}</if>
            <if test="updateDesc != null ">and update_desc = #{updateDesc}</if>
        </where>
    </select>

    <select id="selectAppConfigById" parameterType="Long" resultMap="AppConfigResult">
        <include refid="selectAppConfigVo"/>
        where id = #{id}
    </select>

    <insert id="insertAppConfig" parameterType="AppConfig">
        insert into app_config
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">id,</if>
            <if test="version != null">version,</if>
            <if test="lastVersion != null">last_version,</if>
            <if test="url != null">url,</if>
            <if test="updateState != null">update_state,</if>
            <if test="updateDesc != null">update_desc,</if>
            <if test="createBy != null">create_by,</if>
            <if test="updateBy != null">update_by,</if>
            <if test="updateTime != null">update_time,</if>
            <if test="createTime != null">create_time,</if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="id != null">#{id},</if>
            <if test="version != null">#{version},</if>
            <if test="lastVersion != null">#{lastVersion},</if>
            <if test="url != null">#{url},</if>
            <if test="updateState != null">#{updateState},</if>
            <if test="updateDesc != null">#{updateDesc},</if>
            <if test="createBy != null">#{createBy},</if>
            <if test="updateBy != null">#{updateBy},</if>
            <if test="updateTime != null">#{updateTime},</if>
            <if test="createTime != null">#{createTime},</if>
        </trim>
    </insert>

    <update id="updateAppConfig" parameterType="AppConfig">
        update app_config
        <trim prefix="SET" suffixOverrides=",">
            <if test="version != null">version = #{version},</if>
            <if test="url != null">url = #{url},</if>
            <if test="updateState != null">update_state = #{updateState},</if>
            <if test="lastVersion != null">last_version = #{lastVersion},</if>
            <if test="updateDesc != null">update_desc = #{updateDesc},</if>
            <if test="createBy != null">create_by = #{createBy},</if>
            <if test="updateBy != null">update_by = #{updateBy},</if>
            <if test="updateTime != null">update_time = #{updateTime},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteAppConfigById" parameterType="Long">
        delete
        from app_config
        where id = #{id}
    </delete>

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