开服时间展示

master
gaojie 2019-05-13 16:01:10 +08:00
parent 1e0a26a274
commit 9f3e1d5c58
6 changed files with 96 additions and 4 deletions

View File

@ -1,7 +1,15 @@
package com.jmfy.controller;
import ch.qos.logback.core.util.TimeUtil;
import com.jmfy.dao.ServerInfoDao;
import com.jmfy.model.CServerOpenTime;
import com.jmfy.model.ServerInfo;
import com.jmfy.model.vo.ServerInfoVo;
import com.jmfy.redisProperties.GlobalsDef;
import com.jmfy.redisProperties.RedisUserKey;
import com.jmfy.utils.JsonUtil;
import com.jmfy.utils.RedisUtil;
import org.springframework.data.redis.core.TimeoutUtils;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.*;
@ -23,7 +31,23 @@ public class ServerInfoController {
@RequestMapping(value = "/findServerInfo", method = {RequestMethod.POST, RequestMethod.GET})
public String loginVerify(HttpSession session, ModelMap map) throws Exception {
List<ServerInfo> serverInfos = serverInfoDao.getAllServerInfo();
map.addAttribute("serverInfos", serverInfos);
List<ServerInfoVo> serverInfoVos = new ArrayList<>();
for (ServerInfo serverInfo :serverInfos){
ServerInfoVo serverInfoVo = new ServerInfoVo();
serverInfoVo.setServer_id(serverInfo.getServer_id());
serverInfoVo.setName(serverInfo.getName());
serverInfoVo.setStatus(serverInfo.getStatus());
serverInfoVo.setIsWhite(serverInfo.getIsWhite());
CServerOpenTime cServerOpenTime = RedisUtil.getInstence().getObject(RedisUserKey.SERVER_OPEN_TIME_KEY, Integer.toString(serverInfo.getServer_id()),
CServerOpenTime.class, GlobalsDef.REDIS_OVER_TIME);
if (cServerOpenTime !=null){
serverInfoVo.setOpen_time(JsonUtil.timeStamp2Date(String.valueOf(cServerOpenTime.getOpenTime() * 1000)));
}else{
serverInfoVo.setOpen_time(JsonUtil.timeStamp2Date(String.valueOf(serverInfo.getOpen_time() *1000)));
}
serverInfoVos.add(serverInfoVo);
}
map.addAttribute("serverInfos", serverInfoVos);
return "findServerInfo";
}

View File

@ -0,0 +1,31 @@
package com.jmfy.model;
import org.springframework.data.annotation.Id;
import org.springframework.data.mongodb.core.mapping.Document;
import org.springframework.data.mongodb.core.mapping.Field;
@Document(collection="c_server_open_time")
public class CServerOpenTime {
@Id
private int id; // serverId
@Field(value = "openTime")
private int openTime; // 精确到秒的时间戳
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public int getOpenTime() {
return openTime;
}
public void setOpenTime(int openTime) {
this.openTime = openTime;
}
}

View File

@ -0,0 +1,34 @@
package com.jmfy.model.vo;
public class ServerInfoVo{
public int server_id;
public String name;
public String open_time ;
public int status;
public int isWhite;
public void setServer_id(int server_id) {
this.server_id = server_id;
}
public void setName(String name) {
this.name = name;
}
public void setOpen_time(String open_time) {
this.open_time = open_time;
}
public void setStatus(int status) {
this.status = status;
}
public void setIsWhite(int isWhite) {
this.isWhite = isWhite;
}
}

View File

@ -15,6 +15,9 @@ public class RedisUserKey {
public final static String Ban_Chat = "Ban_Chat";
public final static String SERVER_OPEN_TIME_KEY = "Server_Open_Time_Key";
}

View File

@ -55,10 +55,10 @@
<div th: th:switch="${powersVo.adminList}">
<div th:case="0">
<dl id="menu-member">
<dt><i class="Hui-iconfont">&#xe60d;</i> 会员管理<i class="Hui-iconfont menu_dropdown-arrow">&#xe6d5;</i></dt>
<dt><i class="Hui-iconfont">&#xe60d;</i> 用户管理<i class="Hui-iconfont menu_dropdown-arrow">&#xe6d5;</i></dt>
<dd>
<ul>
<li><a data-href="findmemberlist" data-title="会员列表" href="javascript:;">会员列表</a></li>
<li><a data-href="findmemberlist" data-title="会员列表" href="javascript:;">用户列表</a></li>
</ul>
</dd>
</dl>

View File

@ -23,7 +23,7 @@
<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> 用户管理 <a class="btn btn-success radius r" style="line-height:1.6em;margin-top:3px" href="javascript:location.replace(location.href);" title="刷新" ><i class="Hui-iconfont">&#xe68f;</i></a></nav>
<nav class="breadcrumb"><i class="Hui-iconfont">&#xe67f;</i> 首页 <span class="c-gray en">&gt;</span> 用户管理 <span class="c-gray en">&gt;</span> 用户列表 <a class="btn btn-success radius r" style="line-height:1.6em;margin-top:3px" href="javascript:location.replace(location.href);" title="刷新" ><i class="Hui-iconfont">&#xe68f;</i></a></nav>
<div class="page-container">
<div class="cl pd-5 bg-1 bk-gray mt-20">
<a class="btn btn-primary radius" href="/html/member-add.html">