角色查询

zhangshanxue 2020-10-22 19:58:29 +08:00
parent 4dcfa687bc
commit d08d43854c
8 changed files with 141 additions and 42 deletions

View File

@ -26,9 +26,10 @@ import java.util.concurrent.TimeUnit;
*/
@SpringBootApplication(exclude={DataSourceAutoConfiguration.class, HibernateJpaAutoConfiguration.class})
public class Application extends SpringBootServletInitializer {
private static GlobalSysSettings globalSysSettings;
public static GlobalSysSettings globalSysSettings;
public static ConfigurableApplicationContext configurableApplicationContext;
public static void main(String[] args) {
ConfigurableApplicationContext configurableApplicationContext = SpringApplication.run(Application.class, args);
configurableApplicationContext = SpringApplication.run(Application.class, args);
MyStringRedisTemplate myStringRedisTemplate = configurableApplicationContext.getBean(MyStringRedisTemplate.class);
globalSysSettings = configurableApplicationContext.getBean(GlobalSysSettings.class);
RedisUtil.getInstence().init(myStringRedisTemplate.getRedisObjectTemplate());
@ -47,7 +48,8 @@ public class Application extends SpringBootServletInitializer {
minuteTask.setsHotFixManager(sHotFixManager);
scheduledExecutorService.scheduleWithFixedDelay(minuteTask,30,10, TimeUnit.SECONDS);
FileCacheUtils.initData();
// FileCacheUtils.initData();
// SHotFixManager.main(args);
// FileCacheUtils.initData();
}
@Override//为了打包springboot项目
@ -55,4 +57,8 @@ public class Application extends SpringBootServletInitializer {
SpringApplicationBuilder builder) {
return builder.sources(this.getClass());
}
public static ConfigurableApplicationContext getConfigurableApplicationContext() {
return configurableApplicationContext;
}
}

View File

@ -100,10 +100,18 @@ public class UserInfoController {
@RequestMapping(value = "/getUserRoleInfo", method = {RequestMethod.POST, RequestMethod.GET})
public String getUserInfo(HttpSession session, ModelMap map, HttpServletRequest request) throws Exception {
HashMap<String, String> parameterMap = JsonUtil.getInstence().getParameterMap(request);
int serverId = Integer.parseInt(parameterMap.get("serverId"));
// int serverId = Integer.parseInt(parameterMap.get("serverId"));
int roleId = Integer.parseInt(parameterMap.get("roleId"));
GSUser gsUser = gsUserDao.findUserInfo(serverId, roleId);
CUserVo cUserVo = getcUserVo(gsUser);
CUserInfo userInfoById = userInfoDao.findUserInfoById(parameterMap.get("roleId"));
GSUser gsUser = gsUserDao.findUserInfo(userInfoById.getServerid(), roleId);
CUserVo cUserVo = getcUserVo(gsUser);
if(cUserVo.isData==1){
cUserVo.setServerId(String.valueOf(userInfoById.getServerid()));
}
map.put("cUserVo", cUserVo);
return "userInfo";
}

View File

@ -71,7 +71,7 @@ public class MailDaoImpl implements MailDao {
mailPersonalCache.setContent(mail.getMailContent());
mailPersonalCache.setReward(sb.toString());
// mailPersonalCache.setTime(Integer.parseInt(mail.getSendTime()));
RedisUtil.getInstence().putMapEntry(String.valueOf(mail.getServerId()),RedisUserKey.READY_TO_USER_MAIL+RedisUserKey.Delimiter_colon,uid[i],mailPersonalCache,240);
RedisUtil.getInstence().putMapEntry(String.valueOf(mail.getServerId()),RedisUserKey.READY_TO_USER_MAIL+RedisUserKey.Delimiter_colon,uid[i].trim(),mailPersonalCache,240);
}
}

View File

@ -5,7 +5,7 @@ public class CUserVo implements java.io.Serializable {
public int isData; // 是否有数据 0没有 1
public int userId;
public String serverId;
public String userName;
public int level ;
@ -64,4 +64,12 @@ public class CUserVo implements java.io.Serializable {
this.outLineTime = outLineTime;
}
public String getServerId() {
return serverId;
}
public void setServerId(String serverId) {
this.serverId = serverId;
}
}

View File

@ -43,7 +43,14 @@ public class Connect {
public MongoTemplate getMongoTemplete(String dbName) throws Exception {
if (!oldMongomaps.containsKey(dbName)) {
throw new Exception(dbName + " does not exist");
MongoClient mongoClient = new MongoClient(new MongoClientURI(oldMongoClient));
try {
MongoDbFactory mongoDbFactory = (new SimpleMongoDbFactory(mongoClient, dbName));
MongoTemplate mongoTemplate = new MongoTemplate(mongoDbFactory, mappingMongoConverter(mongoDbFactory));
oldMongomaps.put(dbName, mongoTemplate);
}catch (Exception e){
throw new Exception(dbName + " does not exist");
}
}
MongoTemplate mongoTemplate = oldMongomaps.get(dbName);
return mongoTemplate;

View File

@ -1,5 +1,6 @@
package com.jmfy.utils;
import com.Application;
import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.jmfy.dao.UserInfoDao;
@ -24,6 +25,7 @@ public class SHotFixManager {
private static int currentDbVersion;
@Resource
private UserInfoDao userInfoDao;
/**
*
* __
@ -34,7 +36,7 @@ public class SHotFixManager {
public void updateTablesWithTableNames() throws Exception {
if(null ==jsonPath){
if (null == jsonPath) {
initJsonPath();
}
@ -48,19 +50,19 @@ public class SHotFixManager {
//更新指定表
tableList = version.getTables().split("\\|");
HashMap<Integer ,StringBuilder> roleId2reward= new HashMap<>();
HashMap<Integer, StringBuilder> roleId2reward = new HashMap<>();
//多个文件补充
for (int i = 0; i <tableList.length ; i++) {
for (int i = 0; i < tableList.length; i++) {
String[] s = tableList[i].split("_");
boolean b = s.length >=3;
if(!b){
boolean b = s.length >= 3;
if (!b) {
continue;
}
//单个文件奖励循环补充
//单个文件奖励循环补充
StringBuilder reward = new StringBuilder();
for (int j = 2; j < s.length; j++) {
if(reward.length()!=0)
if (reward.length() != 0)
reward.append("|");
reward.append(s[j]);
}
@ -68,7 +70,7 @@ public class SHotFixManager {
String path = getPath("conf", tableList[i] + ".txt");
File file = new File(path);
if (!file.exists()) {
System.out.println("file not find {}, do not find sheet with {} you need rebuild all sheet by gen sheet tool!"+path+tableList[i]);
System.out.println("file not find {}, do not find sheet with {} you need rebuild all sheet by gen sheet tool!" + path + tableList[i]);
continue;
}
String line;
@ -81,52 +83,50 @@ public class SHotFixManager {
StringBuilder orDefault = roleId2reward.getOrDefault(Integer.valueOf(prarms[0]), new StringBuilder());
//单个文件奖励次数循环
for (int j = 0; j <Integer.valueOf(prarms[1]) ; j++) {
if(orDefault.length()!=0)
for (int j = 0; j < Integer.valueOf(prarms[1]); j++) {
if (orDefault.length() != 0)
orDefault.append("|");
orDefault.append(reward);
}
roleId2reward.putIfAbsent(Integer.valueOf(prarms[0]),orDefault);
roleId2reward.putIfAbsent(Integer.valueOf(prarms[0]), orDefault);
}
}
file.renameTo(new File(path+"_hadfix"));
file.renameTo(new File(path + "_hadfix"));
}
try {
long l = System.currentTimeMillis();
roleId2reward.forEach((integer, stringBuilder) -> {
System.out.println("integer = " + integer+stringBuilder);
System.out.println("integer = " + integer + stringBuilder);
try {
CUserInfo userInfoById = userInfoDao.findUserInfoById(integer.toString());
if(null == userInfoById){
if (null == userInfoById) {
return;
}
MailPersonalCache mailPersonalCache = new MailPersonalCache();
mailPersonalCache.setTitle(version.getMailTitle());
mailPersonalCache.setContent(version.getMailContent());
mailPersonalCache.setReward(stringBuilder.toString());
mailPersonalCache.setTime((int)(l/1000));
RedisUtil.getInstence().putMapEntry(String.valueOf(userInfoById.getServerid()), RedisUserKey.READY_TO_USER_MAIL+RedisUserKey.Delimiter_colon,integer.toString(),mailPersonalCache,240);
mailPersonalCache.setTime((int) (l / 1000));
RedisUtil.getInstence().putMapEntry(String.valueOf(userInfoById.getServerid()), RedisUserKey.READY_TO_USER_MAIL + RedisUserKey.Delimiter_colon, integer.toString(), mailPersonalCache, 240);
}catch (Exception e){
System.out.println("do fix send mail integer e = " + e+integer);
} catch (Exception e) {
System.out.println("do fix send mail integer e = " + e + integer);
}
});
}catch (Exception e){
} catch (Exception e) {
System.out.println("do fix send mail e = " + e);
}
}
public static <T> T getJsonFilePathInJsonConf(String fileName, Class<T> fileClass) {
File file = new File(jsonPath + fileName);
if (!file.exists()) {
System.out.println("the {} is not exist"+fileName);
System.out.println("the {} is not exist" + fileName);
return null;
}
try (InputStream in = new FileInputStream(file);) {
@ -163,7 +163,7 @@ public class SHotFixManager {
StringBuilder path = new StringBuilder();
if (isWindows()) {// Window 系统
path.append(new File(".").getCanonicalPath()).append(File.separator);
}else {
} else {
path.append("../");
}
return path.toString();
@ -173,4 +173,81 @@ public class SHotFixManager {
String osName = System.getProperty("os.name");
return osName.matches("^(?i)Windows.*$");
}
public static void main(String[] args) {
try {
String path = getPath("conf", "fix" + ".txt");
File file = new File(path);
if (!file.exists()) {
System.out.println("file = " + file);
}
HashMap<Integer, Integer> integerIntegerHashMap1001 = new HashMap<>();
String line;
try (BufferedReader bufferedReader = new BufferedReader(new FileReader(file))) {
while ((line = bufferedReader.readLine()) != null) {
if (line.isEmpty()) {
continue;
}
integerIntegerHashMap1001.put(Integer.valueOf(line), 1 + integerIntegerHashMap1001.getOrDefault(Integer.valueOf(line), 0));
}
}
StringBuilder stringBuilder = new StringBuilder();
SHotFixManager sHotFixManager = Application.getConfigurableApplicationContext().getBean(SHotFixManager.class);
integerIntegerHashMap1001.forEach((integer, integer2) ->
{
if (stringBuilder.length() != 0) {
stringBuilder.append("\n");
}
stringBuilder.append(integer);
stringBuilder.append("\t");
stringBuilder.append(integer2);
try {
int sserverId = sHotFixManager.getSserverId(integer);
stringBuilder.append("\t");
stringBuilder.append(sserverId);
} catch (Exception e) {
System.out.println("e = " + e);
}
}
);
File file1 = new File(getPath("conf/fix_out" + 1 + ".txt"));
prientFile(file1, stringBuilder, "");
} catch (Exception e) {
e.printStackTrace();
}
}
private int getSserverId(Integer integer) throws Exception {
CUserInfo userInfoById = userInfoDao.findUserInfoById(String.valueOf(integer));
return userInfoById.getServerid();
}
private static void prientFile(File file, StringBuilder stringBuilder, String s) {
try (PrintWriter printWriter = new PrintWriter(new FileOutputStream(file));) {
printWriter.print(stringBuilder.toString());
printWriter.print("\r\n\r\n");
printWriter.print(s);
printWriter.flush();
} catch (FileNotFoundException e) {
e.printStackTrace();
}
}
}

View File

@ -27,14 +27,9 @@
<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-4 col-sm-2">
<label class="form-label col-xs-0 col-sm-0">
<span class="c-red">*</span>
区服id</label>
<div class="formControls col-xs-8 col-sm-9">
<select name="serverId" class="input-text" id="serverId"><!--下拉列表-->
<option th:each="server:${serverInfo}" th:value="${server.server_id}" th:text="${server.server_id}"></option>
</select>
</div>
</div>
<div class="row cl">
@ -64,10 +59,6 @@
var serverId = $("#serverId").val();
var roleId = $("input[name='roleId']").val();
var erroCode = $('.SERVERID');
if (serverId === '' || serverId == null) {
erroCode.html('<span style="color: red; ">服务器id不能为空!</span>');
return false;
}
if (roleId === '' || roleId == null) {
erroCode = $('.ROLEID');
erroCode.html('<span style="color: red; ">角色id不能为空!</span>');

View File

@ -34,6 +34,7 @@
<thead>
<tr class="text-c">
<th width="500">ID</th>
<th width="500">serverID</th>
<th width="500">角色名</th>
<th width="200">等級</th>
<th width="200">妖精</th>
@ -54,6 +55,7 @@
</div>
<div th:case="1">
<td th:text="${cUserVo.userId}" style="text-align: center;"></td>
<td th:text="${cUserVo.serverId}" style="text-align: center;"></td>
<td th:text="${cUserVo.userName}" style="text-align: center;"></td>
<td th:text="${cUserVo.level}" style="text-align: center;"></td>
<td th:text="${cUserVo.gem}" style="text-align: center;"></td>