<?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.tievd.cube.modules.system.mapper.SysLogMapper">
|
|
<!-- 清空所有日志记录 -->
|
<delete id="removeAll">
|
DELETE FROM sys_log
|
</delete>
|
|
<!-- 获取访问总数 -->
|
<select id="findTotalVisitCount" resultType="long">
|
select count(1) from sys_log where log_type = 1
|
</select>
|
|
<!-- 获取今日访问总数 -->
|
<select id="findTodayVisitCount" resultType="long">
|
select count(1) from sys_log where log_type = 1 and create_time >= #{dayStart} and create_time < #{dayEnd}
|
</select>
|
|
<!-- 获取今日访问总IP数 -->
|
<select id="findTodayIp" resultType="long">
|
select count(distinct(ip)) from sys_log where log_type = 1 and create_time >= #{dayStart} and create_time < #{dayEnd}
|
</select>
|
|
<!-- 首页访问统计 -->
|
<select id="findVisitCount" resultType="com.tievd.cube.modules.system.model.api.response.VisitsInfo">
|
<if test="dbType == 'MYSQL'">
|
select count(*) as visit
|
,count(distinct(ip)) as ip
|
,DATE_FORMAT(create_time, '%Y-%m-%d') as tian
|
,DATE_FORMAT(create_time, '%m-%d') as type
|
from sys_log
|
where log_type = 1 and create_time >= #{dayStart} and create_time < #{dayEnd}
|
group by tian,type
|
order by tian asc
|
</if>
|
<if test="dbType == 'ORACLE'">
|
select count(*) as visit
|
,count(distinct(ip)) as ip
|
,to_char(create_time, 'yyyy-mm-dd') as tian
|
,to_char(create_time, 'mm-dd') as type
|
from sys_log
|
where log_type = 1 and create_time >= #{dayStart} and create_time < #{dayEnd}
|
group by to_char(create_time, 'yyyy-mm-dd'),to_char(create_time, 'mm-dd')
|
order by to_char(create_time, 'yyyy-mm-dd') asc
|
</if>
|
<if test="dbType == 'POSTGRESQL'">
|
select count(*) as visit
|
,count(distinct(ip)) as ip
|
,to_char(create_time, 'yyyy-mm-dd') as tian
|
,to_char(create_time, 'mm-dd') as type
|
from sys_log
|
where log_type = 1 and create_time >= #{dayStart} and create_time < #{dayEnd}
|
group by tian,type
|
order by tian asc
|
</if>
|
<if test="dbType == 'SQLSERVER'">
|
select count(*) as visit
|
,count(distinct(ip)) as ip
|
,CONVERT(varchar(100), create_time, 23) as tian
|
,RIGHT(CONVERT(varchar(100), create_time, 23),5) as type
|
from sys_log
|
where log_type = 1 and create_time >= #{dayStart} and create_time < #{dayEnd}
|
group by CONVERT(varchar(100), create_time, 23),RIGHT(CONVERT(varchar(100), create_time, 23),5)
|
order by CONVERT(varchar(100), create_time, 23) asc
|
</if>
|
</select>
|
|
<!-- 保存日志11 -->
|
<insert id="saveLog" parameterType="Object">
|
insert into sys_log (id, log_type, log_content, method, operate_type, request_param, ip, userid, username, cost_time, create_time)
|
values(
|
#{dto.id,jdbcType=VARCHAR},
|
#{dto.logType,jdbcType=INTEGER},
|
#{dto.logContent,jdbcType=VARCHAR},
|
#{dto.method,jdbcType=VARCHAR},
|
#{dto.operateType,jdbcType=INTEGER},
|
#{dto.requestParam,jdbcType=VARCHAR},
|
#{dto.ip,jdbcType=VARCHAR},
|
#{dto.userid,jdbcType=VARCHAR},
|
#{dto.username,jdbcType=VARCHAR},
|
#{dto.costTime,jdbcType=BIGINT},
|
#{dto.createTime,jdbcType=TIMESTAMP}
|
)
|
</insert>
|
</mapper>
|