feat: 增加公田移动Rabchaser页面接口调用
parent
7285ede61c
commit
c29ceac5e4
@ -0,0 +1,66 @@
|
||||
package com.shxy.xymanager_common.sms.rabchaser;
|
||||
|
||||
import com.shxy.xymanager_common.exception.ApiException;
|
||||
import com.shxy.xymanager_common.util.HttpClient;
|
||||
import com.shxy.xymanager_common.util.JSONUtil;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
@Service
|
||||
@Slf4j
|
||||
public class RabchaserWeb {
|
||||
private String baseUrl = "http://www.rabchaser.com/api";
|
||||
public static String authorization = "";
|
||||
|
||||
public Object selectMsgReceive(String iccid, String date) {
|
||||
String url = "/cardquery/selectMsgReceiveByPage";
|
||||
Map<String, String> headMap = new HashMap<>();
|
||||
headMap.put("Authorization", authorization);
|
||||
Map<String, Object> dataMap = new HashMap<>();
|
||||
dataMap.put("iccid", iccid);
|
||||
// dataMap.put("receiveTime", date);
|
||||
dataMap.put("pageNum", 1);
|
||||
dataMap.put("pageSize", 10);
|
||||
try {
|
||||
HashMap<String, Object> result = null;
|
||||
String json = HttpClient.post(baseUrl + url, dataMap, headMap);
|
||||
log.info("查询短信记录完成: " + json);
|
||||
try {
|
||||
result = JSONUtil.json2Object(json, HashMap.class);
|
||||
} catch (Exception e) {
|
||||
throw new ApiException(json);
|
||||
}
|
||||
|
||||
if (result.get("code") != null && "200".equalsIgnoreCase(result.get("code").toString())) {
|
||||
return result.get("data");
|
||||
} else {
|
||||
String error = String.valueOf(result.get("message"));
|
||||
throw new ApiException(error);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error("查询短信异常.", e);
|
||||
throw new ApiException("查询短信异常," + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@PostConstruct
|
||||
private void login() {
|
||||
String url = "/user/login";
|
||||
Map<String, Object> dataMap = new HashMap<>();
|
||||
dataMap.put("loginName", "shxy");
|
||||
dataMap.put("password", "Admin@123");
|
||||
dataMap.put("rememberAccount", true);
|
||||
try {
|
||||
String json = HttpClient.post(baseUrl + url, dataMap, null);
|
||||
log.info("login完成: " + json);
|
||||
HashMap<String, Object> result = JSONUtil.json2Object(json, HashMap.class);
|
||||
authorization = "Bearer " + result.get("data").toString();
|
||||
} catch (Exception e) {
|
||||
log.error("短信登入失败.", e);
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue