优化
This commit is contained in:
@@ -41,115 +41,4 @@
|
||||
${ew.customSqlSegment}
|
||||
</select>
|
||||
|
||||
<select id="selectDashboardOverviewPv" resultType="top.wms.admin.system.model.resp.dashboard.DashboardOverviewCommonResp">
|
||||
SELECT
|
||||
(SELECT COUNT(*) FROM sys_log) AS total,
|
||||
(SELECT COUNT(*) FROM sys_log WHERE create_time >= CURDATE() AND create_time < DATE_ADD(CURDATE(), INTERVAL 1 DAY)) AS today,
|
||||
(SELECT COUNT(*) FROM sys_log WHERE create_time >= DATE_SUB(CURDATE(), INTERVAL 1 DAY) AND create_time < CURDATE()) AS yesterday
|
||||
</select>
|
||||
|
||||
<select id="selectDashboardOverviewIp" resultType="top.wms.admin.system.model.resp.dashboard.DashboardOverviewCommonResp">
|
||||
SELECT
|
||||
(SELECT COUNT(DISTINCT ip) FROM sys_log) AS total,
|
||||
(SELECT COUNT(DISTINCT ip) FROM sys_log WHERE create_time >= CURDATE() AND create_time < DATE_ADD(CURDATE(), INTERVAL 1 DAY)) AS today,
|
||||
(SELECT COUNT(DISTINCT ip) FROM sys_log WHERE create_time >= DATE_SUB(CURDATE(), INTERVAL 1 DAY) AND create_time < CURDATE()) AS yesterday
|
||||
</select>
|
||||
|
||||
<select id="selectListDashboardAnalysisPv"
|
||||
resultType="top.wms.admin.system.model.resp.dashboard.DashboardChartCommonResp">
|
||||
SELECT
|
||||
DATE_FORMAT(create_time, '%Y-%m') AS name,
|
||||
COUNT(*) AS value
|
||||
FROM sys_log
|
||||
WHERE DATE_FORMAT(create_time, '%Y-%m' ) IN
|
||||
<foreach collection="months" item="month" separator="," open="(" close=")">
|
||||
#{month}
|
||||
</foreach>
|
||||
GROUP BY name
|
||||
ORDER BY name
|
||||
</select>
|
||||
|
||||
<select id="selectListDashboardAnalysisIp"
|
||||
resultType="top.wms.admin.system.model.resp.dashboard.DashboardChartCommonResp">
|
||||
SELECT
|
||||
DATE_FORMAT(create_time, '%Y-%m') AS name,
|
||||
COUNT(DISTINCT ip) AS value
|
||||
FROM sys_log
|
||||
WHERE DATE_FORMAT(create_time, '%Y-%m' ) IN
|
||||
<foreach collection="months" item="month" separator="," open="(" close=")">
|
||||
#{month}
|
||||
</foreach>
|
||||
GROUP BY name
|
||||
ORDER BY name
|
||||
</select>
|
||||
|
||||
<select id="selectListDashboardAnalysisGeo" resultType="top.wms.admin.system.model.resp.dashboard.DashboardChartCommonResp">
|
||||
SELECT
|
||||
CASE
|
||||
WHEN POSITION(' ' IN address) > 0 THEN SUBSTRING(address FROM 1 FOR POSITION(' ' IN address) - 1)
|
||||
ELSE address
|
||||
END AS name,
|
||||
COUNT(*) AS value
|
||||
FROM sys_log
|
||||
WHERE address LIKE '中国%'
|
||||
GROUP BY name
|
||||
</select>
|
||||
|
||||
<select id="selectListDashboardAccessTrend"
|
||||
resultType="top.wms.admin.system.model.resp.dashboard.DashboardAccessTrendResp">
|
||||
SELECT
|
||||
DATE(create_time) AS date,
|
||||
COUNT(*) AS pvCount,
|
||||
COUNT(DISTINCT ip) AS ipCount
|
||||
FROM sys_log
|
||||
WHERE create_time BETWEEN #{startTime} AND #{endTime}
|
||||
GROUP BY date
|
||||
ORDER BY date
|
||||
</select>
|
||||
|
||||
<select id="selectListDashboardAnalysisTimeslot"
|
||||
resultType="top.wms.admin.system.model.resp.dashboard.DashboardChartCommonResp">
|
||||
SELECT
|
||||
LPAD(CONCAT(FLOOR(HOUR(create_time) / 2) * 2, ':00'), 5, '0') AS name,
|
||||
COUNT(*) AS value
|
||||
FROM sys_log
|
||||
GROUP BY name
|
||||
ORDER BY name
|
||||
</select>
|
||||
|
||||
<select id="selectListDashboardAnalysisModule"
|
||||
resultType="top.wms.admin.system.model.resp.dashboard.DashboardChartCommonResp">
|
||||
SELECT
|
||||
module AS name,
|
||||
COUNT(*) AS value
|
||||
FROM sys_log
|
||||
WHERE module != '验证码' AND module != '登录'
|
||||
GROUP BY name
|
||||
ORDER BY value DESC
|
||||
LIMIT #{top}
|
||||
</select>
|
||||
|
||||
<select id="selectListDashboardAnalysisOs"
|
||||
resultType="top.wms.admin.system.model.resp.dashboard.DashboardChartCommonResp">
|
||||
SELECT
|
||||
os AS name,
|
||||
COUNT(*) AS value
|
||||
FROM sys_log
|
||||
WHERE os IS NOT NULL
|
||||
GROUP BY name
|
||||
ORDER BY value DESC
|
||||
LIMIT #{top}
|
||||
</select>
|
||||
|
||||
<select id="selectListDashboardAnalysisBrowser"
|
||||
resultType="top.wms.admin.system.model.resp.dashboard.DashboardChartCommonResp">
|
||||
SELECT
|
||||
SUBSTRING_INDEX(browser, ' ', 1) AS name,
|
||||
COUNT(*) AS value
|
||||
FROM sys_log
|
||||
WHERE browser IS NOT NULL
|
||||
GROUP BY name
|
||||
ORDER BY value DESC
|
||||
LIMIT #{top}
|
||||
</select>
|
||||
</mapper>
|
||||
|
||||
@@ -1,14 +0,0 @@
|
||||
<?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="top.wms.admin.system.mapper.MessageMapper">
|
||||
<select id="selectPageByUserId" resultType="top.wms.admin.system.model.resp.message.MessageResp">
|
||||
SELECT
|
||||
t1.*,
|
||||
t2.user_id,
|
||||
t2.is_read,
|
||||
t2.read_time
|
||||
FROM sys_message AS t1
|
||||
LEFT JOIN sys_message_user AS t2 ON t2.message_id = t1.id
|
||||
${ew.getCustomSqlSegment}
|
||||
</select>
|
||||
</mapper>
|
||||
@@ -1,14 +0,0 @@
|
||||
<?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="top.wms.admin.system.mapper.MessageUserMapper">
|
||||
<select id="selectUnreadCountByUserIdAndType" resultType="Long">
|
||||
SELECT
|
||||
COUNT(t1.message_id)
|
||||
FROM sys_message_user AS t1
|
||||
LEFT JOIN sys_message AS t2 ON t2.id = t1.message_id
|
||||
WHERE t1.user_id = #{userId} AND t1.is_read = false
|
||||
<if test="type != null">
|
||||
AND t2.type = #{type}
|
||||
</if>
|
||||
</select>
|
||||
</mapper>
|
||||
@@ -1,18 +0,0 @@
|
||||
<?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="top.wms.admin.system.mapper.NoticeMapper">
|
||||
|
||||
<select id="selectDashboardList"
|
||||
resultType="top.wms.admin.system.model.resp.dashboard.DashboardNoticeResp">
|
||||
SELECT
|
||||
id, title, type
|
||||
FROM sys_notice
|
||||
WHERE (effective_time IS NULL OR NOW() > effective_time)
|
||||
AND (terminate_time IS NULL OR terminate_time > NOW())
|
||||
<if test="userId != null">
|
||||
AND (notice_scope = 1 OR (notice_scope = 2 AND JSON_EXTRACT(notice_users, "$[0]") = CAST(#{userId} AS CHAR)))
|
||||
</if>
|
||||
ORDER BY sort ASC, effective_time DESC
|
||||
LIMIT 5
|
||||
</select>
|
||||
</mapper>
|
||||
Reference in New Issue
Block a user