src/main/java/com/smartearth/poiexcel/config/InitConfig.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
src/main/java/com/smartearth/poiexcel/controller/EntController.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
src/main/java/com/smartearth/poiexcel/entity/Result.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
src/main/java/com/smartearth/poiexcel/entity/TokenResult.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
src/main/java/com/smartearth/poiexcel/service/EntService.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
src/main/resources/application.properties | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 |
src/main/java/com/smartearth/poiexcel/config/InitConfig.java
@@ -1,5 +1,9 @@ package com.smartearth.poiexcel.config; import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONObject; import com.smartearth.poiexcel.entity.Result; import com.smartearth.poiexcel.entity.TokenResult; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.springframework.boot.ApplicationArguments; @@ -18,9 +22,20 @@ public void run(ApplicationArguments args) { // noinspection AlibabaRemoveCommentedCode try { test(); log.info("***************** ç³»ç»å¯å¨å®æ¯ *****************" + "\n"); } catch (Exception ex) { log.error(ex.getMessage(), ex); } } private void test() { String json = "{\"success\":true,\"code\":200,\"message\":\"æå\",\"data\":{\"ctoken\":\"ZmYxZTgyN2QxZTYyNDMxMDhjZjgzNDNiNDZiN2RjMDVAYTc3ZmFlOGE5ZGM0OGQ1Y2ZmODY4ZTFmNWYwZTEzM2E=\",\"userInfo\":{\"loginLogId\":\"1ab1675c3632428a84dc0ebe579cd66f\",\"phoneNumber\":\"\",\"displayName\":\"æ¶ç©ºä¸å¼ å¾\",\"userMail\":\"\",\"departLevel\":\"5-1\",\"id\":\"ff1e827d1e6243108cf8343b46b7dc05\",\"userID\":\"shikong001\",\"uniqueID\":\"\",\"departName\":\"æ±½è½¦åæºè½å¶é 产ä¸ä¸ç\"},\"expires\":3600,\"roles\":[]}}"; Result rs = JSON.parseObject(json, Result.class); // TokenResult tr = JSON.parseObject(rs.getData().toJSONString(), TokenResult.class) TokenResult tr = JSONObject.parseObject(rs.getData(), TokenResult.class); int len = json.length(); } } src/main/java/com/smartearth/poiexcel/controller/EntController.java
@@ -1,6 +1,8 @@ package com.smartearth.poiexcel.controller; import com.smartearth.poiexcel.entity.ResponseMsg; import com.smartearth.poiexcel.entity.Result; import com.smartearth.poiexcel.entity.TokenResult; import io.swagger.annotations.Api; import io.swagger.annotations.ApiImplicitParam; import io.swagger.annotations.ApiImplicitParams; @@ -25,6 +27,7 @@ @GetMapping({"/selectCount"}) public ResponseMsg<Integer> selectCount(String name) { try { //Result<TokenResult> rs = new Result<>(); return success(0); src/main/java/com/smartearth/poiexcel/entity/Result.java
¶Ô±ÈÐÂÎļþ @@ -0,0 +1,52 @@ package com.smartearth.poiexcel.entity; import com.alibaba.fastjson.JSONObject; /** * ç»æç±» * @author WWW */ public class Result { public Result() { } private Boolean success; private Integer code; private String message; private String data; public Boolean getSuccess() { return success; } public void setSuccess(Boolean success) { this.success = success; } public Integer getCode() { return code; } public void setCode(Integer code) { this.code = code; } public String getMessage() { return message; } public void setMessage(String message) { this.message = message; } public String getData() { return data; } public void setData(String data) { this.data = data; } } src/main/java/com/smartearth/poiexcel/entity/TokenResult.java
¶Ô±ÈÐÂÎļþ @@ -0,0 +1,139 @@ package com.smartearth.poiexcel.entity; import java.io.Serializable; /** * 令çç»æç±» * @author WWW */ public class TokenResult implements Serializable { private static final long serialVersionUID = -8624235184539814992L; private String ctoken; private UserInfo userInfo; private Integer expires; public static class UserInfo { public UserInfo() { } private String loginLogId; private String phoneNumber; private String displayName; private String userMail; private String departLevel; private String id; private String userID; private String uniqueID; private String departName; public String getLoginLogId() { return loginLogId; } public void setLoginLogId(String loginLogId) { this.loginLogId = loginLogId; } public String getPhoneNumber() { return phoneNumber; } public void setPhoneNumber(String phoneNumber) { this.phoneNumber = phoneNumber; } public String getDisplayName() { return displayName; } public void setDisplayName(String displayName) { this.displayName = displayName; } public String getUserMail() { return userMail; } public void setUserMail(String userMail) { this.userMail = userMail; } public String getDepartLevel() { return departLevel; } public void setDepartLevel(String departLevel) { this.departLevel = departLevel; } public String getId() { return id; } public void setId(String id) { this.id = id; } public String getUserID() { return userID; } public void setUserID(String userID) { this.userID = userID; } public String getUniqueID() { return uniqueID; } public void setUniqueID(String uniqueID) { this.uniqueID = uniqueID; } public String getDepartName() { return departName; } public void setDepartName(String departName) { this.departName = departName; } } public TokenResult() { } public String getCtoken() { return ctoken; } public void setCtoken(String ctoken) { this.ctoken = ctoken; } public UserInfo getUserInfo() { return userInfo; } public void setUserInfo(UserInfo userInfo) { this.userInfo = userInfo; } public Integer getExpires() { return expires; } public void setExpires(Integer expires) { this.expires = expires; } } src/main/java/com/smartearth/poiexcel/service/EntService.java
@@ -24,8 +24,8 @@ @Resource EntMapper entMapper; @Value("${qylweb.url}") String url; @Value("${qylweb.host}") String host; @Value("${qylweb.user}") String user; @@ -39,6 +39,21 @@ private final static String getEntBaseInfo = "%s/yqfwg/api/project/getEntBaseInfoForOtherSysListPage?ctoken=%s&buildDate_startdate=%s&buildDate_enddate=%s&qylabel=%s&showCount=%d¤tPage=%d"; public String getToken() { try { String url = String.format(generateToken, host); Map<String, String> map = new HashMap<>(2); map.put("userName", user); map.put("passWord", pwd); return null; } catch (Exception ex) { log.error(ex.getMessage(), ex); return null; } } /** * post请æ±ï¼Restï¼ */ @@ -51,14 +66,14 @@ /** * delete请æ±ï¼Restï¼ */ public Object deleteForRest(String url, Map<String, Object> map) { public <T> T deleteForRest(String url, Map<String, T> map, Class<T> clazz) { HttpHeaders headers = new HttpHeaders(); headers.setContentType(MediaType.APPLICATION_JSON); HttpEntity<?> entity = new HttpEntity<>(map, headers); RestTemplate rest = RestHelper.getRestTemplate(); ResponseEntity<Object> rs = rest.exchange(url, HttpMethod.DELETE, entity, Object.class); ResponseEntity<T> rs = rest.exchange(url, HttpMethod.DELETE, entity, clazz); return rs.getBody(); } src/main/resources/application.properties
@@ -18,6 +18,6 @@ mybatis-plus.config-location=classpath:mybatis.xml mybatis-plus.mapper-locations=classpath:mapper/**/*.xml qylweb.url=https://qylweb.bda.gov.cn qylweb.host=https://qylweb.bda.gov.cn qylweb.user=shikong001 qylweb.pwd=123!@#qwe