gm允许修改全局标题

jieling
grimm 2024-02-28 18:04:50 +08:00
parent 6ab9057fe8
commit a4e6d62a6e
11 changed files with 186 additions and 74 deletions

View File

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

View File

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

View File

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

View File

@ -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<Integer> 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<ZSetOperations.TypedTuple<String>> chapterSet = instence.rangeWithScores(slowChapterKey, 0, -1);
instence.zsetAddAall(masterChapterKey,chapterSet);
Set<ZSetOperations.TypedTuple<String>> 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<String> dimKey = instence.getDimKey(masterChapterKey, -1);
Set<String> 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<ZSetOperations.TypedTuple<String>> chapterSet = instance.rangeWithScores(slowKey, 0, -1);
instance.zsetAddAall(masterKey,chapterSet);
instance.del(slowKey);
}catch (Exception e){
LOGGER.error("竞技场删除报错key{}master{}",key,masterSID);
e.printStackTrace();
}
}
}

View File

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

View File

@ -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
*/

View File

@ -24,51 +24,29 @@
<![endif]-->
<!--/meta 作为公共模版分离出去-->
<title>基本设置</title>
<title>设置全局标题</title>
</head>
<body>
<nav class="breadcrumb"><i class="Hui-iconfont">&#xe67f;</i> 首页
<span class="c-gray en">&gt;</span>
GM管理
用户管理
<span class="c-gray en">&gt;</span>
发送GM
全局标题
<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">
<form class="form form-horizontal" id="form-article-add" action="/sendGm" method="post" target="sendGM"
onsubmit="return sendCheck()">
<div class="row cl">
<label class="form-label col-xs-4 col-sm-2">
<span class="c-red">*</span>
服务器id</label>
<div class="formControls col-xs-8 col-sm-9">
<input type="text" name="serverId"
placeholder="服务器id." value=""
class="input-text"/>
<span class="SERVERID"></span>
</div>
</div>
<div class="row cl">
<label class="form-label col-xs-4 col-sm-2">
<span class="c-red">*</span>
内容:</label>
<div class="formControls col-xs-8 col-sm-9">
<input type="text" name="content1" placeholder="" value="" class="input-text"/>
<span class="ROLEID"></span>
</div>
</div>
<div class="row cl" style="text-align: center">
<div class="col-xs-8 col-sm-9 col-xs-offset-4 col-sm-offset-2">
<button class="btn btn-primary radius" type="submit" style="font-size: 15px"><i class="Hui-iconfont">&#xe665;</i>
提交
</button>
</div>
</div>
</form>
<iframe name='sendGM' id="sendGM" style='display: none'></iframe>
<div class="tabBar cl">
<span>全局标题</span>
</div>
<div class="row cl">
<div style="margin: 20px 0 0 80px;padding-top: 50px;">
<span style="font-size: 15px;">全局标题:</span>
<input type="text" name="title1" style="height: 36px;line-height: 36px;width: 500px; margin: 0 0 0 21px;" placeholder="标题(不能为空)" class="input-text"/>
</div>
<div style="margin: 30px 0 0 80px;">
<button class="btn btn-secondary radius" style="font-size: 15px; float: left" onclick="setTitle()">确认</button>
</div>
</div>
</div>
@ -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('<span style="color: red; ">内容不能为空!</span>');
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("权限不足!");
}
}}
)
}
</script>
<!--/请在上方写此页面业务相关的脚本-->
</body>

View File

@ -35,7 +35,7 @@
<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">
<form class="form form-horizontal" id="form-article-add" action="/register" method="post"target="sendNotice">
<form class="form form-horizontal" id="form-article-add" action="/register" method="post" target="sendNotice">
<div id="tab-system" class="HuiTab">
<div class="tabBar cl">
<span>添加GS账号</span>

View File

@ -26,12 +26,6 @@
<div class="page-container" style="text-align: center">
<h1><span style="color: red">查询个人信息</span></h1>
<form class="form form-horizontal" id="form-article-add" action="/getUserRoleInfo" method="post" onsubmit="return getUserInfo()">
<div class="row cl">
<label class="form-label col-xs-0 col-sm-0">
<span class="c-red">*</span>
区服id</label>
</div>
<div class="row cl">
<label class="form-label col-xs-4 col-sm-2">
<span class="c-red">*</span>

View File

@ -23,7 +23,7 @@
<script type="text/javascript" src="lib/DD_belatedPNG_0.0.8a-min.js"></script>
<script>DD_belatedPNG.fix('*');</script>
<![endif]-->
<title>ljsd.admin</title>
<title th:text="${title}"></title>
</head>
<body>
<header class="navbar-wrapper">

View File

@ -1,5 +1,8 @@
## 更新日志
+ ### 2024-2-28
1. 用户管理新增功能可以修改全局标题
+ ### 2023-1-5
1. 添加用户修改自定义密码功能
2. 修改部分页签标题