角色查询

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,6 +48,7 @@ public class Application extends SpringBootServletInitializer {
minuteTask.setsHotFixManager(sHotFixManager);
scheduledExecutorService.scheduleWithFixedDelay(minuteTask,30,10, TimeUnit.SECONDS);
FileCacheUtils.initData();
// SHotFixManager.main(args);
// FileCacheUtils.initData();
}
@ -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);
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,8 +43,15 @@ public class Connect {
public MongoTemplate getMongoTemplete(String dbName) throws Exception {
if (!oldMongomaps.containsKey(dbName)) {
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;
/**
*
* __
@ -121,8 +123,6 @@ public class SHotFixManager {
}
public static <T> T getJsonFilePathInJsonConf(String fileName, Class<T> fileClass) {
File file = new File(jsonPath + fileName);
if (!file.exists()) {
@ -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>