generated from root/miduo_server
服务器显示开服时间
parent
e281f53710
commit
9129747f5b
|
|
@ -33,8 +33,14 @@ public class ServerInfoController {
|
|||
@Resource
|
||||
private SeqUtils seqUtils;
|
||||
|
||||
/**
|
||||
* 服务器信息界面
|
||||
* @param map
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
@RequestMapping(value = "/findServerInfo", method = {RequestMethod.POST, RequestMethod.GET})
|
||||
public String loginVerify(HttpSession session, ModelMap map) throws Exception {
|
||||
public String loginVerify(ModelMap map) throws Exception {
|
||||
List<ServerInfo> serverInfos = serverInfoDao.getAllServerInfo();
|
||||
List<ServerInfoVo> serverInfoVos = new ArrayList<>();
|
||||
for (ServerInfo serverInfo : serverInfos) {
|
||||
|
|
@ -42,7 +48,7 @@ public class ServerInfoController {
|
|||
continue;
|
||||
}
|
||||
ServerInfoVo serverInfoVo = new ServerInfoVo();
|
||||
serverInfoVo.setServer_id(String.valueOf(serverInfo.getServer_id()));
|
||||
serverInfoVo.setServer_id(serverInfo.getServer_id());
|
||||
serverInfoVo.setName(serverInfo.getName());
|
||||
serverInfoVo.setStatus(Integer.valueOf(serverInfo.getStatus()));
|
||||
if(serverInfo.getIs_new()!=null){
|
||||
|
|
@ -71,19 +77,17 @@ public class ServerInfoController {
|
|||
|
||||
/**
|
||||
* 编辑服务器
|
||||
*
|
||||
* @param session
|
||||
* @param map
|
||||
* @param id
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
@RequestMapping(value = "/toServerInfoEdit", method = {RequestMethod.POST, RequestMethod.GET})
|
||||
public String toServerInfoEdit(HttpSession session, ModelMap map, int id) throws Exception {
|
||||
public String toServerInfoEdit(ModelMap map, int id) throws Exception {
|
||||
ServerInfo serverInfo = serverInfoDao.getServerinfo(String.valueOf(id));
|
||||
|
||||
if(serverInfo.getOpen_type()!=null&&serverInfo.getOpen_type().equals(Constants.SERVEROPEN_TIME)&&serverInfo.getStatus().equals(Constants.SERVERSTATE_UNSTART)){
|
||||
String openT = RedisUtil.getInstence().getObject(String.valueOf(serverInfo.getServer_id()) + RedisUserKey.Delimiter_colon + RedisUserKey.AUTOOPENTIME, "", String.class, -1);
|
||||
String openT = RedisUtil.getInstence().getObject(serverInfo.getServer_id() + RedisUserKey.Delimiter_colon + RedisUserKey.AUTOOPENTIME, "", String.class, -1);
|
||||
if(null!= openT){
|
||||
serverInfo.setOpen_time("(等待启动)"+openT);
|
||||
}
|
||||
|
|
@ -99,20 +103,33 @@ public class ServerInfoController {
|
|||
return "serverInfoEdit";
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改服务器信息
|
||||
* @param map
|
||||
* @param request
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
@RequestMapping(value = "/serverEdit", method = {RequestMethod.POST, RequestMethod.GET})
|
||||
public String toServerInfoEdit(HttpSession session, ModelMap map, HttpServletRequest request) throws Exception {
|
||||
public String toServerInfoEdit(ModelMap map, HttpServletRequest request) throws Exception {
|
||||
List<ServerInfoVo> serverInfoVos = new ArrayList<>();
|
||||
// 服务器状态
|
||||
int status = Integer.parseInt(request.getParameter("status"));
|
||||
// 名字
|
||||
String name = request.getParameter("name");
|
||||
// 服务器id
|
||||
String server_id = request.getParameter("server_id");
|
||||
// 新服
|
||||
int isnew = Integer.parseInt(request.getParameter("is_new"));
|
||||
// 开启时间
|
||||
String opentime = request.getParameter("startTime");
|
||||
// 注册状态
|
||||
String register_state = request.getParameter("register_state");
|
||||
System.out.println(register_state);
|
||||
|
||||
serverInfoDao.updateServerInfo(server_id, status, 0, isnew, name,register_state);
|
||||
if(status==-1){
|
||||
//自动开服修改开服时间
|
||||
RedisUtil.getInstence().putObject(String.valueOf(server_id) + RedisUserKey.Delimiter_colon + RedisUserKey.AUTOOPENTIME, "", opentime, -1);
|
||||
RedisUtil.getInstence().putObject(server_id + RedisUserKey.Delimiter_colon + RedisUserKey.AUTOOPENTIME, "", opentime, -1);
|
||||
}else {
|
||||
CServerOpenTime cServerOpenTime = serverInfoDao.getOpenServerTime(server_id);
|
||||
if (null != cServerOpenTime) {
|
||||
|
|
@ -136,8 +153,15 @@ public class ServerInfoController {
|
|||
map.addAttribute("serverInfos", serverInfoVos);
|
||||
return "findServerInfo";
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量修改服务器状态
|
||||
* @param request
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
@RequestMapping(value = "/serverListEdit", method = {RequestMethod.POST, RequestMethod.GET})
|
||||
public @ResponseBody int toServerListEdit(HttpSession session, ModelMap map, HttpServletRequest request) throws Exception {
|
||||
public @ResponseBody int toServerListEdit(HttpServletRequest request) throws Exception {
|
||||
int status = Integer.parseInt(request.getParameter("status"));
|
||||
String[] serverId = request.getParameterValues("serverId[]");
|
||||
for (String str:serverId){
|
||||
|
|
@ -145,6 +169,7 @@ public class ServerInfoController {
|
|||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/serverNumberInfo", method = {RequestMethod.POST, RequestMethod.GET})
|
||||
public String serverNumberInfo(HttpSession session, ModelMap map) throws Exception {
|
||||
List<ServerInfo> serverInfos = serverInfoDao.getAllServerInfo();
|
||||
|
|
@ -156,7 +181,7 @@ public class ServerInfoController {
|
|||
continue;
|
||||
}
|
||||
ServerInfoVo serverInfoVo = new ServerInfoVo();
|
||||
serverInfoVo.setServer_id(String.valueOf(serverInfo.getServer_id()));
|
||||
serverInfoVo.setServer_id(serverInfo.getServer_id());
|
||||
long registerNum = serverInfoDao.getRegisterNum(serverInfo.getServer_id());
|
||||
totalRegisterNum += registerNum;
|
||||
serverInfoVo.setRegisterNum(registerNum);
|
||||
|
|
|
|||
|
|
@ -134,14 +134,9 @@ public class ServerInfoDaoImpl implements ServerInfoDao {
|
|||
|
||||
@Override
|
||||
public CServerOpenTime getOpenServerTime(String serverId) throws Exception {
|
||||
try {
|
||||
MongoTemplate mongoTemplate = connect.getMongoTemplete(dbName);
|
||||
CServerOpenTime cServerOpenTime = mongoTemplate.findById(1, CServerOpenTime.class);
|
||||
return cServerOpenTime;
|
||||
}catch (Exception e){
|
||||
|
||||
}
|
||||
return null;
|
||||
String dbNames = MongoName.getMongoDBName(Integer.valueOf(serverId));
|
||||
MongoTemplate mongoTemplate = connect.getMongoTemplete(dbNames);
|
||||
return mongoTemplate.findById(1, CServerOpenTime.class);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -55,6 +55,9 @@ public class ServerInfo {
|
|||
@Field(value = "register_state")
|
||||
private String register_state;
|
||||
|
||||
@Field(value = "coreName")
|
||||
private String coreName;
|
||||
|
||||
public ServerInfo(int _id, String name) {
|
||||
this._id = _id;
|
||||
this.server_id = String.valueOf(_id);
|
||||
|
|
@ -161,6 +164,14 @@ public class ServerInfo {
|
|||
|
||||
public void setRegister_state(String register_state) { this.register_state = register_state; }
|
||||
|
||||
public String getCoreName() {
|
||||
return coreName;
|
||||
}
|
||||
|
||||
public void setCoreName(String coreName) {
|
||||
this.coreName = coreName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "ServerInfo{" +
|
||||
|
|
|
|||
|
|
@ -77,6 +77,10 @@
|
|||
<option th:value="3">拥挤</option>
|
||||
<option th:value="4">爆满</option>
|
||||
<option th:value="5">自动</option>
|
||||
<option th:value="6">
|
||||
未运营
|
||||
<span style="color: red">(谨慎修改此状态,可能会导致数据丢失)</span>
|
||||
</option>
|
||||
</div>
|
||||
</select>
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue