<?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.neusoft.smart.pos.ota.persistent.mapper.UpgradePackageMapper">
    <resultMap id="BaseResultMap" type="com.neusoft.smart.pos.ota.persistent.domain.UpgradePackage">
        <id column="id" jdbcType="INTEGER" property="id"/>
        <result column="file_name" jdbcType="VARCHAR" property="fileName"/>
        <result column="file_path" jdbcType="VARCHAR" property="filePath"/>
        <result column="file_size" jdbcType="INTEGER" property="fileSize"/>
        <result column="md5_code" jdbcType="VARCHAR" property="md5Code"/>
        <result column="file_type" jdbcType="INTEGER" property="fileType"/>
        <result column="version_code" jdbcType="VARCHAR" property="versionCode"/>
        <result column="prev_package_id" jdbcType="INTEGER" property="prevPackageId"/>
        <result column="manufacturer" jdbcType="VARCHAR" property="manufacturer"/>
        <result column="device_type" jdbcType="VARCHAR" property="deviceType"/>
        <result column="device_model" jdbcType="VARCHAR" property="deviceModel"/>
        <result column="customer" jdbcType="VARCHAR" property="customer"/>
        <result column="created_by" jdbcType="INTEGER" property="createdBy"/>
        <result column="created_date" jdbcType="TIMESTAMP" property="createdDate"/>
        <result column="last_modified_by" jdbcType="INTEGER" property="lastModifiedBy"/>
        <result column="last_modified_date" jdbcType="TIMESTAMP" property="lastModifiedDate"/>
        <result column="status" jdbcType="INTEGER" property="status"/>
        <result column="release_note" jdbcType="VARCHAR" property="releaseNote"/>
        <result column="organization_id" jdbcType="INTEGER" property="organizationId"/>
    </resultMap>
    <sql id="Example_Where_Clause">
        <where>
            <foreach collection="oredCriteria" item="criteria" separator="or">
                <if test="criteria.valid">
                    <trim prefix="(" prefixOverrides="and" suffix=")">
                        <foreach collection="criteria.criteria" item="criterion">
                            <choose>
                                <when test="criterion.noValue">
                                    and ${criterion.condition}
                                </when>
                                <when test="criterion.singleValue">
                                    and ${criterion.condition} #{criterion.value}
                                </when>
                                <when test="criterion.betweenValue">
                                    and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
                                </when>
                                <when test="criterion.listValue">
                                    and ${criterion.condition}
                                    <foreach close=")" collection="criterion.value" item="listItem" open="("
                                             separator=",">
                                        #{listItem}
                                    </foreach>
                                </when>
                            </choose>
                        </foreach>
                    </trim>
                </if>
            </foreach>
        </where>
    </sql>
    <sql id="Update_By_Example_Where_Clause">
        <where>
            <foreach collection="example.oredCriteria" item="criteria" separator="or">
                <if test="criteria.valid">
                    <trim prefix="(" prefixOverrides="and" suffix=")">
                        <foreach collection="criteria.criteria" item="criterion">
                            <choose>
                                <when test="criterion.noValue">
                                    and ${criterion.condition}
                                </when>
                                <when test="criterion.singleValue">
                                    and ${criterion.condition} #{criterion.value}
                                </when>
                                <when test="criterion.betweenValue">
                                    and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
                                </when>
                                <when test="criterion.listValue">
                                    and ${criterion.condition}
                                    <foreach close=")" collection="criterion.value" item="listItem" open="("
                                             separator=",">
                                        #{listItem}
                                    </foreach>
                                </when>
                            </choose>
                        </foreach>
                    </trim>
                </if>
            </foreach>
        </where>
    </sql>
    <sql id="Base_Column_List">
        id, file_name, file_path, file_size, md5_code, file_type, version_code, prev_package_id,
        manufacturer, device_type, device_model, customer, created_by, created_date, last_modified_by,
        last_modified_date, status, release_note, organization_id
    </sql>
    <select id="selectByExample" parameterType="com.neusoft.smart.pos.ota.persistent.domain.UpgradePackageExample"
            resultMap="BaseResultMap">
        select
        <if test="distinct">
            distinct
        </if>
        <include refid="Base_Column_List"/>
        from upgrade_package
        <if test="_parameter != null">
            <include refid="Example_Where_Clause"/>
        </if>
        <if test="orderByClause != null">
            order by ${orderByClause}
        </if>
        <if test="offset != null and limit != null">
            limit ${offset}, ${limit}
        </if>
    </select>
    <select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap">
        select
        <include refid="Base_Column_List"/>
        from upgrade_package
        where id = #{id,jdbcType=INTEGER}
    </select>
    <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
        delete from upgrade_package
        where id = #{id,jdbcType=INTEGER}
    </delete>
    <delete id="deleteByExample" parameterType="com.neusoft.smart.pos.ota.persistent.domain.UpgradePackageExample">
        delete from upgrade_package
        <if test="_parameter != null">
            <include refid="Example_Where_Clause"/>
        </if>
    </delete>
    <insert id="insert" keyColumn="id" keyProperty="id"
            parameterType="com.neusoft.smart.pos.ota.persistent.domain.UpgradePackage" useGeneratedKeys="true">
        insert into upgrade_package (file_name, file_path, file_size,
        md5_code, file_type, version_code,
        prev_package_id, manufacturer, device_type,
        device_model, customer, created_by,
        created_date, last_modified_by, last_modified_date,
        status, release_note, organization_id
        )
        values (#{fileName,jdbcType=VARCHAR}, #{filePath,jdbcType=VARCHAR}, #{fileSize,jdbcType=INTEGER},
        #{md5Code,jdbcType=VARCHAR}, #{fileType,jdbcType=INTEGER}, #{versionCode,jdbcType=VARCHAR},
        #{prevPackageId,jdbcType=INTEGER}, #{manufacturer,jdbcType=VARCHAR}, #{deviceType,jdbcType=VARCHAR},
        #{deviceModel,jdbcType=VARCHAR}, #{customer,jdbcType=VARCHAR}, #{createdBy,jdbcType=INTEGER},
        #{createdDate,jdbcType=TIMESTAMP}, #{lastModifiedBy,jdbcType=INTEGER}, #{lastModifiedDate,jdbcType=TIMESTAMP},
        #{status,jdbcType=INTEGER}, #{releaseNote,jdbcType=VARCHAR}, #{organizationId,jdbcType=INTEGER}
        )
    </insert>
    <insert id="insertSelective" keyColumn="id" keyProperty="id"
            parameterType="com.neusoft.smart.pos.ota.persistent.domain.UpgradePackage" useGeneratedKeys="true">
        insert into upgrade_package
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="fileName != null">
                file_name,
            </if>
            <if test="filePath != null">
                file_path,
            </if>
            <if test="fileSize != null">
                file_size,
            </if>
            <if test="md5Code != null">
                md5_code,
            </if>
            <if test="fileType != null">
                file_type,
            </if>
            <if test="versionCode != null">
                version_code,
            </if>
            <if test="prevPackageId != null">
                prev_package_id,
            </if>
            <if test="manufacturer != null">
                manufacturer,
            </if>
            <if test="deviceType != null">
                device_type,
            </if>
            <if test="deviceModel != null">
                device_model,
            </if>
            <if test="customer != null">
                customer,
            </if>
            <if test="createdBy != null">
                created_by,
            </if>
            <if test="createdDate != null">
                created_date,
            </if>
            <if test="lastModifiedBy != null">
                last_modified_by,
            </if>
            <if test="lastModifiedDate != null">
                last_modified_date,
            </if>
            <if test="status != null">
                status,
            </if>
            <if test="releaseNote != null">
                release_note,
            </if>
            <if test="organizationId != null">
                organization_id,
            </if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="fileName != null">
                #{fileName,jdbcType=VARCHAR},
            </if>
            <if test="filePath != null">
                #{filePath,jdbcType=VARCHAR},
            </if>
            <if test="fileSize != null">
                #{fileSize,jdbcType=INTEGER},
            </if>
            <if test="md5Code != null">
                #{md5Code,jdbcType=VARCHAR},
            </if>
            <if test="fileType != null">
                #{fileType,jdbcType=INTEGER},
            </if>
            <if test="versionCode != null">
                #{versionCode,jdbcType=VARCHAR},
            </if>
            <if test="prevPackageId != null">
                #{prevPackageId,jdbcType=INTEGER},
            </if>
            <if test="manufacturer != null">
                #{manufacturer,jdbcType=VARCHAR},
            </if>
            <if test="deviceType != null">
                #{deviceType,jdbcType=VARCHAR},
            </if>
            <if test="deviceModel != null">
                #{deviceModel,jdbcType=VARCHAR},
            </if>
            <if test="customer != null">
                #{customer,jdbcType=VARCHAR},
            </if>
            <if test="createdBy != null">
                #{createdBy,jdbcType=INTEGER},
            </if>
            <if test="createdDate != null">
                #{createdDate,jdbcType=TIMESTAMP},
            </if>
            <if test="lastModifiedBy != null">
                #{lastModifiedBy,jdbcType=INTEGER},
            </if>
            <if test="lastModifiedDate != null">
                #{lastModifiedDate,jdbcType=TIMESTAMP},
            </if>
            <if test="status != null">
                #{status,jdbcType=INTEGER},
            </if>
            <if test="releaseNote != null">
                #{releaseNote,jdbcType=VARCHAR},
            </if>
            <if test="organizationId != null">
                #{organizationId,jdbcType=INTEGER},
            </if>
        </trim>
    </insert>
    <select id="countByExample" parameterType="com.neusoft.smart.pos.ota.persistent.domain.UpgradePackageExample"
            resultType="java.lang.Integer">
        select count(*) from upgrade_package
        <if test="_parameter != null">
            <include refid="Example_Where_Clause"/>
        </if>
    </select>
    <update id="updateByExampleSelective" parameterType="map">
        update upgrade_package
        <set>
            <if test="record.id != null">
                id = #{record.id,jdbcType=INTEGER},
            </if>
            <if test="record.fileName != null">
                file_name = #{record.fileName,jdbcType=VARCHAR},
            </if>
            <if test="record.filePath != null">
                file_path = #{record.filePath,jdbcType=VARCHAR},
            </if>
            <if test="record.fileSize != null">
                file_size = #{record.fileSize,jdbcType=INTEGER},
            </if>
            <if test="record.md5Code != null">
                md5_code = #{record.md5Code,jdbcType=VARCHAR},
            </if>
            <if test="record.fileType != null">
                file_type = #{record.fileType,jdbcType=INTEGER},
            </if>
            <if test="record.versionCode != null">
                version_code = #{record.versionCode,jdbcType=VARCHAR},
            </if>
            <if test="record.prevPackageId != null">
                prev_package_id = #{record.prevPackageId,jdbcType=INTEGER},
            </if>
            <if test="record.manufacturer != null">
                manufacturer = #{record.manufacturer,jdbcType=VARCHAR},
            </if>
            <if test="record.deviceType != null">
                device_type = #{record.deviceType,jdbcType=VARCHAR},
            </if>
            <if test="record.deviceModel != null">
                device_model = #{record.deviceModel,jdbcType=VARCHAR},
            </if>
            <if test="record.customer != null">
                customer = #{record.customer,jdbcType=VARCHAR},
            </if>
            <if test="record.createdBy != null">
                created_by = #{record.createdBy,jdbcType=INTEGER},
            </if>
            <if test="record.createdDate != null">
                created_date = #{record.createdDate,jdbcType=TIMESTAMP},
            </if>
            <if test="record.lastModifiedBy != null">
                last_modified_by = #{record.lastModifiedBy,jdbcType=INTEGER},
            </if>
            <if test="record.lastModifiedDate != null">
                last_modified_date = #{record.lastModifiedDate,jdbcType=TIMESTAMP},
            </if>
            <if test="record.status != null">
                status = #{record.status,jdbcType=INTEGER},
            </if>
            <if test="record.releaseNote != null">
                release_note = #{record.releaseNote,jdbcType=VARCHAR},
            </if>
            <if test="record.organizationId != null">
                organization_id = #{record.organizationId,jdbcType=INTEGER},
            </if>
        </set>
        <if test="_parameter != null">
            <include refid="Update_By_Example_Where_Clause"/>
        </if>
    </update>
    <update id="updateByExample" parameterType="map">
        update upgrade_package
        set id = #{record.id,jdbcType=INTEGER},
        file_name = #{record.fileName,jdbcType=VARCHAR},
        file_path = #{record.filePath,jdbcType=VARCHAR},
        file_size = #{record.fileSize,jdbcType=INTEGER},
        md5_code = #{record.md5Code,jdbcType=VARCHAR},
        file_type = #{record.fileType,jdbcType=INTEGER},
        version_code = #{record.versionCode,jdbcType=VARCHAR},
        prev_package_id = #{record.prevPackageId,jdbcType=INTEGER},
        manufacturer = #{record.manufacturer,jdbcType=VARCHAR},
        device_type = #{record.deviceType,jdbcType=VARCHAR},
        device_model = #{record.deviceModel,jdbcType=VARCHAR},
        customer = #{record.customer,jdbcType=VARCHAR},
        created_by = #{record.createdBy,jdbcType=INTEGER},
        created_date = #{record.createdDate,jdbcType=TIMESTAMP},
        last_modified_by = #{record.lastModifiedBy,jdbcType=INTEGER},
        last_modified_date = #{record.lastModifiedDate,jdbcType=TIMESTAMP},
        status = #{record.status,jdbcType=INTEGER},
        release_note = #{record.releaseNote,jdbcType=VARCHAR},
        organization_id = #{record.organizationId,jdbcType=INTEGER}
        <if test="_parameter != null">
            <include refid="Update_By_Example_Where_Clause"/>
        </if>
    </update>
    <update id="updateByPrimaryKeySelective" parameterType="com.neusoft.smart.pos.ota.persistent.domain.UpgradePackage">
        update upgrade_package
        <set>
            <if test="fileName != null">
                file_name = #{fileName,jdbcType=VARCHAR},
            </if>
            <if test="filePath != null">
                file_path = #{filePath,jdbcType=VARCHAR},
            </if>
            <if test="fileSize != null">
                file_size = #{fileSize,jdbcType=INTEGER},
            </if>
            <if test="md5Code != null">
                md5_code = #{md5Code,jdbcType=VARCHAR},
            </if>
            <if test="fileType != null">
                file_type = #{fileType,jdbcType=INTEGER},
            </if>
            <if test="versionCode != null">
                version_code = #{versionCode,jdbcType=VARCHAR},
            </if>
            <if test="prevPackageId != null">
                prev_package_id = #{prevPackageId,jdbcType=INTEGER},
            </if>
            <if test="manufacturer != null">
                manufacturer = #{manufacturer,jdbcType=VARCHAR},
            </if>
            <if test="deviceType != null">
                device_type = #{deviceType,jdbcType=VARCHAR},
            </if>
            <if test="deviceModel != null">
                device_model = #{deviceModel,jdbcType=VARCHAR},
            </if>
            <if test="customer != null">
                customer = #{customer,jdbcType=VARCHAR},
            </if>
            <if test="createdBy != null">
                created_by = #{createdBy,jdbcType=INTEGER},
            </if>
            <if test="createdDate != null">
                created_date = #{createdDate,jdbcType=TIMESTAMP},
            </if>
            <if test="lastModifiedBy != null">
                last_modified_by = #{lastModifiedBy,jdbcType=INTEGER},
            </if>
            <if test="lastModifiedDate != null">
                last_modified_date = #{lastModifiedDate,jdbcType=TIMESTAMP},
            </if>
            <if test="status != null">
                status = #{status,jdbcType=INTEGER},
            </if>
            <if test="releaseNote != null">
                release_note = #{releaseNote,jdbcType=VARCHAR},
            </if>
            <if test="organizationId != null">
                organization_id = #{organizationId,jdbcType=INTEGER},
            </if>
        </set>
        where id = #{id,jdbcType=INTEGER}
    </update>
    <update id="updateByPrimaryKey" parameterType="com.neusoft.smart.pos.ota.persistent.domain.UpgradePackage">
        update upgrade_package
        set file_name = #{fileName,jdbcType=VARCHAR},
        file_path = #{filePath,jdbcType=VARCHAR},
        file_size = #{fileSize,jdbcType=INTEGER},
        md5_code = #{md5Code,jdbcType=VARCHAR},
        file_type = #{fileType,jdbcType=INTEGER},
        version_code = #{versionCode,jdbcType=VARCHAR},
        prev_package_id = #{prevPackageId,jdbcType=INTEGER},
        manufacturer = #{manufacturer,jdbcType=VARCHAR},
        device_type = #{deviceType,jdbcType=VARCHAR},
        device_model = #{deviceModel,jdbcType=VARCHAR},
        customer = #{customer,jdbcType=VARCHAR},
        created_by = #{createdBy,jdbcType=INTEGER},
        created_date = #{createdDate,jdbcType=TIMESTAMP},
        last_modified_by = #{lastModifiedBy,jdbcType=INTEGER},
        last_modified_date = #{lastModifiedDate,jdbcType=TIMESTAMP},
        status = #{status,jdbcType=INTEGER},
        release_note = #{releaseNote,jdbcType=VARCHAR},
        organization_id = #{organizationId,jdbcType=INTEGER}
        where id = #{id,jdbcType=INTEGER}
    </update>
</mapper>