tool-tech/tool-tech-admin/src/main/resources/mapper/DownloadCountMapper.xml
pan f90c8e0c6f 1、新增文档和工具统计
2、样式调整
3、文件下载分页(还有一部分没有调整)
2024-09-05 22:36:07 +08:00

157 lines
7.4 KiB
XML

<?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.rzdata.web.mapper.DownloadCountMapper">
<resultMap type="DownloadCount" id="DownloadCountResult">
<result property="id" column="id" />
<result property="businessId" column="business_id" />
<result property="businessType" column="business_type" />
<result property="attId" column="att_id" />
<result property="attName" column="att_name" />
<result property="createBy" column="create_by" />
<result property="createById" column="create_by_id" />
<result property="createTime" column="create_time" />
<result property="updateBy" column="update_by" />
<result property="updateById" column="update_by_id" />
<result property="updateTime" column="update_time" />
<result property="toolCode" column="tool_code" />
<result property="toolName" column="tool_name" />
<result property="toolDownNum" column="tool_down_num" />
<result property="docCode" column="doc_code" />
<result property="docName" column="doc_name" />
<result property="docDownNum" column="doc_down_num" />
<result property="nickName" column="nick_name" />
</resultMap>
<sql id="selectDownloadCountVo">
select id, business_id,business_type,att_id,att_name
create_by, create_by_id, create_time, update_by, update_by_id, update_time from t_download_count
</sql>
<select id="selectDownloadCountList" parameterType="DownloadCount" resultMap="DownloadCountResult">
select
tdc.business_id,tl.tool_code,tl.tool_name,sum(1) as tool_down_num
from t_download_count tdc
left join t_tool tl on tdc.business_id = tl.tool_id
<where>
and business_type = 'tool'
<if test="params.beginTime != null and params.beginTime != ''"><!-- 开始时间检索 -->
AND date_format(tdc.create_time,'%y%m%d') &gt;= date_format(#{params.beginTime},'%y%m%d')
</if>
<if test="params.endTime != null and params.endTime != ''"><!-- 结束时间检索 -->
AND date_format(tdc.create_time,'%y%m%d') &lt;= date_format(#{params.endTime},'%y%m%d')
</if>
<if test="toolCode != null and toolCode != ''">
AND tl.tool_code like concat('%', #{toolCode}, '%')
</if>
<if test="toolName != null and toolName != ''">
AND tl.tool_name like concat('%', #{toolName}, '%')
</if>
</where>
group by tdc.business_id,tl.tool_code,tl.tool_name
</select>
<select id="selectDownloadCountById" parameterType="String" resultMap="DownloadCountResult">
<include refid="selectDownloadCountVo"/>
where id = #{id}
</select>
<insert id="insertDownloadCount" parameterType="DownloadCount">
insert into t_download_count
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="id != null">id,</if>
<if test="businessId != null">business_id,</if>
<if test="businessType != null">business_type,</if>
<if test="attId != null">att_id,</if>
<if test="attName != null">att_name,</if>
<if test="createBy != null">create_by,</if>
<if test="createById != null">create_by_id,</if>
<if test="createTime != null">create_time,</if>
<if test="updateBy != null">update_by,</if>
<if test="updateById != null">update_by_id,</if>
<if test="updateTime != null">update_time,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="id != null">#{id},</if>
<if test="businessId != null">#{businessId},</if>
<if test="businessType != null">#{businessType},</if>
<if test="attId != null">#{attId},</if>
<if test="attName != null">#{attName},</if>
<if test="createBy != null">#{createBy},</if>
<if test="createById != null">#{createById},</if>
<if test="createTime != null">#{createTime},</if>
<if test="updateBy != null">#{updateBy},</if>
<if test="updateById != null">#{updateById},</if>
<if test="updateTime != null">#{updateTime},</if>
</trim>
</insert>
<update id="updateDownloadCount" parameterType="DownloadCount">
update t_download_count
<trim prefix="SET" suffixOverrides=",">
<if test="businessId != null">business_id = #{businessId},</if>
<if test="businessType != null">business_type = #{businessType},</if>
<if test="attId != null">att_id = #{attId},</if>
<if test="attName != null">att_name = #{attName},</if>
<if test="createBy != null">create_by = #{createBy},</if>
<if test="createById != null">create_by_id = #{createById},</if>
<if test="createTime != null">create_time = #{createTime},</if>
<if test="updateBy != null">update_by = #{updateBy},</if>
<if test="updateById != null">update_by_id = #{updateById},</if>
<if test="updateTime != null">update_time = #{updateTime},</if>
</trim>
where id = #{id}
</update>
<delete id="deleteDownloadCountById" parameterType="String">
delete from t_download_count where id = #{id}
</delete>
<delete id="deleteDownloadCountByIds" parameterType="String">
delete from t_download_count where id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
</delete>
<select id="userDownList" parameterType="DownloadCount" resultMap="DownloadCountResult">
select
tdc.business_id,tdc.att_name,su.nick_name,tdc.create_time,sum(1) as tool_down_num
from t_download_count tdc
left join sys_user su on tdc.create_by_id = su.user_id
<where>
<if test="businessId != null and businessId != ''">
AND business_id = #{businessId}
</if>
</where>
group by su.nick_name,tdc.business_id,tdc.att_name
</select>
<select id="selectDownloadDocCountList" parameterType="DownloadCount" resultMap="DownloadCountResult">
select
tdc.business_id,tl.doc_code,tl.doc_name,sum(1) as doc_down_num
from t_download_count tdc
left join t_document tl on tdc.business_id = tl.doc_id
<where>
and business_type = 'doc'
<if test="params.beginTime != null and params.beginTime != ''"><!-- 开始时间检索 -->
AND date_format(tdc.create_time,'%y%m%d') &gt;= date_format(#{params.beginTime},'%y%m%d')
</if>
<if test="params.endTime != null and params.endTime != ''"><!-- 结束时间检索 -->
AND date_format(tdc.create_time,'%y%m%d') &lt;= date_format(#{params.endTime},'%y%m%d')
</if>
<if test="docCode != null and docCode != ''">
AND tl.doc_code like concat('%', #{docCode}, '%')
</if>
<if test="docName != null and docName != ''">
AND tl.doc_name like concat('%', #{docName}, '%')
</if>
</where>
group by tdc.business_id,tl.doc_code,tl.doc_name
</select>
</mapper>