UserDownloadCountLogMapper.xml 4.4 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.lhcredit.project.business.userDownloadCountLog.mapper.UserDownloadCountLogMapper">
    
    <resultMap type="UserDownloadCountLog" id="UserDownloadCountLogResult">
        <result property="id"    column="id"    />
        <result property="userId"    column="user_id"    />
        <result property="userName"    column="user_name"    />
        <result property="enterpriseName"    column="enterprise_name"    />
        <result property="type"    column="type"    />
        <result property="uri"    column="uri"    />
        <result property="createTime"    column="create_time"    />
    </resultMap>
	
	<sql id="selectUserDownloadCountLogVo">
        select id, user_id, user_name, enterprise_name, type, uri, create_time from user_download_count_log
    </sql>
	
    <select id="selectUserDownloadCountLogList" parameterType="UserDownloadCountLog" resultMap="UserDownloadCountLogResult">
        <include refid="selectUserDownloadCountLogVo"/>
        <where>  
            <if test="id != null "> and id = #{id}</if>
            <if test="userId != null "> and user_id = #{userId}</if>
            <if test="userName != null  and userName != '' "> and user_name = #{userName}</if>
            <if test="enterpriseName != null  and enterpriseName != '' "> and enterprise_name = #{enterpriseName}</if>
            <if test="type != null  and type != '' "> and type = #{type}</if>
            <if test="uri != null  and uri != '' "> and uri = #{uri}</if>
            <if test="createTime != null "> and create_time = #{createTime}</if>
        </where>
    </select>
    
    <select id="selectUserDownloadCountLogById" parameterType="Integer" resultMap="UserDownloadCountLogResult">
        <include refid="selectUserDownloadCountLogVo"/>
        where id = #{id}
    </select>

    <select id="getUserSFAssitDataNum" parameterType="Long" resultType="UserDownloadCountLog">
        SELECT
            COUNT( id ) AS 'sfAssistNum'
        FROM
            user_download_count_log
        WHERE
            type = "SF"
        AND user_id = #{userId}
        GROUP BY
            user_id
    </select>
        
    <insert id="insertUserDownloadCountLog" parameterType="UserDownloadCountLog" useGeneratedKeys="true" keyProperty="id">
        insert into user_download_count_log
		<trim prefix="(" suffix=")" suffixOverrides=",">
			<if test="userId != null  ">user_id,</if>
			<if test="userName != null  and userName != ''  ">user_name,</if>
			<if test="enterpriseName != null  and enterpriseName != ''  ">enterprise_name,</if>
			<if test="type != null  and type != ''  ">type,</if>
			<if test="uri != null  and uri != ''  ">uri,</if>
			<if test="createTime != null  ">create_time,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
			<if test="userId != null  ">#{userId},</if>
			<if test="userName != null  and userName != ''  ">#{userName},</if>
			<if test="enterpriseName != null  and enterpriseName != ''  ">#{enterpriseName},</if>
			<if test="type != null  and type != ''  ">#{type},</if>
			<if test="uri != null  and uri != ''  ">#{uri},</if>
			<if test="createTime != null  ">#{createTime},</if>
         </trim>
    </insert>
	 
    <update id="updateUserDownloadCountLog" parameterType="UserDownloadCountLog">
        update user_download_count_log
        <trim prefix="SET" suffixOverrides=",">
            <if test="userId != null  ">user_id = #{userId},</if>
            <if test="userName != null  and userName != ''  ">user_name = #{userName},</if>
            <if test="enterpriseName != null  and enterpriseName != ''  ">enterprise_name = #{enterpriseName},</if>
            <if test="type != null  and type != ''  ">type = #{type},</if>
            <if test="uri != null  and uri != ''  ">uri = #{uri},</if>
            <if test="createTime != null  ">create_time = #{createTime},</if>
        </trim>
        where id = #{id}
    </update>

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