This commit is contained in:
yutou 2021-05-28 18:32:55 +08:00
parent 470d07d416
commit be3e3bbf9d
2 changed files with 44 additions and 40 deletions

View File

@ -350,7 +350,7 @@ public class Live implements ApplicationContextAware {
BilibiliLiveData liveData = new BilibiliLiveData(); BilibiliLiveData liveData = new BilibiliLiveData();
String danmu; String danmu;
GiftData giftData; GiftData giftData;
Log.i(AppTools.getToDayTimeToString(startTime),roomId,json.toJSONString()); Log.i(AppTools.getToDayTime(),roomId,json.toJSONString());
switch (json.getString("cmd")) { switch (json.getString("cmd")) {
case "INTERACT_WORD"://普通用户进直播间 case "INTERACT_WORD"://普通用户进直播间
danmu = json.getJSONObject("data").getString("uname") + " 进入到直播间"; danmu = json.getJSONObject("data").getString("uname") + " 进入到直播间";

View File

@ -31,44 +31,48 @@ public class APIFilter implements Filter {
HttpServletRequest request = (HttpServletRequest) servletRequest; HttpServletRequest request = (HttpServletRequest) servletRequest;
HttpServletResponse response = (HttpServletResponse) servletResponse; HttpServletResponse response = (HttpServletResponse) servletResponse;
String token = request.getParameter("token"); String token = request.getParameter("token");
if(StringUtils.isEmpty(token)){ if (StringUtils.isEmpty(token)) {
Cookie cookie=AppTools.getCookie(request,"login"); Cookie cookie = AppTools.getCookie(request, "login");
if(cookie!=null){ if (cookie != null) {
token=cookie.getValue(); token = cookie.getValue();
} }
} }
String tmp = request.getRequestURI(); String tmp = request.getRequestURI();
if(tmp.contains("/user/login.do") if (tmp.contains("/user/login.do")
||tmp.contains("/user/reg.do") || tmp.contains("/user/reg.do")
||tmp.contains("/user/logout.do") || tmp.contains("/user/logout.do")
||tmp.contains("/user/get/test.do") || tmp.contains("/user/get/test.do")
||tmp.contains("/system/public/reg.do") || tmp.contains("/system/public/reg.do")
||tmp.contains("/favicon.ico") || tmp.contains("/favicon.ico")
){ ) {
filterChain.doFilter(servletRequest,servletResponse); filterChain.doFilter(servletRequest, servletResponse);
}else { } else {
UUser user= service.getUserToUid(Integer.parseInt(RedisTools.get(token)));; if (StringUtils.isEmpty(token)) {
if(user==null){
response.sendRedirect("/"); response.sendRedirect("/");
}else{ return;
String url=null; }
UUser user = service.getUserToUid(Integer.parseInt(RedisTools.get(token)));
if (user == null) {
response.sendRedirect("/");
} else {
String url = null;
try { try {
url = tmp.split(tmp.split("/")[tmp.split("/").length - 1])[0]; url = tmp.split(tmp.split("/")[tmp.split("/").length - 1])[0];
} catch (Exception e) { } catch (Exception e) {
com.yutou.bilibili.Tools.Log.e(e); com.yutou.bilibili.Tools.Log.e(e);
com.yutou.bilibili.Tools.Log.i("无权限请求:"+tmp); com.yutou.bilibili.Tools.Log.i("无权限请求:" + tmp);
return; return;
} }
JSONArray powers = JSONArray.parseArray(user.getPower()); JSONArray powers = JSONArray.parseArray(user.getPower());
if(powers.toJavaList(Integer.class).contains(-1)){ if (powers.toJavaList(Integer.class).contains(-1)) {
filterChain.doFilter(servletRequest,servletResponse); filterChain.doFilter(servletRequest, servletResponse);
}else { } else {
PermissionExample pExample = new PermissionExample(); PermissionExample pExample = new PermissionExample();
pExample.createCriteria().andUrlEqualTo(url); pExample.createCriteria().andUrlEqualTo(url);
List<Permission> permissions = permissionDao.selectByExample(pExample); List<Permission> permissions = permissionDao.selectByExample(pExample);
if (permissions != null && permissions.size() > 0) { if (permissions != null && permissions.size() > 0) {
if (powers.toJavaList(Integer.class).contains(permissions.get(0).getId())) { if (powers.toJavaList(Integer.class).contains(permissions.get(0).getId())) {
filterChain.doFilter(servletRequest,servletResponse); filterChain.doFilter(servletRequest, servletResponse);
} }
} }
} }