diff --git a/src/main/java/com/jmfy/controller/LoginController.java b/src/main/java/com/jmfy/controller/LoginController.java index dff2b27..734e420 100644 --- a/src/main/java/com/jmfy/controller/LoginController.java +++ b/src/main/java/com/jmfy/controller/LoginController.java @@ -3,10 +3,12 @@ package com.jmfy.controller; import com.jmfy.WebSecurityConfig; import com.jmfy.dao.CUserDao; import com.jmfy.dao.ChannelInfoDao; +import com.jmfy.dao.GlobalSettingDao; import com.jmfy.dao.ServerInfoDao; import com.jmfy.dao.impl.ServerInfoDaoImpl; import com.jmfy.handler.RedisLogic; import com.jmfy.model.CAdmin; +import com.jmfy.model.CGlobalSetting; import com.jmfy.model.ChannelInfo; import com.jmfy.model.ServerInfo; import com.jmfy.model.vo.IdentityEnum; @@ -46,6 +48,8 @@ public class LoginController { private ChannelInfoDao channelInfoDao; @Resource private ServerInfoDao serverInfoDao; + @Resource + private GlobalSettingDao settingDao; static final String ROOT = "root"; @@ -115,7 +119,8 @@ public class LoginController { } @GetMapping("/") - public String index(){ + public String index(ModelMap map) throws Exception { + map.put("title", getTitle()); return "index"; } @@ -161,6 +166,7 @@ public class LoginController { session.setAttribute(WebSecurityConfig.SESSION_KEY, userName); map.put("admin",admin); map.put("sidebar",PowersVo.create2(admin.getPowers())); + map.put("title", getTitle()); return "index"; } else { return "redirect:/login"; @@ -178,6 +184,26 @@ public class LoginController { return "redirect:/login"; } + @RequestMapping(value = "/setTitle", method = {RequestMethod.POST, RequestMethod.GET}) + public @ResponseBody int setTitle(HttpServletRequest request) throws Exception { + String title = request.getParameter("title1"); + CGlobalSetting setting = settingDao.getGlobalSetting(); + if (setting == null){ + setting = new CGlobalSetting(); + } + setting.setTitle(title); + settingDao.uporsetGlobalSetting(setting); + return 1; + } + + public String getTitle() throws Exception { + CGlobalSetting setting = settingDao.getGlobalSetting(); + if (setting == null){ + return "admin"; + } + return setting.getTitle(); + } + /** * root账号特殊处理,登陆或注册获取全部权限 * @param admin diff --git a/src/main/java/com/jmfy/dao/GlobalSettingDao.java b/src/main/java/com/jmfy/dao/GlobalSettingDao.java new file mode 100644 index 0000000..5178945 --- /dev/null +++ b/src/main/java/com/jmfy/dao/GlobalSettingDao.java @@ -0,0 +1,8 @@ +package com.jmfy.dao; + +import com.jmfy.model.CGlobalSetting; + +public interface GlobalSettingDao { + CGlobalSetting getGlobalSetting() throws Exception; + void uporsetGlobalSetting(CGlobalSetting setting) throws Exception; +} diff --git a/src/main/java/com/jmfy/dao/impl/GlobalSettingDaoImpl.java b/src/main/java/com/jmfy/dao/impl/GlobalSettingDaoImpl.java new file mode 100644 index 0000000..edf2534 --- /dev/null +++ b/src/main/java/com/jmfy/dao/impl/GlobalSettingDaoImpl.java @@ -0,0 +1,42 @@ +package com.jmfy.dao.impl; + +import com.jmfy.dao.GlobalSettingDao; +import com.jmfy.model.CGlobalSetting; +import com.jmfy.model.Constant; +import com.jmfy.utils.Connect; +import org.springframework.data.mongodb.core.MongoTemplate; +import org.springframework.data.mongodb.core.query.Criteria; +import org.springframework.data.mongodb.core.query.Query; +import org.springframework.data.mongodb.core.query.Update; +import org.springframework.stereotype.Component; + +import javax.annotation.Resource; + +/** + * @Author hj + * @Date 2021/5/20 10:48 + * @Description: + * @Version 1.0 + */ +@Component +public class GlobalSettingDaoImpl implements GlobalSettingDao { + + @Resource + private Connect connect; + + @Override + public CGlobalSetting getGlobalSetting() throws Exception { + MongoTemplate mongoTemplate = connect.getMongoTemplete(Constant.dbName); + Query query = new Query(Criteria.where("_id").is(1)); + return mongoTemplate.findOne(query, CGlobalSetting.class); + } + + @Override + public void uporsetGlobalSetting(CGlobalSetting setting) throws Exception { + MongoTemplate mongoTemplate = connect.getMongoTemplete(Constant.dbName); + Query query = new Query(Criteria.where("_id").is(1)); + Update update = new Update(); + update.set("title",setting.getTitle()); + mongoTemplate.upsert(query,update,CGlobalSetting.class); + } +} diff --git a/src/main/java/com/jmfy/handler/HeFuManager.java b/src/main/java/com/jmfy/handler/HeFuManager.java index 19de22a..f0d6a84 100644 --- a/src/main/java/com/jmfy/handler/HeFuManager.java +++ b/src/main/java/com/jmfy/handler/HeFuManager.java @@ -276,6 +276,7 @@ public class HeFuManager { public static final String FOUR_CHALLENGE_TIER_RANK = "FOUR_CHALLENGE_TIER_RANK";//四灵试炼排行榜 public static final String GUILD_CHALLENGE_RANK = "GUILD_CHALLENGE_RANK";//公会副本排行榜 public static final String ARENA_RANK = "ARENA_RANK";//竞技场排行榜 + public static final String NEW_ARENA_RANK = "NEW_ARENA_RANK";//新竞技场排行榜 public static void dealRedis(int masterSID, Set slaveId){ for (Integer slowSID : slaveId) { @@ -298,17 +299,18 @@ public class HeFuManager { deleteRankOfRedis(GUILD_CHALLENGE_RANK,masterSID); // 竞技场排行榜处理 deleteRankOfRedis(ARENA_RANK,masterSID); + deleteArenaOfRedis(NEW_ARENA_RANK, masterSID, slowSID); LOGGER.info("{} 处理redis排行榜完成======================", slowSID); } } public static void defaultRankOfRedis(String key, int masterSID, int slowSID){ try { - RedisUtil instence = RedisUtil.getInstence(); + RedisUtil instance = RedisUtil.getInstence(); String masterChapterKey = masterSID + colon + key + colon; String slowChapterKey = slowSID + colon + key + colon; - Set> chapterSet = instence.rangeWithScores(slowChapterKey, 0, -1); - instence.zsetAddAall(masterChapterKey,chapterSet); + Set> chapterSet = instance.rangeWithScores(slowChapterKey, 0, -1); + instance.zsetAddAall(masterChapterKey,chapterSet); }catch (Exception e){ LOGGER.error("排行榜合并报错,key:{},master:{},slave:{}",key,masterSID,slowSID); e.printStackTrace(); @@ -332,11 +334,11 @@ public class HeFuManager { public static void deleteRankOfRedis(String key, int masterSID){ try { - RedisUtil instence = RedisUtil.getInstence(); + RedisUtil instance = RedisUtil.getInstence(); String masterChapterKey = masterSID + colon + key + colon; - Set dimKey = instence.getDimKey(masterChapterKey, -1); + Set dimKey = instance.getDimKey(masterChapterKey, -1); for (String s : dimKey) { - instence.del(s); + instance.del(s); } }catch (Exception e){ LOGGER.error("排行榜删除报错,key:{},master:{}",key,masterSID); @@ -344,4 +346,18 @@ public class HeFuManager { } } + public static void deleteArenaOfRedis(String key, int masterSID, int slowSId){ + try { + RedisUtil instance = RedisUtil.getInstence(); + String masterKey = key + ":" + masterSID + ":1"; + String slowKey = key + ":" + slowSId + ":1"; + Set> chapterSet = instance.rangeWithScores(slowKey, 0, -1); + instance.zsetAddAall(masterKey,chapterSet); + instance.del(slowKey); + }catch (Exception e){ + LOGGER.error("竞技场删除报错,key:{},master:{}",key,masterSID); + e.printStackTrace(); + } + } + } diff --git a/src/main/java/com/jmfy/model/CGlobalSetting.java b/src/main/java/com/jmfy/model/CGlobalSetting.java new file mode 100644 index 0000000..e00eec9 --- /dev/null +++ b/src/main/java/com/jmfy/model/CGlobalSetting.java @@ -0,0 +1,41 @@ +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; + +import java.util.HashSet; +import java.util.Set; +import java.util.TreeSet; + +/** + * @author hj + * gm用户类 + */ +@Document(collection = "c_global_setting") +public class CGlobalSetting { + @Id + private int id = 1; + /** + * 账号,account + */ + @Field(value = "title") + private String title; + + /********************************************* setter and getter ***********************************************/ + + public CGlobalSetting() { + } + + public int getId() { + return id; + } + + public String getTitle() { + return title; + } + + public void setTitle(String title) { + this.title = title; + } +} diff --git a/src/main/java/com/jmfy/model/vo/PowersEnum.java b/src/main/java/com/jmfy/model/vo/PowersEnum.java index 59a6650..e0e097c 100644 --- a/src/main/java/com/jmfy/model/vo/PowersEnum.java +++ b/src/main/java/com/jmfy/model/vo/PowersEnum.java @@ -13,6 +13,7 @@ public enum PowersEnum { ACCOUNT_MANAGER(100,"用户管理",100,1,""), ACCOUNT_LIST(101,"用户列表",100,1,"findMemberList"), ADD_ACCOUNT(102,"权限: 添加用户",100,0,""), + SET_GLOBAL_TITLE(103, "全局标题", 100, 1,"/html/setTitle.html"), /** * 服务器管理200-299 */ diff --git a/src/main/resources/static/html/sendSysCmd.html b/src/main/resources/static/html/setTitle.html similarity index 61% rename from src/main/resources/static/html/sendSysCmd.html rename to src/main/resources/static/html/setTitle.html index 3944c7d..925c9a4 100644 --- a/src/main/resources/static/html/sendSysCmd.html +++ b/src/main/resources/static/html/setTitle.html @@ -24,51 +24,29 @@ -基本设置 +设置全局标题
- -
-
- -
- - -
-
- -
- -
- - -
-
- -
-
- -
-
-
- +
+ 全局标题 +
+
+
+ 全局标题: + +
+
+ +
+
@@ -95,29 +73,32 @@ $(function(){ }); }); -$('#sendGM').load(function () { - // 根据后台返回值处理结果 - var text=$(this).contents().find("body").text(); - if (text != 0) { - alert('失败'); - } else { - alert('成功'); - location.reload(); - } -}) - - -function sendCheck() { - var erroCode = $('.SERVERID'); - var content1 = $("input[name='content1']").val(); - - if (content1 === '' || content1 == null) { - erroCode.html('内容不能为空!'); - return false; - } - - return true; +function setTitle() { + let title1 = $("input[name='title1']").val(); + if (title1 === '' || title1 == null) { + alert("内容不能为空!"); + return false; + } + $.ajax({ + type: "POST", + data: { + "title1": title1 + }, + url: "/setTitle", + success: function (data) { + if (data === 1) { + alert("修改成功,请刷新页面查看。"); + } + if (data === 0) { + alert("修改失败"); + } + if (data === 2) { + alert("权限不足!"); + } + }} + ) } + diff --git a/src/main/resources/templates/addGsAccount.html b/src/main/resources/templates/addGsAccount.html index 07d3f0c..d63ae4d 100644 --- a/src/main/resources/templates/addGsAccount.html +++ b/src/main/resources/templates/addGsAccount.html @@ -35,7 +35,7 @@
-
+
添加GS账号 diff --git a/src/main/resources/templates/getuserInfo.html b/src/main/resources/templates/getuserInfo.html index 8f0b43d..5fa9bda 100644 --- a/src/main/resources/templates/getuserInfo.html +++ b/src/main/resources/templates/getuserInfo.html @@ -26,12 +26,6 @@

查询个人信息

-
- -
-