1
This commit is contained in:
38
pom.xml
38
pom.xml
@@ -31,6 +31,24 @@
|
|||||||
<artifactId>spring-boot-starter-test</artifactId>
|
<artifactId>spring-boot-starter-test</artifactId>
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
|
||||||
|
<!--
|
||||||
|
降级Java的版本:降级到Java 8或者更低版本,这些版本包含了这些包。
|
||||||
|
添加缺失的依赖:如果你不希望降级Java的版本,你可以通过添加缺失的依赖来解决这个问题。
|
||||||
|
如果缺少的是javax.rmi.CORBA包,添加以下依赖:
|
||||||
|
-->
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>javax.rmi</groupId>
|
||||||
|
<artifactId>javax.rmi-api</artifactId>
|
||||||
|
<version>1.0.2.Final</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>javax.activation</groupId>
|
||||||
|
<artifactId>activation</artifactId>
|
||||||
|
<version>1.1.1</version>
|
||||||
|
</dependency>
|
||||||
<!-- redis 缓存操作 -->
|
<!-- redis 缓存操作 -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.springframework.boot</groupId>
|
<groupId>org.springframework.boot</groupId>
|
||||||
@@ -96,7 +114,27 @@
|
|||||||
<artifactId>lombok</artifactId>
|
<artifactId>lombok</artifactId>
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<!-- 京东依赖-->
|
||||||
|
<dependency>
|
||||||
|
|
||||||
|
<groupId>org.codehaus.jackson</groupId>
|
||||||
|
|
||||||
|
<artifactId>jackson-mapper-asl</artifactId>
|
||||||
|
|
||||||
|
<version>1.9.2</version>
|
||||||
|
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
|
||||||
|
<groupId>org.codehaus.jackson</groupId>
|
||||||
|
|
||||||
|
<artifactId>jackson-core-asl</artifactId>
|
||||||
|
|
||||||
|
<version>1.9.2</version>
|
||||||
|
|
||||||
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
<dependencyManagement>
|
<dependencyManagement>
|
||||||
<dependencies>
|
<dependencies>
|
||||||
|
|||||||
@@ -0,0 +1,49 @@
|
|||||||
|
package cn.van333.wxsend.business.controller;
|
||||||
|
|
||||||
|
import cn.hutool.core.util.ObjectUtil;
|
||||||
|
import cn.hutool.core.util.StrUtil;
|
||||||
|
import cn.van333.wxsend.aop.annotation.RateLimiter;
|
||||||
|
import cn.van333.wxsend.business.model.R;
|
||||||
|
import cn.van333.wxsend.business.service.LogService;
|
||||||
|
import cn.van333.wxsend.enums.WXMessageType;
|
||||||
|
import cn.van333.wxsend.util.SourceForQLUtil;
|
||||||
|
import cn.van333.wxsend.util.TokenUtil;
|
||||||
|
import cn.van333.wxsend.util.WxSendUtil;
|
||||||
|
import cn.van333.wxsend.util.request.MessageRequest;
|
||||||
|
import com.alibaba.fastjson2.JSON;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.ResponseBody;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Leo
|
||||||
|
* @version 1.0
|
||||||
|
* @create 2023/10/07 0007 下午 02:25
|
||||||
|
* @description:
|
||||||
|
*/
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/dc")
|
||||||
|
public class DCController {
|
||||||
|
private static final Logger logger = LoggerFactory.getLogger(LogService.class);
|
||||||
|
|
||||||
|
@RequestMapping(value = "/send/ty")
|
||||||
|
@ResponseBody
|
||||||
|
@RateLimiter(time = 10, count = 60)
|
||||||
|
public R sendToTY(@RequestBody MessageRequest message) throws Exception {
|
||||||
|
logger.info(message.toString());
|
||||||
|
|
||||||
|
if (!TokenUtil.checkToken(message.getVanToken())) {
|
||||||
|
return R.error("vanToken无效");
|
||||||
|
}
|
||||||
|
if (!StrUtil.isAllNotEmpty(message.getTitle(), message.getText())) {
|
||||||
|
return R.error("缺少标题和内容");
|
||||||
|
}
|
||||||
|
String result = WxSendUtil.sendNotify(message.getTitle(), message.getText(), message.getTouser(), WXMessageType.TY);
|
||||||
|
return R.ok(result);
|
||||||
|
}
|
||||||
|
}
|
||||||
61
src/main/java/cn/van333/wxsend/util/JDUtils.java
Normal file
61
src/main/java/cn/van333/wxsend/util/JDUtils.java
Normal file
@@ -0,0 +1,61 @@
|
|||||||
|
package cn.van333.wxsend.util;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson2.JSON;
|
||||||
|
import com.jd.open.api.sdk.DefaultJdClient;
|
||||||
|
import com.jd.open.api.sdk.JdClient;
|
||||||
|
import com.jd.open.api.sdk.domain.kplunion.OrderService.request.query.OrderRowReq;
|
||||||
|
import com.jd.open.api.sdk.domain.kplunion.OrderService.response.query.OrderRowResp;
|
||||||
|
import com.jd.open.api.sdk.request.JdRequest;
|
||||||
|
import com.jd.open.api.sdk.request.kplunion.UnionOpenOrderRowQueryRequest;
|
||||||
|
import com.jd.open.api.sdk.response.AbstractResponse;
|
||||||
|
import com.jd.open.api.sdk.response.kplunion.UnionOpenOrderRowQueryResponse;
|
||||||
|
|
||||||
|
import java.text.SimpleDateFormat;
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Leo
|
||||||
|
* @version 1.0
|
||||||
|
* @create 2024/11/5 17:40
|
||||||
|
* @description:
|
||||||
|
*/
|
||||||
|
public class JDUtils {
|
||||||
|
private static final String SERVER_URL =
|
||||||
|
"https://api.jd.com/routerjson";
|
||||||
|
private static final String APP_KEY =
|
||||||
|
"98e21c89ae5610240ec3f5f575f86a59";
|
||||||
|
private static final String SECRET_KEY =
|
||||||
|
"3dcb6b23a1104639ac433fd07adb6dfb";
|
||||||
|
|
||||||
|
|
||||||
|
public static void main(String[] args) throws Exception {
|
||||||
|
String accessToken = "";
|
||||||
|
JdClient client = new DefaultJdClient(SERVER_URL, accessToken, APP_KEY, SECRET_KEY);
|
||||||
|
UnionOpenOrderRowQueryRequest request = new UnionOpenOrderRowQueryRequest();
|
||||||
|
OrderRowReq orderReq = new OrderRowReq();
|
||||||
|
orderReq.setPageIndex(1);
|
||||||
|
orderReq.setPageSize(20);
|
||||||
|
orderReq.setStartTime("2024-11-01 00:00:00");
|
||||||
|
orderReq.setEndTime("2024-11-05 23:59:59");
|
||||||
|
orderReq.setType(1);
|
||||||
|
|
||||||
|
|
||||||
|
request.setOrderReq(orderReq);
|
||||||
|
request.setVersion("1.0");
|
||||||
|
request.setSignmethod("md5");
|
||||||
|
// 时间戳,格式为yyyy-MM-dd HH:mm:ss,时区为GMT+8。API服务端允许客户端请求最大时间误差为10分钟
|
||||||
|
Date date = new Date();
|
||||||
|
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||||
|
request.setTimestamp(simpleDateFormat.format(date));
|
||||||
|
|
||||||
|
|
||||||
|
UnionOpenOrderRowQueryResponse response = client.execute(request);
|
||||||
|
System.out.println("响应码:" + response.getQueryResult().getCode());
|
||||||
|
System.out.println(JSON.toJSONString(response));
|
||||||
|
OrderRowResp[] orderRowResps = response.getQueryResult().getData();
|
||||||
|
//for (OrderRowResp orderRowResp : orderRowResps) {
|
||||||
|
// System.out.println(orderRowResp.getOrderId());
|
||||||
|
//}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user