聊天信息管理功能提交

master
lvxinran 2020-07-30 02:52:05 +08:00
parent 795830bb57
commit 952f1b85f9
9 changed files with 295 additions and 3 deletions

View File

@ -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<ServerInfo> 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<String> list = redisUtil.lGet(key, 0, -1);
List<ChatRedisEntity> 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";
}
}

View File

@ -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);

View File

@ -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;
}
}

View File

@ -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;
}
}

View File

@ -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);
}
}

View File

@ -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<String> lGet(String key, long start, long end) {
try {
return redisObjectTemplate.opsForList().range(key, start, end);
} catch (Exception e) {
e.printStackTrace();
return null;
}
}
}

View File

@ -94,6 +94,9 @@
<label class=""><br>
<input type="checkbox" value="13" name="power" id="user-Character-1-0-13"/>
审核</label>
<label class=""><br>
<input type="checkbox" value="14" name="power" id="user-Character-1-0-14"/>
聊天记录管理</label>
</dd>
</dl>
</dd>

View File

@ -0,0 +1,99 @@
<!DOCTYPE HTML>
<html xmlns:th="http://www.thymeleaf.org">
<head>
<meta charset="utf-8"/>
<meta name="renderer" content="webkit|ie-comp|ie-stand"/>
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"/>
<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no"/>
<meta http-equiv="Cache-Control" content="no-siteapp"/>
<script type="text/javascript" src="lib/html5shiv.js"></script>
<script type="text/javascript" src="lib/respond.min.js"></script>
<![endif]-->
<link rel="stylesheet" type="text/css" href="h-ui/css/H-ui.min.css"/>
<link rel="stylesheet" type="text/css" href="h-ui.admin/css/H-ui.admin.css"/>
<link rel="stylesheet" type="text/css" href="lib/Hui-iconfont/1.0.8/iconfont.css"/>
<link rel="stylesheet" type="text/css" href="h-ui.admin/skin/default/skin.css" id="skin"/>
<link rel="stylesheet" type="text/css" href="h-ui.admin/css/style.css"/>
<script type="text/javascript" src="lib/DD_belatedPNG_0.0.8a-min.js"></script>
<script>DD_belatedPNG.fix('*');</script>
<title>聊天信息查询</title>
</head>
<body>
<nav class="breadcrumb">
<i class="Hui-iconfont">&#xe67f;</i> 首页
<span class="c-gray en">&gt;</span> 聊天信息管理
<span class="c-gray en">&gt;</span> 聊天信息查询
<i class="Hui-iconfont">&#xe68f;</i>
</nav>
<div class="page-container" style="text-align: center">
<h2><span style="color:red;">聊天信息查询</span></h2>
<div style="width: 800px;height: 50px">
<div style="width: 200px; float: left">
<span style="float: left;line-height: 200%">服务器id</span> <select class="select-default" id="serverId" >
<option th:each="server:${serverInfo}" th:value="${server.server_id}" th:text="${server.server_id}"></option>
</select>
</div>
<div style="width: 200px;float: left">
<span style="float: left;line-height: 200%">频道:</span><select class="select-default" id="channel" >
<option value="1">大厅</option>
<option value="2">公会</option>
<option value="3">私聊</option>
</select>
</div>
<div style="float: left;">
<button id="getChatInfo" class="btn btn-success radius r">查找</button>
</div>
</div>
<div class="text-c" id="chatInfo" th:fragment="chatInfo">
<div class="mt-20">
<table class="table table-border table-bordered table-bg table-hover table-sort table-responsive">
<thead>
<tr class="text-c">
<!--<th width="25"><input type="checkbox" name="" value=""/></th>-->
<th width="40">玩家角色id</th>
<th width="60">玩家名称</th>
<th width="60">聊天类型</th>
<th width="100">聊天内容</th>
<th width="80">发送时间</th>
<th width="20">状态</th>
</tr>
</thead>
<tbody>
<tr th:each="obj:${chatInfoList}">
<!--<td><input type="checkbox" value="" name=""/></td>-->
<td th:text="${obj.uid}" style="text-align: center;"></td>
<td th:text="${obj.name}" style="text-align: center;"></td>
<td th:text="${obj.type}" style="text-align: center;"></td>
<td th:text="${obj.message}" style="text-align: center;"></td>
<td th:text="${#dates.format(obj.time,'yyyy-MM-dd HH:mm:ss')}" style="text-align: center;"></td>
<th th:switch="${obj.status}" style="text-align: center;">
<span th:case="0" >可发言</span>
<span th:case="1" >被禁言</span>
</th>
</tr>
</tbody>
</table>
</div>
</div>
<!--_footer 作为公共模版分离出去-->
<script type="text/javascript" src="../static/lib/jquery/1.9.1/jquery.min.js"></script>
<script type="text/javascript" src="lib/layer/2.4/layer.js"></script>
<script type="text/javascript" src="h-ui/js/H-ui.min.js"></script>
<script type="text/javascript" src="h-ui.admin/js/H-ui.admin.js"></script> <!--/_footer 作为公共模版分离出去-->
<!--请在下方写此页面业务相关的脚本-->
<script type="text/javascript" src="lib/My97DatePicker/4.8/WdatePicker.js"></script>
<script type="text/javascript" src="lib/laypage/1.2/laypage.js"></script>
<script type="text/javascript">
$("#getChatInfo").click(function () {
var url = "/chatInfoShowByServerAndChannel?serverId=" + $('#serverId').val()+"&channelId="+$("#channel").val();
$('#chatInfo').load(url);
})
</script>
</body>
</html>

View File

@ -150,7 +150,7 @@
</div>
<div th: th:switch="${powersVo.userInfo}">
<div th:case="0">
<dl id="menu-user">
<dl id="menu-info">
<dt><i class="Hui-iconfont">&#xe62c;</i> 信息管理<i class="Hui-iconfont menu_dropdown-arrow">&#xe6d5;</i></dt>
<dd>
<ul>
@ -162,7 +162,7 @@
</div>
<div th: th:switch="${powersVo.question}">
<div th:case="0">
<dl id="menu-user">
<dl id="menu-question">
<dt><i class="Hui-iconfont">&#xe64f;</i> 问卷管理<i class="Hui-iconfont menu_dropdown-arrow">&#xe6d5;</i></dt>
<dd>
<ul>
@ -176,7 +176,7 @@
</div>
<div th: th:switch="${powersVo.check}">
<div th:case="0">
<dl id="menu-user">
<dl id="menu-check">
<dt><i class="Hui-iconfont">&#xe64f;</i> 审核<i class="Hui-iconfont menu_dropdown-arrow">&#xe6d5;</i></dt>
<dd>
<ul>
@ -187,6 +187,18 @@
</dl>
</div>
</div>
<div th: th:switch="${powersVo.chatInfo}">
<div th:case="0">
<dl id="menu-ChatInfo">
<dt><i class="Hui-iconfont">&#xe64f;</i> 聊天信息管理<i class="Hui-iconfont menu_dropdown-arrow">&#xe6d5;</i></dt>
<dd>
<ul>
<li><a data-href="chatInfoShow" data-title="聊天信息查询" href="javascript:void(0)">聊天信息查询</a></li>
</ul>
</dd>
</dl>
</div>
</div>
</tr>