1
This commit is contained in:
@@ -0,0 +1,41 @@
|
|||||||
|
package com.ruoyi.web.controller.jarvis;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson2.JSONObject;
|
||||||
|
import com.ruoyi.common.utils.http.HttpUtils;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Leo
|
||||||
|
* @version 1.0
|
||||||
|
* @create 2025/8/15 10:53
|
||||||
|
* @description:京东指令类
|
||||||
|
*/
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/jarvis/jdorder")
|
||||||
|
public class JDOrderController {
|
||||||
|
|
||||||
|
private final static String skey = "2192057370ef8140c201079969c956a3";
|
||||||
|
private final static String requestUrl = "http://192.168.8.88:6666/jd/";
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@RequestMapping("/generatePromotionContent")
|
||||||
|
public String generatePromotionContent(String promotionContent) {
|
||||||
|
System.out.println(promotionContent);
|
||||||
|
String result = "";
|
||||||
|
try {
|
||||||
|
String url = requestUrl+ "generatePromotionContent";
|
||||||
|
JSONObject param = new JSONObject();
|
||||||
|
param.put("skey", skey);
|
||||||
|
param.put("promotionContent", promotionContent);
|
||||||
|
result = HttpUtils.sendJsonPost(url, param.toJSONString());
|
||||||
|
System.out.println(result);
|
||||||
|
} catch (Exception e) {
|
||||||
|
System.out.println(e.getMessage());
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -25,7 +25,7 @@ import org.springframework.http.MediaType;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 通用http发送方法
|
* 通用http发送方法
|
||||||
*
|
*
|
||||||
* @author ruoyi
|
* @author ruoyi
|
||||||
*/
|
*/
|
||||||
public class HttpUtils
|
public class HttpUtils
|
||||||
@@ -129,10 +129,21 @@ public class HttpUtils
|
|||||||
{
|
{
|
||||||
return sendPost(url, param, MediaType.APPLICATION_FORM_URLENCODED_VALUE);
|
return sendPost(url, param, MediaType.APPLICATION_FORM_URLENCODED_VALUE);
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
* 向指定 URL 发送POST方法的请求,请求体为JSON格式
|
||||||
|
*
|
||||||
|
* @param url 发送请求的 URL
|
||||||
|
* @param json JSON格式的请求体
|
||||||
|
* @return 所代表远程资源的响应结果
|
||||||
|
*/
|
||||||
|
public static String sendJsonPost(String url, String json)
|
||||||
|
{
|
||||||
|
return sendPost(url, json, MediaType.APPLICATION_JSON_VALUE);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 向指定 URL 发送POST方法的请求
|
* 向指定 URL 发送POST方法的请求
|
||||||
*
|
*
|
||||||
* @param url 发送请求的 URL
|
* @param url 发送请求的 URL
|
||||||
* @param param 请求参数
|
* @param param 请求参数
|
||||||
* @param contentType 内容类型
|
* @param contentType 内容类型
|
||||||
@@ -290,4 +301,4 @@ public class HttpUtils
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user