<?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.advertisement.persistent.mapper.MediaResourceMapper">
  <resultMap id="BaseResultMap" type="com.neusoft.smart.pos.advertisement.persistent.domain.MediaResource">
    <id column="id" jdbcType="INTEGER" property="id" />
    <result column="media_name" jdbcType="VARCHAR" property="mediaName" />
    <result column="media_uuid" jdbcType="VARCHAR" property="mediaUuid" />
    <result column="media_url" jdbcType="VARCHAR" property="mediaUrl" />
    <result column="media_type" jdbcType="INTEGER" property="mediaType" />
    <result column="file_type" jdbcType="VARCHAR" property="fileType" />
    <result column="status" jdbcType="INTEGER" property="status" />
    <result column="display_type" jdbcType="INTEGER" property="displayType" />
    <result column="create_by" jdbcType="INTEGER" property="createBy" />
    <result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
    <result column="organization_id" jdbcType="INTEGER" property="organizationId" />
    <result column="store_id" jdbcType="INTEGER" property="storeId" />
  </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, media_name, media_uuid, media_url, media_type, file_type, status, display_type, 
    create_by, create_time, organization_id, store_id
  </sql>
  <select id="selectByExample" parameterType="com.neusoft.smart.pos.advertisement.persistent.domain.MediaResourceExample" resultMap="BaseResultMap">
    select
    <if test="distinct">
      distinct
    </if>
    <include refid="Base_Column_List" />
    from media_resource
    <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 media_resource
    where id = #{id,jdbcType=INTEGER}
  </select>
  <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
    delete from media_resource
    where id = #{id,jdbcType=INTEGER}
  </delete>
  <delete id="deleteByExample" parameterType="com.neusoft.smart.pos.advertisement.persistent.domain.MediaResourceExample">
    delete from media_resource
    <if test="_parameter != null">
      <include refid="Example_Where_Clause" />
    </if>
  </delete>
  <insert id="insert" keyColumn="id" keyProperty="id" parameterType="com.neusoft.smart.pos.advertisement.persistent.domain.MediaResource" useGeneratedKeys="true">
    insert into media_resource (media_name, media_uuid, media_url, 
      media_type, file_type, status, 
      display_type, create_by, create_time, 
      organization_id, store_id)
    values (#{mediaName,jdbcType=VARCHAR}, #{mediaUuid,jdbcType=VARCHAR}, #{mediaUrl,jdbcType=VARCHAR}, 
      #{mediaType,jdbcType=INTEGER}, #{fileType,jdbcType=VARCHAR}, #{status,jdbcType=INTEGER}, 
      #{displayType,jdbcType=INTEGER}, #{createBy,jdbcType=INTEGER}, #{createTime,jdbcType=TIMESTAMP}, 
      #{organizationId,jdbcType=INTEGER}, #{storeId,jdbcType=INTEGER})
  </insert>
  <insert id="insertSelective" keyColumn="id" keyProperty="id" parameterType="com.neusoft.smart.pos.advertisement.persistent.domain.MediaResource" useGeneratedKeys="true">
    insert into media_resource
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="mediaName != null">
        media_name,
      </if>
      <if test="mediaUuid != null">
        media_uuid,
      </if>
      <if test="mediaUrl != null">
        media_url,
      </if>
      <if test="mediaType != null">
        media_type,
      </if>
      <if test="fileType != null">
        file_type,
      </if>
      <if test="status != null">
        status,
      </if>
      <if test="displayType != null">
        display_type,
      </if>
      <if test="createBy != null">
        create_by,
      </if>
      <if test="createTime != null">
        create_time,
      </if>
      <if test="organizationId != null">
        organization_id,
      </if>
      <if test="storeId != null">
        store_id,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides=",">
      <if test="mediaName != null">
        #{mediaName,jdbcType=VARCHAR},
      </if>
      <if test="mediaUuid != null">
        #{mediaUuid,jdbcType=VARCHAR},
      </if>
      <if test="mediaUrl != null">
        #{mediaUrl,jdbcType=VARCHAR},
      </if>
      <if test="mediaType != null">
        #{mediaType,jdbcType=INTEGER},
      </if>
      <if test="fileType != null">
        #{fileType,jdbcType=VARCHAR},
      </if>
      <if test="status != null">
        #{status,jdbcType=INTEGER},
      </if>
      <if test="displayType != null">
        #{displayType,jdbcType=INTEGER},
      </if>
      <if test="createBy != null">
        #{createBy,jdbcType=INTEGER},
      </if>
      <if test="createTime != null">
        #{createTime,jdbcType=TIMESTAMP},
      </if>
      <if test="organizationId != null">
        #{organizationId,jdbcType=INTEGER},
      </if>
      <if test="storeId != null">
        #{storeId,jdbcType=INTEGER},
      </if>
    </trim>
  </insert>
  <select id="countByExample" parameterType="com.neusoft.smart.pos.advertisement.persistent.domain.MediaResourceExample" resultType="java.lang.Integer">
    select count(*) from media_resource
    <if test="_parameter != null">
      <include refid="Example_Where_Clause" />
    </if>
  </select>
  <update id="updateByExampleSelective" parameterType="map">
    update media_resource
    <set>
      <if test="record.id != null">
        id = #{record.id,jdbcType=INTEGER},
      </if>
      <if test="record.mediaName != null">
        media_name = #{record.mediaName,jdbcType=VARCHAR},
      </if>
      <if test="record.mediaUuid != null">
        media_uuid = #{record.mediaUuid,jdbcType=VARCHAR},
      </if>
      <if test="record.mediaUrl != null">
        media_url = #{record.mediaUrl,jdbcType=VARCHAR},
      </if>
      <if test="record.mediaType != null">
        media_type = #{record.mediaType,jdbcType=INTEGER},
      </if>
      <if test="record.fileType != null">
        file_type = #{record.fileType,jdbcType=VARCHAR},
      </if>
      <if test="record.status != null">
        status = #{record.status,jdbcType=INTEGER},
      </if>
      <if test="record.displayType != null">
        display_type = #{record.displayType,jdbcType=INTEGER},
      </if>
      <if test="record.createBy != null">
        create_by = #{record.createBy,jdbcType=INTEGER},
      </if>
      <if test="record.createTime != null">
        create_time = #{record.createTime,jdbcType=TIMESTAMP},
      </if>
      <if test="record.organizationId != null">
        organization_id = #{record.organizationId,jdbcType=INTEGER},
      </if>
      <if test="record.storeId != null">
        store_id = #{record.storeId,jdbcType=INTEGER},
      </if>
    </set>
    <if test="_parameter != null">
      <include refid="Update_By_Example_Where_Clause" />
    </if>
  </update>
  <update id="updateByExample" parameterType="map">
    update media_resource
    set id = #{record.id,jdbcType=INTEGER},
      media_name = #{record.mediaName,jdbcType=VARCHAR},
      media_uuid = #{record.mediaUuid,jdbcType=VARCHAR},
      media_url = #{record.mediaUrl,jdbcType=VARCHAR},
      media_type = #{record.mediaType,jdbcType=INTEGER},
      file_type = #{record.fileType,jdbcType=VARCHAR},
      status = #{record.status,jdbcType=INTEGER},
      display_type = #{record.displayType,jdbcType=INTEGER},
      create_by = #{record.createBy,jdbcType=INTEGER},
      create_time = #{record.createTime,jdbcType=TIMESTAMP},
      organization_id = #{record.organizationId,jdbcType=INTEGER},
      store_id = #{record.storeId,jdbcType=INTEGER}
    <if test="_parameter != null">
      <include refid="Update_By_Example_Where_Clause" />
    </if>
  </update>
  <update id="updateByPrimaryKeySelective" parameterType="com.neusoft.smart.pos.advertisement.persistent.domain.MediaResource">
    update media_resource
    <set>
      <if test="mediaName != null">
        media_name = #{mediaName,jdbcType=VARCHAR},
      </if>
      <if test="mediaUuid != null">
        media_uuid = #{mediaUuid,jdbcType=VARCHAR},
      </if>
      <if test="mediaUrl != null">
        media_url = #{mediaUrl,jdbcType=VARCHAR},
      </if>
      <if test="mediaType != null">
        media_type = #{mediaType,jdbcType=INTEGER},
      </if>
      <if test="fileType != null">
        file_type = #{fileType,jdbcType=VARCHAR},
      </if>
      <if test="status != null">
        status = #{status,jdbcType=INTEGER},
      </if>
      <if test="displayType != null">
        display_type = #{displayType,jdbcType=INTEGER},
      </if>
      <if test="createBy != null">
        create_by = #{createBy,jdbcType=INTEGER},
      </if>
      <if test="createTime != null">
        create_time = #{createTime,jdbcType=TIMESTAMP},
      </if>
      <if test="organizationId != null">
        organization_id = #{organizationId,jdbcType=INTEGER},
      </if>
      <if test="storeId != null">
        store_id = #{storeId,jdbcType=INTEGER},
      </if>
    </set>
    where id = #{id,jdbcType=INTEGER}
  </update>
  <update id="updateByPrimaryKey" parameterType="com.neusoft.smart.pos.advertisement.persistent.domain.MediaResource">
    update media_resource
    set media_name = #{mediaName,jdbcType=VARCHAR},
      media_uuid = #{mediaUuid,jdbcType=VARCHAR},
      media_url = #{mediaUrl,jdbcType=VARCHAR},
      media_type = #{mediaType,jdbcType=INTEGER},
      file_type = #{fileType,jdbcType=VARCHAR},
      status = #{status,jdbcType=INTEGER},
      display_type = #{displayType,jdbcType=INTEGER},
      create_by = #{createBy,jdbcType=INTEGER},
      create_time = #{createTime,jdbcType=TIMESTAMP},
      organization_id = #{organizationId,jdbcType=INTEGER},
      store_id = #{storeId,jdbcType=INTEGER}
    where id = #{id,jdbcType=INTEGER}
  </update>
  <insert id="batchInsert">
    <if test="items.get(0) != null">
            insert into media_resource  (media_name, media_uuid, media_url, 
        media_type, file_type, status, 
        display_type, create_by, create_time, 
        organization_id, store_id)
      values
      <foreach collection="items" item="item" index="index" separator=",">
      (#{item.mediaName,jdbcType=VARCHAR}, #{item.mediaUuid,jdbcType=VARCHAR}, #{item.mediaUrl,jdbcType=VARCHAR}, 
        #{item.mediaType,jdbcType=INTEGER}, #{item.fileType,jdbcType=VARCHAR}, #{item.status,jdbcType=INTEGER}, 
        #{item.displayType,jdbcType=INTEGER}, #{item.createBy,jdbcType=INTEGER}, #{item.createTime,jdbcType=TIMESTAMP}, 
        #{item.organizationId,jdbcType=INTEGER}, #{item.storeId,jdbcType=INTEGER})
      </foreach>
    </if>
  </insert>
</mapper>