From 952f1b85f97d5dd552340d35de4734cf54d4f626 Mon Sep 17 00:00:00 2001 From: lvxinran Date: Thu, 30 Jul 2020 02:52:05 +0800 Subject: [PATCH] =?UTF-8?q?=E8=81=8A=E5=A4=A9=E4=BF=A1=E6=81=AF=E7=AE=A1?= =?UTF-8?q?=E7=90=86=E5=8A=9F=E8=83=BD=E6=8F=90=E4=BA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../jmfy/controller/ChatInfoController.java | 63 ++++++++++++ .../com/jmfy/controller/LoginController.java | 8 ++ .../com/jmfy/model/vo/ChatRedisEntity.java | 80 +++++++++++++++ src/main/java/com/jmfy/model/vo/PowersVo.java | 9 ++ .../jmfy/redisProperties/RedisUserKey.java | 8 ++ src/main/java/com/jmfy/utils/RedisUtil.java | 10 ++ .../resources/static/html/member-add.html | 3 + src/main/resources/templates/chatInfo.html | 99 +++++++++++++++++++ src/main/resources/templates/index.html | 18 +++- 9 files changed, 295 insertions(+), 3 deletions(-) create mode 100644 src/main/java/com/jmfy/controller/ChatInfoController.java create mode 100644 src/main/java/com/jmfy/model/vo/ChatRedisEntity.java create mode 100644 src/main/resources/templates/chatInfo.html diff --git a/src/main/java/com/jmfy/controller/ChatInfoController.java b/src/main/java/com/jmfy/controller/ChatInfoController.java new file mode 100644 index 0000000..ec2a220 --- /dev/null +++ b/src/main/java/com/jmfy/controller/ChatInfoController.java @@ -0,0 +1,63 @@ +package com.jmfy.controller; + +import com.google.gson.Gson; +import com.jmfy.dao.ServerInfoDao; +import com.jmfy.model.ServerInfo; +import com.jmfy.model.vo.ChatRedisEntity; +import com.jmfy.redisProperties.RedisUserKey; +import com.jmfy.utils.RedisUtil; +import org.springframework.stereotype.Controller; +import org.springframework.ui.ModelMap; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.RequestParam; + +import javax.annotation.Resource; +import java.util.ArrayList; +import java.util.List; + +/** + * @author lvxinran + * @date 2020/7/22 + * @discribe + */ +@Controller +public class ChatInfoController { + + + @Resource + private ServerInfoDao serverInfoDao; + + private static Gson gson = new Gson(); + + @RequestMapping(value = "/chatInfoShow",method = RequestMethod.GET) + public String chatInfoShow(ModelMap map){ + try { + List allServerInfo = serverInfoDao.getAllServerInfo(); + map.addAttribute("serverInfo",allServerInfo); + } catch (Exception e) { + e.printStackTrace(); + } + return "chatInfo"; + + } + @RequestMapping(value = "/chatInfoShowByServerAndChannel",method = RequestMethod.GET) + public String chatInfoShowByServerAndChannel(@RequestParam int serverId,@RequestParam int channelId, ModelMap map){ + RedisUtil redisUtil = RedisUtil.getInstence(); + + String key = RedisUserKey.getKey(RedisUserKey.CHAT_INFO_CACHE, String.valueOf(channelId), serverId); + List list = redisUtil.lGet(key, 0, -1); + + List chatInfoList = new ArrayList<>(list.size()); + for(String str:list){ + ChatRedisEntity chatRedisEntity = gson.fromJson(str, ChatRedisEntity.class); + chatInfoList.add(chatRedisEntity); + } + map.addAttribute("chatInfoList",chatInfoList); + + return "chatInfo::chatInfo"; + } + + +} diff --git a/src/main/java/com/jmfy/controller/LoginController.java b/src/main/java/com/jmfy/controller/LoginController.java index dafe116..eba673d 100644 --- a/src/main/java/com/jmfy/controller/LoginController.java +++ b/src/main/java/com/jmfy/controller/LoginController.java @@ -72,6 +72,7 @@ public class LoginController { powersVo.setShopItemFlow(0); powersVo.setQuestion(0); powersVo.setCheck(0); + powersVo.setChatInfo(0); return; } for (Integer str : powerList) { @@ -111,9 +112,13 @@ public class LoginController { break; case 12: powersVo.setQuestion(0); + break; case 13: powersVo.setCheck(0); break; + case 14: + powersVo.setChatInfo(0); + break; } } @@ -216,6 +221,9 @@ public class LoginController { case 13: powers = "审核"; break; + case 14: + powers = "聊天记录管理"; + break; } if (power.length() == 0) { power = new StringBuilder(powers); diff --git a/src/main/java/com/jmfy/model/vo/ChatRedisEntity.java b/src/main/java/com/jmfy/model/vo/ChatRedisEntity.java new file mode 100644 index 0000000..20b1f6d --- /dev/null +++ b/src/main/java/com/jmfy/model/vo/ChatRedisEntity.java @@ -0,0 +1,80 @@ +package com.jmfy.model.vo; + +/** + * @author lvxinran + * @date 2020/7/22 + * @discribe + */ +public class ChatRedisEntity { + + private int uid; + + private String name; + + private int type; + + private String message; + + private Long time; + + private int status; + + public ChatRedisEntity(){}; + + public ChatRedisEntity(int uid, String name, int type, String message, Long time, int status) { + this.uid = uid; + this.name = name; + this.type = type; + this.message = message; + this.time = time; + this.status = status; + } + + public int getUid() { + return uid; + } + + public void setUid(int uid) { + this.uid = uid; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public int getType() { + return type; + } + + public void setType(int type) { + this.type = type; + } + + public String getMessage() { + return message; + } + + public void setMessage(String message) { + this.message = message; + } + + public Long getTime() { + return time; + } + + public void setTime(Long time) { + this.time = time; + } + + public int getStatus() { + return status; + } + + public void setStatus(int status) { + this.status = status; + } +} diff --git a/src/main/java/com/jmfy/model/vo/PowersVo.java b/src/main/java/com/jmfy/model/vo/PowersVo.java index 9cefe2f..8f769c1 100644 --- a/src/main/java/com/jmfy/model/vo/PowersVo.java +++ b/src/main/java/com/jmfy/model/vo/PowersVo.java @@ -16,6 +16,7 @@ public class PowersVo { public int shopItemFlow =1; public int question =1; public int check =1; + private int chatInfo = 1; public void setAdminList(int adminList) { this.adminList = adminList; } @@ -74,4 +75,12 @@ public class PowersVo { public void setCheck(int check) { this.check = check; } + + public int getChatInfo() { + return chatInfo; + } + + public void setChatInfo(int chatInfo) { + this.chatInfo = chatInfo; + } } diff --git a/src/main/java/com/jmfy/redisProperties/RedisUserKey.java b/src/main/java/com/jmfy/redisProperties/RedisUserKey.java index c31dc05..bd66184 100644 --- a/src/main/java/com/jmfy/redisProperties/RedisUserKey.java +++ b/src/main/java/com/jmfy/redisProperties/RedisUserKey.java @@ -24,6 +24,7 @@ public class RedisUserKey { public static final String NOTICE = "NOTICE"; public static final String AUTOOPENTIME = "AUTOOPENTIME"; + public static final String CHAT_INFO_CACHE = "CHAT_INFO_CACHE";//聊天信息缓存,gm后台使用 /** * 在线人数 updata/min @@ -31,6 +32,13 @@ public class RedisUserKey { public static final String ONLINE_NUM = "ONLINE_NUM"; + public static String getKey(String type, String key, int serverId) { + if (serverId!=0) { + return serverId + Delimiter_colon + type + Delimiter_colon + String.valueOf(key); + } + return type + Delimiter_colon + String.valueOf(key); + + } } diff --git a/src/main/java/com/jmfy/utils/RedisUtil.java b/src/main/java/com/jmfy/utils/RedisUtil.java index 11cd082..b2f6808 100644 --- a/src/main/java/com/jmfy/utils/RedisUtil.java +++ b/src/main/java/com/jmfy/utils/RedisUtil.java @@ -13,6 +13,7 @@ import org.springframework.data.redis.core.ZSetOperations; import redis.clients.jedis.JedisPoolConfig; import java.util.HashMap; +import java.util.List; import java.util.Map; import java.util.Set; import java.util.concurrent.TimeUnit; @@ -310,4 +311,13 @@ public class RedisUtil { } return null; } + + public List lGet(String key, long start, long end) { + try { + return redisObjectTemplate.opsForList().range(key, start, end); + } catch (Exception e) { + e.printStackTrace(); + return null; + } + } } diff --git a/src/main/resources/static/html/member-add.html b/src/main/resources/static/html/member-add.html index d2e6058..42a5188 100644 --- a/src/main/resources/static/html/member-add.html +++ b/src/main/resources/static/html/member-add.html @@ -94,6 +94,9 @@ + diff --git a/src/main/resources/templates/chatInfo.html b/src/main/resources/templates/chatInfo.html new file mode 100644 index 0000000..94ad7ed --- /dev/null +++ b/src/main/resources/templates/chatInfo.html @@ -0,0 +1,99 @@ + + + + + + + + + + + + + + + + + + + 聊天信息查询 + + + +
+

聊天信息查询

+
+
+ 服务器id: +
+ +
+ 频道: +
+
+ +
+
+ + +
+
+ + + + + + + + + + + + + + + + + + + + + + + + +
玩家角色id玩家名称聊天类型聊天内容发送时间状态
+ 可发言 + 被禁言 +
+
+
+ + + + + + + + + + + + \ No newline at end of file diff --git a/src/main/resources/templates/index.html b/src/main/resources/templates/index.html index 635d473..e696801 100644 --- a/src/main/resources/templates/index.html +++ b/src/main/resources/templates/index.html @@ -150,7 +150,7 @@
-
-
-
+
+
+ +
+