PlatformAppDownloadMapper.xml 11.6 KB
<?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.glsx.mapper.PlatformAppDownloadMapper">
    <resultMap id="BaseResultMap" type="com.glsx.model.PlatformAppDownload">
        <!--@mbg.generated-->
        <!--@Table t_platform_app_download-->
        <id column="id" jdbcType="INTEGER" property="id"/>
        <result column="customer_id" jdbcType="INTEGER" property="customerId"/>
        <result column="create_time" jdbcType="TIMESTAMP" property="createTime"/>
        <result column="create_by" jdbcType="INTEGER" property="createBy"/>
        <result column="remark" jdbcType="VARCHAR" property="remark"/>
    </resultMap>
    <sql id="Base_Column_List">
        <!--@mbg.generated-->
        id, customer_id, create_time, create_by, remark
    </sql>

    <select id="getApiCallCountAuth" resultType="java.lang.Integer">
        select count(1)
        from t_platform_app_download a
        left join t_platform_customer b
        on a.customer_id = b.id
        where b.customer_name = #{customerName,jdbcType=VARCHAR}
    </select>

    <select id="getAppDownloadStatistic" resultType="map">
        select date_format(pad.create_time, '%Y-%m-%d') `time`,
        count(pad.create_time) `count`
        from t_platform_app_download pad
        left join t_platform_customer pc on pc.id = pad.customer_id
        <where>
            pad.create_time >= #{startTime,jdbcType=TIMESTAMP}
            and pad.create_time &lt; #{endTime,jdbcType=TIMESTAMP}
            <if test="customerName != null and customerName != ''">
                and pc.customer_name = #{customerName,jdbcType=VARCHAR}
            </if>
        </where>
        group by time
    </select>



    <select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap">
        <!--@mbg.generated-->
        select
        <include refid="Base_Column_List"/>
        from t_platform_app_download
        where id = #{id,jdbcType=INTEGER}
    </select>

    <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
        <!--@mbg.generated-->
        delete
        from t_platform_app_download
        where id = #{id,jdbcType=INTEGER}
    </delete>
    <insert id="insert" keyColumn="id" keyProperty="id"
            parameterType="com.glsx.model.PlatformAppDownload" useGeneratedKeys="true">
        <!--@mbg.generated-->
        insert into t_platform_app_download (customer_id, create_time, create_by,
                                             remark)
        values (#{customerId,jdbcType=INTEGER}, #{createTime,jdbcType=TIMESTAMP},
                #{createBy,jdbcType=INTEGER},
                #{remark,jdbcType=VARCHAR})
    </insert>
    <insert id="insertSelective" keyColumn="id" keyProperty="id"
            parameterType="com.glsx.model.PlatformAppDownload" useGeneratedKeys="true">
        <!--@mbg.generated-->
        insert into t_platform_app_download
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="customerId != null">
                customer_id,
            </if>
            <if test="createTime != null">
                create_time,
            </if>
            <if test="createBy != null">
                create_by,
            </if>
            <if test="remark != null and remark != ''">
                remark,
            </if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="customerId != null">
                #{customerId,jdbcType=INTEGER},
            </if>
            <if test="createTime != null">
                #{createTime,jdbcType=TIMESTAMP},
            </if>
            <if test="createBy != null">
                #{createBy,jdbcType=INTEGER},
            </if>
            <if test="remark != null and remark != ''">
                #{remark,jdbcType=VARCHAR},
            </if>
        </trim>
    </insert>
    <update id="updateByPrimaryKeySelective" parameterType="com.glsx.model.PlatformAppDownload">
        <!--@mbg.generated-->
        update t_platform_app_download
        <set>
            <if test="customerId != null">
                customer_id = #{customerId,jdbcType=INTEGER},
            </if>
            <if test="createTime != null">
                create_time = #{createTime,jdbcType=TIMESTAMP},
            </if>
            <if test="createBy != null">
                create_by = #{createBy,jdbcType=INTEGER},
            </if>
            <if test="remark != null and remark != ''">
                remark = #{remark,jdbcType=VARCHAR},
            </if>
        </set>
        where id = #{id,jdbcType=INTEGER}
    </update>
    <update id="updateByPrimaryKey" parameterType="com.glsx.model.PlatformAppDownload">
        <!--@mbg.generated-->
        update t_platform_app_download
        set customer_id = #{customerId,jdbcType=INTEGER},
                create_time = #{createTime,jdbcType=TIMESTAMP},
                create_by = #{createBy,jdbcType=INTEGER},
                remark = #{remark,jdbcType=VARCHAR}
        where id = #{id,jdbcType=INTEGER}
    </update>
    <update id="updateBatch" parameterType="java.util.List">
        <!--@mbg.generated-->
        update t_platform_app_download
        <trim prefix="set" suffixOverrides=",">
            <trim prefix="customer_id = case" suffix="end,">
                <foreach collection="list" index="index" item="item">
                    when id = #{item.id,jdbcType=INTEGER} then #{item.customerId,jdbcType=INTEGER}
                </foreach>
            </trim>
            <trim prefix="create_time = case" suffix="end,">
                <foreach collection="list" index="index" item="item">
                    when id = #{item.id,jdbcType=INTEGER} then #{item.createTime,jdbcType=TIMESTAMP}
                </foreach>
            </trim>
            <trim prefix="create_by = case" suffix="end,">
                <foreach collection="list" index="index" item="item">
                    when id = #{item.id,jdbcType=INTEGER} then #{item.createBy,jdbcType=INTEGER}
                </foreach>
            </trim>
            <trim prefix="remark = case" suffix="end,">
                <foreach collection="list" index="index" item="item">
                    when id = #{item.id,jdbcType=INTEGER} then #{item.remark,jdbcType=VARCHAR}
                </foreach>
            </trim>
        </trim>
        where id in
        <foreach close=")" collection="list" item="item" open="(" separator=", ">
            #{item.id,jdbcType=INTEGER}
        </foreach>
    </update>
    <update id="updateBatchSelective" parameterType="java.util.List">
        <!--@mbg.generated-->
        update t_platform_app_download
        <trim prefix="set" suffixOverrides=",">
            <trim prefix="customer_id = case" suffix="end,">
                <foreach collection="list" index="index" item="item">
                    <if test="item.customerId != null">
                        when id = #{item.id,jdbcType=INTEGER}
                                then #{item.customerId,jdbcType=INTEGER}
                    </if>
                </foreach>
            </trim>
            <trim prefix="create_time = case" suffix="end,">
                <foreach collection="list" index="index" item="item">
                    <if test="item.createTime != null">
                        when id = #{item.id,jdbcType=INTEGER}
                                then #{item.createTime,jdbcType=TIMESTAMP}
                    </if>
                </foreach>
            </trim>
            <trim prefix="create_by = case" suffix="end,">
                <foreach collection="list" index="index" item="item">
                    <if test="item.createBy != null">
                        when id = #{item.id,jdbcType=INTEGER} then #{item.createBy,jdbcType=INTEGER}
                    </if>
                </foreach>
            </trim>
            <trim prefix="remark = case" suffix="end,">
                <foreach collection="list" index="index" item="item">
                    <if test="item.remark != null">
                        when id = #{item.id,jdbcType=INTEGER} then #{item.remark,jdbcType=VARCHAR}
                    </if>
                </foreach>
            </trim>
        </trim>
        where id in
        <foreach close=")" collection="list" item="item" open="(" separator=", ">
            #{item.id,jdbcType=INTEGER}
        </foreach>
    </update>
    <insert id="insertOrUpdate" keyColumn="id" keyProperty="id"
            parameterType="com.glsx.model.PlatformAppDownload" useGeneratedKeys="true">
        <!--@mbg.generated-->
        insert into t_platform_app_download
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">
                id,
            </if>
            customer_id,
            create_time,
            create_by,
            remark,
        </trim>
        values
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">
                #{id,jdbcType=INTEGER},
            </if>
            #{customerId,jdbcType=INTEGER},
            #{createTime,jdbcType=TIMESTAMP},
            #{createBy,jdbcType=INTEGER},
            #{remark,jdbcType=VARCHAR},
        </trim>
        on duplicate key update
        <trim suffixOverrides=",">
            <if test="id != null">
                id = #{id,jdbcType=INTEGER},
            </if>
            customer_id = #{customerId,jdbcType=INTEGER},
                    create_time = #{createTime,jdbcType=TIMESTAMP},
                    create_by = #{createBy,jdbcType=INTEGER},
                    remark = #{remark,jdbcType=VARCHAR},
        </trim>
    </insert>
    <insert id="insertOrUpdateSelective" keyColumn="id" keyProperty="id"
            parameterType="com.glsx.model.PlatformAppDownload" useGeneratedKeys="true">
        <!--@mbg.generated-->
        insert into t_platform_app_download
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">
                id,
            </if>
            <if test="customerId != null">
                customer_id,
            </if>
            <if test="createTime != null">
                create_time,
            </if>
            <if test="createBy != null">
                create_by,
            </if>
            <if test="remark != null and remark != ''">
                remark,
            </if>
        </trim>
        values
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">
                #{id,jdbcType=INTEGER},
            </if>
            <if test="customerId != null">
                #{customerId,jdbcType=INTEGER},
            </if>
            <if test="createTime != null">
                #{createTime,jdbcType=TIMESTAMP},
            </if>
            <if test="createBy != null">
                #{createBy,jdbcType=INTEGER},
            </if>
            <if test="remark != null and remark != ''">
                #{remark,jdbcType=VARCHAR},
            </if>
        </trim>
        on duplicate key update
        <trim suffixOverrides=",">
            <if test="id != null">
                id = #{id,jdbcType=INTEGER},
            </if>
            <if test="customerId != null">
                customer_id = #{customerId,jdbcType=INTEGER},
            </if>
            <if test="createTime != null">
                create_time = #{createTime,jdbcType=TIMESTAMP},
            </if>
            <if test="createBy != null">
                create_by = #{createBy,jdbcType=INTEGER},
            </if>
            <if test="remark != null and remark != ''">
                remark = #{remark,jdbcType=VARCHAR},
            </if>
        </trim>
    </insert>
</mapper>