<?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.MediaStrategyGroupMapper">
    <resultMap id="BaseResultMap" type="com.neusoft.smart.pos.advertisement.persistent.domain.MediaStrategyGroup">
        <id column="id" jdbcType="INTEGER" property="id"/>
        <result column="strategy_name" jdbcType="VARCHAR" property="strategyName"/>
        <result column="cache_time" jdbcType="BIGINT" property="cacheTime"/>
        <result column="created_by" jdbcType="INTEGER" property="createdBy"/>
        <result column="created_date" jdbcType="TIMESTAMP" property="createdDate"/>
        <result column="status" jdbcType="INTEGER" property="status"/>
        <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, strategy_name, cache_time, created_by, created_date, status, organization_id,
        store_id
    </sql>
    <select id="selectByExample"
            parameterType="com.neusoft.smart.pos.advertisement.persistent.domain.MediaStrategyGroupExample"
            resultMap="BaseResultMap">
        select
        <if test="distinct">
            distinct
        </if>
        <include refid="Base_Column_List"/>
        from media_strategy_group
        <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_strategy_group
        where id = #{id,jdbcType=INTEGER}
    </select>
    <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
        delete from media_strategy_group
        where id = #{id,jdbcType=INTEGER}
    </delete>
    <delete id="deleteByExample"
            parameterType="com.neusoft.smart.pos.advertisement.persistent.domain.MediaStrategyGroupExample">
        delete from media_strategy_group
        <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.MediaStrategyGroup"
            useGeneratedKeys="true">
        insert into media_strategy_group (strategy_name, cache_time, created_by,
        created_date, status, organization_id,
        store_id)
        values (#{strategyName,jdbcType=VARCHAR}, #{cacheTime,jdbcType=BIGINT}, #{createdBy,jdbcType=INTEGER},
        #{createdDate,jdbcType=TIMESTAMP}, #{status,jdbcType=INTEGER}, #{organizationId,jdbcType=INTEGER},
        #{storeId,jdbcType=INTEGER})
    </insert>
    <insert id="insertSelective" keyColumn="id" keyProperty="id"
            parameterType="com.neusoft.smart.pos.advertisement.persistent.domain.MediaStrategyGroup"
            useGeneratedKeys="true">
        insert into media_strategy_group
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="strategyName != null">
                strategy_name,
            </if>
            <if test="cacheTime != null">
                cache_time,
            </if>
            <if test="createdBy != null">
                created_by,
            </if>
            <if test="createdDate != null">
                created_date,
            </if>
            <if test="status != null">
                status,
            </if>
            <if test="organizationId != null">
                organization_id,
            </if>
            <if test="storeId != null">
                store_id,
            </if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="strategyName != null">
                #{strategyName,jdbcType=VARCHAR},
            </if>
            <if test="cacheTime != null">
                #{cacheTime,jdbcType=BIGINT},
            </if>
            <if test="createdBy != null">
                #{createdBy,jdbcType=INTEGER},
            </if>
            <if test="createdDate != null">
                #{createdDate,jdbcType=TIMESTAMP},
            </if>
            <if test="status != null">
                #{status,jdbcType=INTEGER},
            </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.MediaStrategyGroupExample"
            resultType="java.lang.Integer">
        select count(*) from media_strategy_group
        <if test="_parameter != null">
            <include refid="Example_Where_Clause"/>
        </if>
    </select>
    <update id="updateByExampleSelective" parameterType="map">
        update media_strategy_group
        <set>
            <if test="record.id != null">
                id = #{record.id,jdbcType=INTEGER},
            </if>
            <if test="record.strategyName != null">
                strategy_name = #{record.strategyName,jdbcType=VARCHAR},
            </if>
            <if test="record.cacheTime != null">
                cache_time = #{record.cacheTime,jdbcType=BIGINT},
            </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.status != null">
                status = #{record.status,jdbcType=INTEGER},
            </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_strategy_group
        set id = #{record.id,jdbcType=INTEGER},
        strategy_name = #{record.strategyName,jdbcType=VARCHAR},
        cache_time = #{record.cacheTime,jdbcType=BIGINT},
        created_by = #{record.createdBy,jdbcType=INTEGER},
        created_date = #{record.createdDate,jdbcType=TIMESTAMP},
        status = #{record.status,jdbcType=INTEGER},
        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.MediaStrategyGroup">
        update media_strategy_group
        <set>
            <if test="strategyName != null">
                strategy_name = #{strategyName,jdbcType=VARCHAR},
            </if>
            <if test="cacheTime != null">
                cache_time = #{cacheTime,jdbcType=BIGINT},
            </if>
            <if test="createdBy != null">
                created_by = #{createdBy,jdbcType=INTEGER},
            </if>
            <if test="createdDate != null">
                created_date = #{createdDate,jdbcType=TIMESTAMP},
            </if>
            <if test="status != null">
                status = #{status,jdbcType=INTEGER},
            </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.MediaStrategyGroup">
        update media_strategy_group
        set strategy_name = #{strategyName,jdbcType=VARCHAR},
        cache_time = #{cacheTime,jdbcType=BIGINT},
        created_by = #{createdBy,jdbcType=INTEGER},
        created_date = #{createdDate,jdbcType=TIMESTAMP},
        status = #{status,jdbcType=INTEGER},
        organization_id = #{organizationId,jdbcType=INTEGER},
        store_id = #{storeId,jdbcType=INTEGER}
        where id = #{id,jdbcType=INTEGER}
    </update>
</mapper>