From 8d9ee8b1fd6bead3da5db6d7afd6e76b963f2a85 Mon Sep 17 00:00:00 2001 From: Surpriseplus <845948745@qq.com> Date: 星期二, 25 十月 2022 09:10:34 +0800 Subject: [PATCH] 1 --- src/main/java/com/lf/server/service/sys/OperateService.java | 5 + src/main/java/com/lf/server/service/sys/ResService.java | 2 src/main/resources/mapper/sys/OperateMapper.xml | 4 + src/main/java/com/lf/server/service/all/ScheduleService.java | 59 +++++++++++++++++++ src/main/java/com/lf/server/mapper/sys/OperateMapper.java | 8 ++ src/main/java/com/lf/server/config/ScheduleConfig.java | 4 src/main/java/com/lf/server/mapper/sys/ResMapper.java | 3 + src/main/java/com/lf/server/entity/sys/LoginEntity.java | 12 ++++ src/main/java/com/lf/server/mapper/sys/LoginMapper.java | 9 +++ src/main/java/com/lf/server/service/sys/LoginService.java | 9 +++ src/main/resources/mapper/sys/LoginMapper.xml | 5 + src/main/java/com/lf/server/entity/sys/OperateEntity.java | 10 +++ 12 files changed, 128 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/lf/server/config/ScheduleConfig.java b/src/main/java/com/lf/server/config/ScheduleConfig.java index dfab04b..e35b633 100644 --- a/src/main/java/com/lf/server/config/ScheduleConfig.java +++ b/src/main/java/com/lf/server/config/ScheduleConfig.java @@ -69,10 +69,10 @@ jsonObject.put("resUseCount", scheduleService.countResStatus()); // 鐢ㄦ埛鐧诲綍鐘舵�� sys_login - // jsonObject.put("userLoginCount", scheduleService.userLoginCount()); + jsonObject.put("userLoginCount", scheduleService.userLoginCount()); // 璧勬簮鎿嶄綔鐘舵�� sys_operate - // jsonObject.put("operateCount", scheduleService.operateCount()); + jsonObject.put("operateCount", scheduleService.operateCount()); // 璧勬簮璋冪敤鐘舵�� diff --git a/src/main/java/com/lf/server/entity/sys/LoginEntity.java b/src/main/java/com/lf/server/entity/sys/LoginEntity.java index 25599db..5f3ddc7 100644 --- a/src/main/java/com/lf/server/entity/sys/LoginEntity.java +++ b/src/main/java/com/lf/server/entity/sys/LoginEntity.java @@ -30,6 +30,10 @@ private Timestamp optime; + + + private int count; + public int getId() { return id; } @@ -101,4 +105,12 @@ public void setOptime(Timestamp optime) { this.optime = optime; } + + public int getCount() { + return count; + } + + public void setCount(int count) { + this.count = count; + } } diff --git a/src/main/java/com/lf/server/entity/sys/OperateEntity.java b/src/main/java/com/lf/server/entity/sys/OperateEntity.java index 174e1bc..b87aa35 100644 --- a/src/main/java/com/lf/server/entity/sys/OperateEntity.java +++ b/src/main/java/com/lf/server/entity/sys/OperateEntity.java @@ -35,6 +35,8 @@ private String bak; + private int count; + public int getId() { return id; } @@ -130,4 +132,12 @@ public void setBak(String bak) { this.bak = bak; } + + public int getCount() { + return count; + } + + public void setCount(int count) { + this.count = count; + } } diff --git a/src/main/java/com/lf/server/mapper/sys/LoginMapper.java b/src/main/java/com/lf/server/mapper/sys/LoginMapper.java index 3526cdd..197ed25 100644 --- a/src/main/java/com/lf/server/mapper/sys/LoginMapper.java +++ b/src/main/java/com/lf/server/mapper/sys/LoginMapper.java @@ -93,4 +93,13 @@ * @return */ public List<LoginEntity> selectLoginAll(); + + + /** + * 鐢ㄦ埛鐧诲綍鐘舵�� + * + * @return + */ + public List<LoginEntity> selectLoginCounts(); + } diff --git a/src/main/java/com/lf/server/mapper/sys/OperateMapper.java b/src/main/java/com/lf/server/mapper/sys/OperateMapper.java index 3416a26..4f4db6b 100644 --- a/src/main/java/com/lf/server/mapper/sys/OperateMapper.java +++ b/src/main/java/com/lf/server/mapper/sys/OperateMapper.java @@ -92,4 +92,12 @@ */ public List<OperateEntity> selectOperateAll(); + /** + * 鏌ヨ鎵�鏈� + * + * @return + */ + public List<OperateEntity> operateCount(); + + } diff --git a/src/main/java/com/lf/server/mapper/sys/ResMapper.java b/src/main/java/com/lf/server/mapper/sys/ResMapper.java index 43082dd..a334548 100644 --- a/src/main/java/com/lf/server/mapper/sys/ResMapper.java +++ b/src/main/java/com/lf/server/mapper/sys/ResMapper.java @@ -104,4 +104,7 @@ * @return */ public List<ResEntity> selectResAll(); + + + } diff --git a/src/main/java/com/lf/server/service/all/ScheduleService.java b/src/main/java/com/lf/server/service/all/ScheduleService.java index 592514f..03399cc 100644 --- a/src/main/java/com/lf/server/service/all/ScheduleService.java +++ b/src/main/java/com/lf/server/service/all/ScheduleService.java @@ -1,10 +1,14 @@ package com.lf.server.service.all; import com.lf.server.entity.all.RedisCacheKey; +import com.lf.server.entity.sys.LoginEntity; +import com.lf.server.entity.sys.OperateEntity; import com.lf.server.entity.sys.ResEntity; import com.lf.server.entity.sys.UserEntity; import com.lf.server.helper.FileHelper; import com.lf.server.helper.StringHelper; +import com.lf.server.service.sys.LoginService; +import com.lf.server.service.sys.OperateService; import com.lf.server.service.sys.ResService; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -35,6 +39,12 @@ public class ScheduleService { @Autowired private ResService resService; + + @Autowired + private LoginService loginService; + + @Autowired + private OperateService operateService; @Autowired private RedisTemplate<String, Object> redisTemplate; @@ -197,4 +207,53 @@ return jsonObject; } + + /** + * 璧勬簮鎿嶄綔鐘舵�� + * + * @return + */ + + public JSONObject operateCount() { + List<OperateEntity> list = operateService.operateCount(); + JSONObject jsonObject = new JSONObject(); + if (list.isEmpty()) { + return null; + } else { + List<JSONObject> lister = new ArrayList<JSONObject>(); + for (OperateEntity key : list) { + JSONObject map = new JSONObject(); + map.put("count", key.getCount()); + map.put("modular2", key.getModular2()); + lister.add(map); + } + jsonObject.put("operateCount", lister); + return jsonObject; + } + } + + /** + * 鐢ㄦ埛鐧诲綍鐘舵�� + * + * @return + */ + + public JSONObject userLoginCount() { + List<LoginEntity> list = loginService.selectLoginCounts(); + JSONObject jsonObject = new JSONObject(); + if (list.isEmpty()) { + return null; + } else { + List<JSONObject> lister = new ArrayList<JSONObject>(); + for (LoginEntity key : list) { + JSONObject map = new JSONObject(); + map.put("count", key.getCount()); + map.put("optime", key.getOptime()); + lister.add(map); + } + jsonObject.put("userLoginCount", lister); + return jsonObject; + } + } + } diff --git a/src/main/java/com/lf/server/service/sys/LoginService.java b/src/main/java/com/lf/server/service/sys/LoginService.java index 6a5b8e1..666868f 100644 --- a/src/main/java/com/lf/server/service/sys/LoginService.java +++ b/src/main/java/com/lf/server/service/sys/LoginService.java @@ -84,4 +84,13 @@ return le; } + + /** + * 鐢ㄦ埛鐧诲綍鐘舵�� + * @return + */ + @Override + public List<LoginEntity> selectLoginCounts(){ + return loginMapper.selectLoginCounts(); + } } diff --git a/src/main/java/com/lf/server/service/sys/OperateService.java b/src/main/java/com/lf/server/service/sys/OperateService.java index f5a4816..b2a2e74 100644 --- a/src/main/java/com/lf/server/service/sys/OperateService.java +++ b/src/main/java/com/lf/server/service/sys/OperateService.java @@ -67,4 +67,9 @@ public List<OperateEntity> selectOperateAll() { return operateMapper.selectOperateAll(); } + + @Override + public List<OperateEntity> operateCount() { + return operateMapper.operateCount(); + } } diff --git a/src/main/java/com/lf/server/service/sys/ResService.java b/src/main/java/com/lf/server/service/sys/ResService.java index d4f993e..2a75a1a 100644 --- a/src/main/java/com/lf/server/service/sys/ResService.java +++ b/src/main/java/com/lf/server/service/sys/ResService.java @@ -1,5 +1,6 @@ package com.lf.server.service.sys; +import com.lf.server.entity.sys.LoginEntity; import com.lf.server.entity.sys.ResEntity; import com.lf.server.helper.StringHelper; import com.lf.server.mapper.sys.ResMapper; @@ -76,4 +77,5 @@ public List<ResEntity> selectResAll() { return resMapper.selectResAll(); } + } diff --git a/src/main/resources/mapper/sys/LoginMapper.xml b/src/main/resources/mapper/sys/LoginMapper.xml index 29adb60..076fed1 100644 --- a/src/main/resources/mapper/sys/LoginMapper.xml +++ b/src/main/resources/mapper/sys/LoginMapper.xml @@ -83,4 +83,9 @@ <update id="updateLogin"> update lf.sys_login set appid=#{appid},ip=#{ip},type=#{type},status=#{status},descr=#{descr},userid=#{userid},optime=now() where id=#{id} </update> + + <select id="selectLoginCounts" resultType="com.lf.server.entity.sys.LoginEntity"> + select to_char(optime,'yyyy-mm-dd') as optime ,count(*) from lf.sys_login where optime between (select optime - interval '30 day') + and optime group by to_char(optime,'yyyy-mm-dd') order by to_char(optime,'yyyy-mm-dd') desc; + </select> </mapper> \ No newline at end of file diff --git a/src/main/resources/mapper/sys/OperateMapper.xml b/src/main/resources/mapper/sys/OperateMapper.xml index f6786fb..92c98ad 100644 --- a/src/main/resources/mapper/sys/OperateMapper.xml +++ b/src/main/resources/mapper/sys/OperateMapper.xml @@ -78,4 +78,8 @@ <update id="updateOperate"> update lf.sys_operate set modular1=#{modular1},modular2=#{modular2},url=#{url},ip=#{ip},exec=#{exec},clazz=#{clazz},type=#{type},userid=#{userid},optime=now(),bak=#{bak} where id=#{id} </update> + + <select id="operateCount" resultType="com.lf.server.entity.sys.OperateEntity"> + select modular2, count(*) from lf.sys_operate group by modular2 ; + </select> </mapper> \ No newline at end of file -- Gitblit v1.9.3