Skip to content

Commit

Permalink
fix: office成绩查询
Browse files Browse the repository at this point in the history
  • Loading branch information
msojocs committed Sep 10, 2021
1 parent 9019b4c commit 766cb96
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 17 deletions.
31 changes: 31 additions & 0 deletions src/main/java/cn/wecuit/backen/config/WecuitConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,43 @@
@EnableConfigurationProperties
@ConfigurationProperties(prefix = "wecuit")
public class WecuitConfig {
private String dataPath;
private String localhost;
private Robot robot;
private AES aes;
private RSA rsa;
private OCR ocr;
private WX wx;
private QQ qq;

@Data
public static class Robot{
private Long id;
private String pass;
}
@Data
public static class AES{
private String key;
}
@Data
public static class RSA{
private String pri;
private String pub;
}
@Data
public static class OCR{
private String server;
private String salt;
}
@Data
public static class WX{
private String appid;
private String secret;
}
@Data
public static class QQ{
private String appid;
private String secret;
}
}

27 changes: 11 additions & 16 deletions src/main/java/cn/wecuit/backen/controller/JszxController.java
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
package cn.wecuit.backen.controller;

import cn.wecuit.backen.exception.BaseException;
import cn.wecuit.backen.response.BaseResponse;
import cn.wecuit.backen.utils.CCUtil;
import cn.wecuit.backen.utils.HTTP.HttpUtil2;
import cn.wecuit.backen.utils.HTTP.HttpUtilEntity;
import cn.wecuit.backen.utils.JsonUtil;
import cn.wecuit.backen.utils.RSAUtils;
import org.apache.hc.core5.http.ParseException;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.servlet.ServletContext;
Expand All @@ -27,9 +26,12 @@
**/
@RestController
@RequestMapping("/Jszx")
@BaseResponse
public class JszxController {
@Resource
HttpServletRequest request;
@Value("${wecuit.ocr.server}")
private String OCR_SERVER;

@RequestMapping("/getCheckInListV2")
public Map<String, Object> getCheckInListV2() throws IOException, ParseException {
Expand All @@ -48,7 +50,7 @@ public Map<String, Object> getCheckInListV2() throws IOException, ParseException
String html = resp.getBody();
Map<String, List<Map<String, String>>> checkInList = CCUtil.parseCheckInList(html);
return new HashMap<String, Object>(){{
put("code", 200);

put("list", checkInList);
}};
}
Expand All @@ -66,7 +68,6 @@ public Map<String, Object> loginRSAv1(@RequestBody Map<String, String> uInfo) th

// 响应体
Map<String, Object> ret = new HashMap<>();
ret.put("code", 200);
ret.put("cookie", loginCookie);
return ret;
}
Expand All @@ -90,7 +91,6 @@ public Map<String, Object> getCheckInEditV2() throws IOException, ParseException
String html = httpUtilEntity.getBody();
Map<String, Object> form = CCUtil.parseCheckInContent(html);
return new HashMap<String, Object>(){{
put("code", 200);
put("form", form);
}};
}
Expand Down Expand Up @@ -125,7 +125,7 @@ public Map<String, Object> doCheckInV3(@RequestBody Map<String, Object> postMap)
if(html.contains("提交打卡成功!")) {
Map<String, Object> newForm = CCUtil.parseCheckInContent(html);
return new HashMap<String, Object>(){{
put("code", 200);

put("error", time.toString());
put("form", newForm);
}};
Expand Down Expand Up @@ -164,17 +164,14 @@ public Map<String, Object> office_prepare() throws IOException, ParseException {
String finalCodeKey = codeKey;
String finalSyncTime = syncTime;
return new HashMap<String, Object>(){{
put("code", 200);
put("cookie", cookie.toString());
put("codeKey", finalCodeKey);
put("syncTime", finalSyncTime);
}};
}

@RequestMapping("/office_getCaptcha")
public Map<String, Object> office_getCaptcha() throws IOException {
String cookie = request.getParameter("cookie");
String codeKey = request.getParameter("codeKey");
public Map<String, Object> office_getCaptcha(@RequestParam String cookie, @RequestParam String codeKey) throws IOException {

HashMap<String, String> headers = new HashMap<String, String>(){{
put("cookie", cookie);
Expand All @@ -183,13 +180,11 @@ public Map<String, Object> office_getCaptcha() throws IOException {
HttpUtil2 http = new HttpUtil2();
byte[] body = http.getContent("http://login.cuit.edu.cn:81/Login/xLogin/yzmDvCode.asp?k=" + codeKey, null, headers, "UTF-8");

ServletContext servletContext = request.getServletContext();
String OCR_SERVER = servletContext.getInitParameter("OCR_SERVER");
String s = http.doFilePost(OCR_SERVER, body);
Map<String, String> map = JsonUtil.string2Obj(s, Map.class);

return new HashMap<String, Object>(){{
put("code", 200);

put("base64img", "data:image/png;base64, " + new String(Base64.getEncoder().encode(body)));
put("imgCode", map.get("result"));
}};
Expand Down Expand Up @@ -232,7 +227,7 @@ public Map<String, Object> office_query() throws IOException, ParseException {
String msg = result.substring(result.lastIndexOf(">") + 1);

return new HashMap<String, Object>(){{
put("code", 200);

put("result", msg);
}};
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/cn/wecuit/backen/utils/HTTP/HttpUtil2.java
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ public class HttpUtil2 {
// 默认配置
unBuildConfig = RequestConfig.custom().setConnectTimeout(Timeout.ofSeconds(5))
.setResponseTimeout(Timeout.ofSeconds(5))
// .setProxy(new HttpHost("127.0.0.1", 8888))
.setProxy(new HttpHost("127.0.0.1", 8888))
.setCircularRedirectsAllowed(true);
localContext.setCookieStore(httpCookieStore);
}
Expand Down

0 comments on commit 766cb96

Please sign in to comment.