修复Android登录状态会混乱的bug
ship/type.do接口取消登录验证 新增Filter拦截器,打印请求和参数 System.out改成Log.i
This commit is contained in:
parent
ad332a80cf
commit
89346de453
@ -161,7 +161,7 @@
|
||||
try {
|
||||
|
||||
var pw = json.data.user.power;
|
||||
if (pw == '') {
|
||||
if (pw === '') {
|
||||
location.reload();
|
||||
return;
|
||||
}
|
||||
|
2
pom.xml
2
pom.xml
@ -10,7 +10,7 @@
|
||||
</parent>
|
||||
<groupId>com.yutou.jianrmod</groupId>
|
||||
<artifactId>servicer</artifactId>
|
||||
<version>2.0.1-release</version>
|
||||
<version>2.0.2-release</version>
|
||||
<name>servicer</name>
|
||||
<description>Demo project for Spring Boot</description>
|
||||
|
||||
|
@ -3,6 +3,7 @@ package com.yutou.Data;
|
||||
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.yutou.utlis.Log;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@ -74,7 +75,7 @@ public class Ship {
|
||||
return ship;
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
System.out.println(json.toString());
|
||||
Log.i(json.toString());
|
||||
System.exit(0);
|
||||
}
|
||||
return null;
|
||||
|
@ -5,6 +5,7 @@ import java.util.Date;
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import com.yutou.utlis.Log;
|
||||
import org.json.JSONObject;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
@ -28,7 +29,7 @@ public class CDNController {
|
||||
public String ballback(HttpServletRequest request, String hash, String key, String bucket, String fsize,
|
||||
String uuid, String uToken,String qToken) {
|
||||
try {
|
||||
System.out.println("七牛云回调:");
|
||||
Log.i("七牛云回调:");
|
||||
Tools.PrintfHttpServletRequest(request);
|
||||
if (qToken == null) {
|
||||
JSONObject json = new JSONObject();
|
||||
|
@ -107,12 +107,6 @@ public class AndroidMapController {
|
||||
@RequestMapping("/android/ship/type.do")
|
||||
public String getShipType(HttpServletRequest request){
|
||||
JSONObject json=new JSONObject();
|
||||
if(Tools.getUidOfToken(request)<=0){
|
||||
json.put("msg",UserEnum.LOGIN_NOT_LOGIN.msg);
|
||||
json.put("code", UserEnum.LOGIN_NOT_LOGIN.code);
|
||||
return json.toString();
|
||||
}
|
||||
|
||||
List<ZsShipType> list=mapNodeService.selectAllShipType();
|
||||
json.put("count",list.size());
|
||||
json.put("data", JSONArray.toJSON(list));
|
||||
|
@ -9,6 +9,7 @@ import com.yutou.maptop.Bean.UserTeam;
|
||||
import com.yutou.maptop.services.MapTopService;
|
||||
import com.yutou.maptop.services.UserTeamService;
|
||||
import com.yutou.utlis.JianrDataTools;
|
||||
import com.yutou.utlis.Log;
|
||||
import com.yutou.utlis.Tools;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
@ -61,7 +62,7 @@ public class MapTopController {
|
||||
map.setMapNode(JianrDataTools.getMapNode(gameInfoLog.getExt()));
|
||||
map.setShipTeam(JianrDataTools.getShip(JSONObject.parseObject(gameInfoLog.getMessage()),JianrDataTools.SHIP_TYPE));
|
||||
int id=mapTopService.insertMapTop(map);
|
||||
System.out.println(">>>>>>ID="+id+" ---> "+JSONObject.parseObject(gameInfoLog.getExt()).getInteger("n")+" "+gameInfoLog.getId());
|
||||
Log.i(">>>>>>ID="+id+" ---> "+JSONObject.parseObject(gameInfoLog.getExt()).getInteger("n")+" "+gameInfoLog.getId());
|
||||
UserTeam team=new UserTeam();
|
||||
team.setMid(id);
|
||||
team.setMapNode(map.getMapNode());
|
||||
|
@ -9,6 +9,7 @@ import javax.servlet.http.Cookie;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import com.yutou.utlis.Log;
|
||||
import org.json.JSONObject;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
@ -77,7 +78,7 @@ public class WebLoginController {
|
||||
request.getSession().setAttribute("power", 100);
|
||||
break;
|
||||
}
|
||||
System.out.println(json.toString());
|
||||
Log.i(json.toString());
|
||||
return json.toString();
|
||||
}
|
||||
|
||||
@ -85,7 +86,7 @@ public class WebLoginController {
|
||||
@ResponseBody
|
||||
public String reg(HttpServletRequest request,String uname,String pass,String name) {
|
||||
JSONObject json = new JSONObject();
|
||||
System.out.println("注册请求");
|
||||
Log.i("注册请求");
|
||||
Tools.PrintfHttpServletRequest(request);
|
||||
try {
|
||||
uname=new String(uname.getBytes(), StandardCharsets.UTF_8);
|
||||
@ -120,7 +121,6 @@ public class WebLoginController {
|
||||
String referer=request.getHeader("referer");
|
||||
JSONObject json = new JSONObject();
|
||||
try {
|
||||
System.out.println( RedisUtlis.get(Tools.getCookie(request,"login")));
|
||||
String ujson = RedisUtlis.get(Tools.getCookie(request,"login"));
|
||||
JSONObject reJson=new JSONObject(ujson);
|
||||
udata = reJson.getInt("uid");
|
||||
|
@ -6,6 +6,7 @@ import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import com.yutou.utlis.Log;
|
||||
import org.json.JSONArray;
|
||||
import org.json.JSONObject;
|
||||
import org.springframework.stereotype.Controller;
|
||||
@ -35,7 +36,7 @@ public class WebPermissionController {
|
||||
JSONObject json=new JSONObject();
|
||||
JSONArray array=new JSONArray();
|
||||
User user=userService.getUser(Tools.getUserId(request));
|
||||
System.out.println(user);
|
||||
Log.i(user);
|
||||
for (UGroup group : list) {
|
||||
JSONObject tmp=new JSONObject();
|
||||
tmp.put("permission", group.getTitle());
|
||||
|
@ -12,6 +12,7 @@ import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import com.yutou.utlis.*;
|
||||
import org.json.JSONObject;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
@ -27,10 +28,6 @@ import com.yutou.mybatis.UUserdata;
|
||||
import com.yutou.mybatis.User;
|
||||
import com.yutou.services.ModService;
|
||||
import com.yutou.services.UserService;
|
||||
import com.yutou.utlis.EmailTools;
|
||||
import com.yutou.utlis.RedisUtlis;
|
||||
import com.yutou.utlis.ServiceStaticValue;
|
||||
import com.yutou.utlis.Tools;
|
||||
|
||||
@Controller
|
||||
@RequestMapping("/user")
|
||||
@ -66,12 +63,16 @@ public class WebUserController {
|
||||
JSONObject userdata = new JSONObject();
|
||||
try {
|
||||
String ujson = RedisUtlis.get(Tools.getCookie(request,"login"));
|
||||
if(ujson==null){
|
||||
userdata.put("code", UserEnum.LOGIN_NOT_LOGIN.code);
|
||||
userdata.put("msg", UserEnum.LOGIN_NOT_LOGIN.msg);
|
||||
}else {
|
||||
JSONObject json = new JSONObject(ujson);
|
||||
int uid = json.getInt("uid");
|
||||
userdata.put("msg", UserEnum.LOGIN_SUCCESS.code);
|
||||
userdata.put("message", "ok");
|
||||
userdata.put("data", userService.getUserData(uid).getJSONObject("data"));
|
||||
|
||||
}
|
||||
} catch (Exception e) {
|
||||
// TODO: handle exception
|
||||
userdata.put("code", UserEnum.LOGIN_NOT_LOGIN.code);
|
||||
@ -152,7 +153,7 @@ public class WebUserController {
|
||||
try {
|
||||
String ujson =RedisUtlis.get(Tools.getCookie(request,"login"));
|
||||
JSONObject reJson=new JSONObject(ujson);
|
||||
System.out.println(ujson);
|
||||
Log.i(ujson);
|
||||
int uid_ =reJson.getInt("uid");
|
||||
if(!Tools.StringIsEmpty(uid)) {
|
||||
try {
|
||||
|
@ -9,6 +9,7 @@ import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import com.yutou.utlis.Log;
|
||||
import org.json.JSONArray;
|
||||
import org.json.JSONObject;
|
||||
import org.springframework.stereotype.Controller;
|
||||
@ -172,7 +173,7 @@ public class AdminUserController {
|
||||
public boolean isAdmin(HttpServletRequest request) {
|
||||
int uid=Tools.getUserId(request);
|
||||
User user=userService.getUser(uid);
|
||||
System.out.println(user);
|
||||
Log.i(user);
|
||||
if(user.getPower()<powerService.getGroup(POWER.ADMIN,null).getPermission()) {
|
||||
return false;
|
||||
}
|
||||
|
@ -59,7 +59,15 @@ public class SystemController {
|
||||
if(uid_==0){
|
||||
uid_=Tools.getUserId(request);
|
||||
}
|
||||
if (uid_ == 0) {
|
||||
int androidUId=-1;
|
||||
try {
|
||||
androidUId=Integer.parseInt(request.getParameter("uid"));
|
||||
}catch (Exception e){
|
||||
if(request.getParameter("sysinfo").equals("web")){
|
||||
androidUId=uid_;
|
||||
}
|
||||
}
|
||||
if (uid_ == 0||uid_!=androidUId) {
|
||||
json.put("code", UserEnum.LOGIN_NOT_LOGIN.code);
|
||||
json.put("msg", UserEnum.LOGIN_NOT_LOGIN.msg);
|
||||
return json.toString();
|
||||
|
@ -144,6 +144,7 @@ public class UserController {
|
||||
@ResponseBody
|
||||
public String logout(HttpServletRequest request, String uid, String token) {
|
||||
JSONObject json = new JSONObject();
|
||||
Log.i(token);
|
||||
if (Tools.getUidOfToken(request)>0) {
|
||||
json.put("msg", "注销成功");
|
||||
json.put("code", UserEnum.LOGIN_SUCCESS.code);
|
||||
|
@ -19,6 +19,7 @@ import javax.mail.Transport;
|
||||
import javax.mail.internet.InternetAddress;
|
||||
import javax.mail.internet.MimeMessage;
|
||||
|
||||
import com.yutou.utlis.Log;
|
||||
import net.sf.json.JSONObject;
|
||||
|
||||
public class ulit {
|
||||
@ -189,7 +190,7 @@ public class ulit {
|
||||
return false;
|
||||
}
|
||||
public static void deleteMod(String modPath){
|
||||
System.out.println("删除:"+modPath);
|
||||
Log.i("删除:"+modPath);
|
||||
File files=new File(modPath);
|
||||
if(files.exists())
|
||||
delete(files);
|
||||
|
@ -6,6 +6,7 @@ import java.util.List;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
import com.yutou.utlis.Log;
|
||||
import org.json.JSONObject;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@ -73,7 +74,7 @@ public class ModServiceimpl implements ModService {
|
||||
public int upload(JSONObject json) {
|
||||
// TODO Auto-generated method stub
|
||||
try {
|
||||
System.out.println("提交数据库:"+json.toString());
|
||||
Log.i("提交数据库:"+json.toString());
|
||||
TMod mod = JSON.parseObject(json.toString(), TMod.class);
|
||||
mod.setCreatetime(System.currentTimeMillis());
|
||||
mod.setIcon(json.getString("icon"));
|
||||
|
24
src/main/java/com/yutou/utlis/APIFilter.java
Normal file
24
src/main/java/com/yutou/utlis/APIFilter.java
Normal file
@ -0,0 +1,24 @@
|
||||
package com.yutou.utlis;
|
||||
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import javax.servlet.*;
|
||||
import javax.servlet.annotation.WebFilter;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.io.IOException;
|
||||
|
||||
@Component
|
||||
@WebFilter
|
||||
public class APIFilter implements Filter {
|
||||
@Override
|
||||
public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException {
|
||||
HttpServletRequest request= (HttpServletRequest) servletRequest;
|
||||
Log.i("API", request.getRequestURI()+Tools.getHttpServletRequest(request));
|
||||
try {
|
||||
filterChain.doFilter(servletRequest, servletResponse);
|
||||
}catch (Exception ignored){
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@ -20,10 +20,11 @@ public class Log {
|
||||
* 普通输出
|
||||
* @param str 正文
|
||||
*/
|
||||
public static void i(String str) {
|
||||
public static void i(Object str) {
|
||||
System.out.println(str);
|
||||
logger.info(str);
|
||||
}
|
||||
|
||||
/**
|
||||
* 错误输出带标题
|
||||
* @param title 标题
|
||||
|
@ -38,7 +38,6 @@ public class MD5Signature {
|
||||
public static void main(String[] args) throws Exception {
|
||||
String str="channelid=1499395535416&cpArea=1&money=1000¬es=1_2_1499400140&order=T20170707120223&time=1499400143360&uid=2";
|
||||
String md5=sign(str, "XT9TEBMAAOH8KNYXUC8TUQB3CTOTOZK4");
|
||||
System.out.println(md5);
|
||||
|
||||
}
|
||||
|
||||
|
@ -126,6 +126,6 @@ public class RedisUtlis {
|
||||
public static void main(String[] args) {
|
||||
String str= "\"aaa\"";
|
||||
str=str.replaceAll("\"aaa\"", "0");
|
||||
System.out.println(str);
|
||||
Log.i(str);
|
||||
}
|
||||
}
|
||||
|
@ -56,7 +56,7 @@ public class Tools {
|
||||
//String url = oss.upload(saveFile, path);
|
||||
//oss.close();
|
||||
fileName=URLEncoder.encode(fileName,"UTF-8");
|
||||
System.out.println("上传文件保存路径:"+(path+fileName));
|
||||
Log.i("上传文件保存路径:"+(path+fileName));
|
||||
return path+fileName;
|
||||
}
|
||||
/**
|
||||
@ -220,7 +220,6 @@ public class Tools {
|
||||
Cookie[] cookies = request.getCookies();
|
||||
String value=null;
|
||||
for (Cookie cookie : cookies) {
|
||||
System.out.println(cookie.getName()+" "+cookie.getValue());
|
||||
if (cookie.getName().equals(key)) {
|
||||
value=cookie.getValue();
|
||||
break;
|
||||
@ -300,8 +299,8 @@ public class Tools {
|
||||
array.put(3);
|
||||
array.put(4);
|
||||
array.put(5);
|
||||
System.out.println(array.toString());
|
||||
System.out.println(array.toString());
|
||||
Log.i(array.toString());
|
||||
Log.i(array.toString());
|
||||
}
|
||||
/**
|
||||
* N以内的不重复随机数
|
||||
@ -476,6 +475,15 @@ public class Tools {
|
||||
Log.i("HttpServletRequest", "Key:" + name + " value:" + request.getParameter(name));
|
||||
}
|
||||
}
|
||||
public static String getHttpServletRequest(HttpServletRequest request){
|
||||
String queryString="?";
|
||||
Enumeration<String> names = request.getParameterNames();
|
||||
while (names.hasMoreElements()) {
|
||||
String name = names.nextElement();
|
||||
queryString+=name+"="+request.getParameter(name)+"&";
|
||||
}
|
||||
return queryString.substring(0,queryString.length()-1);
|
||||
}
|
||||
public static void PrintfSession(HttpServletRequest request) {
|
||||
Enumeration<String> names=request.getSession().getAttributeNames();
|
||||
while (names.hasMoreElements()) {
|
||||
@ -519,6 +527,9 @@ public class Tools {
|
||||
return -1;
|
||||
}
|
||||
String ujson = RedisUtlis.get(token);
|
||||
if(ujson==null){
|
||||
return -1;
|
||||
}
|
||||
JSONObject reJson=new JSONObject(ujson);
|
||||
if(reJson.getString("msg").equals("注册成功")) {
|
||||
return 0;
|
||||
|
Reference in New Issue
Block a user