|
@@ -9,16 +9,18 @@ import cn.com.usky.log.LogService;
|
|
import cn.com.usky.utils.HttpServletRequestUtils;
|
|
import cn.com.usky.utils.HttpServletRequestUtils;
|
|
import cn.com.usky.utils.Page;
|
|
import cn.com.usky.utils.Page;
|
|
import com.alibaba.fastjson.JSONObject;
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
|
+import net.sf.json.JSON;
|
|
import org.apache.tools.ant.taskdefs.condition.Http;
|
|
import org.apache.tools.ant.taskdefs.condition.Http;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.stereotype.Controller;
|
|
import org.springframework.stereotype.Controller;
|
|
-import org.springframework.web.bind.annotation.RequestBody;
|
|
|
|
-import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
|
-import org.springframework.web.bind.annotation.RequestParam;
|
|
|
|
-import org.springframework.web.bind.annotation.ResponseBody;
|
|
|
|
|
|
+import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
import javax.servlet.http.HttpServletRequest;
|
|
import javax.servlet.http.HttpServletResponse;
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
|
+import java.io.UnsupportedEncodingException;
|
|
|
|
+import java.nio.charset.StandardCharsets;
|
|
|
|
+import java.util.HashMap;
|
|
|
|
+import java.util.Map;
|
|
|
|
|
|
/**
|
|
/**
|
|
* @author laowo
|
|
* @author laowo
|
|
@@ -31,30 +33,44 @@ import javax.servlet.http.HttpServletResponse;
|
|
public class Log {
|
|
public class Log {
|
|
@Autowired
|
|
@Autowired
|
|
private LogService logService;
|
|
private LogService logService;
|
|
-
|
|
|
|
@Autowired
|
|
@Autowired
|
|
private TokenAuthService tokenAuthService;
|
|
private TokenAuthService tokenAuthService;
|
|
- @RequestMapping("queryLogList")
|
|
|
|
|
|
+
|
|
|
|
+ @RequestMapping(value = "queryLogList", method = {RequestMethod.GET})
|
|
@ResponseBody
|
|
@ResponseBody
|
|
public String queryLogList(
|
|
public String queryLogList(
|
|
HttpServletResponse response,
|
|
HttpServletResponse response,
|
|
HttpServletRequest request,
|
|
HttpServletRequest request,
|
|
@RequestParam(value = "pageSize", defaultValue = "20") Integer pageSize,
|
|
@RequestParam(value = "pageSize", defaultValue = "20") Integer pageSize,
|
|
@RequestParam(value = "pageNo", defaultValue = "1") Integer pageNo
|
|
@RequestParam(value = "pageNo", defaultValue = "1") Integer pageNo
|
|
- ) {
|
|
|
|
|
|
+ ) throws UnsupportedEncodingException {
|
|
TokenAuthBO tokenAuthBO = HttpServletRequestUtils.tokenAuthForYT(request, tokenAuthService);
|
|
TokenAuthBO tokenAuthBO = HttpServletRequestUtils.tokenAuthForYT(request, tokenAuthService);
|
|
boolean isAuth = tokenAuthBO.isAuthState();
|
|
boolean isAuth = tokenAuthBO.isAuthState();
|
|
if (!isAuth) {
|
|
if (!isAuth) {
|
|
com.alibaba.fastjson.JSONObject json = new com.alibaba.fastjson.JSONObject();
|
|
com.alibaba.fastjson.JSONObject json = new com.alibaba.fastjson.JSONObject();
|
|
json.put("check", false);
|
|
json.put("check", false);
|
|
- json.put("errMsg", "鏉冮檺閿欒�锛岃�閲嶆柊鐧诲綍");
|
|
|
|
- return json.toJSONString();
|
|
|
|
|
|
+ json.put("errMsg", "权限错误,请重新登录");
|
|
|
|
+ return null;
|
|
|
|
|
|
}
|
|
}
|
|
YtiotTAdmin o = (YtiotTAdmin) tokenAuthBO.getData().get(Constants.USER_INFO);
|
|
YtiotTAdmin o = (YtiotTAdmin) tokenAuthBO.getData().get(Constants.USER_INFO);
|
|
String vLoginname = o.getVLoginname();
|
|
String vLoginname = o.getVLoginname();
|
|
- Page<SysLogDTO> sysLogDTOPage = logService.queryLogList(pageSize, pageNo,vLoginname);
|
|
|
|
- String s = JSONObject.toJSON(sysLogDTOPage).toString();
|
|
|
|
|
|
+ Page<SysLogDTO> sysLogDTOPage = logService.queryLogList(pageSize, pageNo, vLoginname);
|
|
|
|
+ // String s = JSONObject.toJSON(sysLogDTOPage).toString();
|
|
|
|
+ // 两者缺一不可,缺setCharacterEncoding,则中文变成“???”
|
|
|
|
+ //缺setContentType,则中文变成“骞夸??...”
|
|
|
|
+ // response.setCharacterEncoding("UTF-8");
|
|
|
|
+
|
|
|
|
+ // response.setContentType("text/html");
|
|
|
|
+ // byte[] utf8Bytes = s.getBytes("UTF-8");
|
|
|
|
+//然后用utf-8 对这个字节数组解码成新的字符串
|
|
|
|
+ // String utf8Str = new String(utf8Bytes, "UTF-8");
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ // byte[] bytes = s.getBytes(StandardCharsets.UTF_8);
|
|
|
|
+ net.sf.json.JSONObject jsonObject = net.sf.json.JSONObject.fromObject(sysLogDTOPage);
|
|
|
|
+ String s = jsonObject.toString();
|
|
|
|
+
|
|
return s;
|
|
return s;
|
|
}
|
|
}
|
|
|
|
|