diff --git a/ruoyi-modules/Property/src/main/java/org/dromara/property/utils/HolidayUtil.java b/ruoyi-modules/Property/src/main/java/org/dromara/property/utils/HolidayUtil.java new file mode 100644 index 0000000..eba2b9b --- /dev/null +++ b/ruoyi-modules/Property/src/main/java/org/dromara/property/utils/HolidayUtil.java @@ -0,0 +1,36 @@ +package org.dromara.property.utils; + +import java.io.BufferedReader; +import java.io.InputStreamReader; +import java.net.HttpURLConnection; +import java.net.URL; +import org.json.JSONObject; + +/** + * 法定节假日工具类 + */ +public class HolidayUtil { + + public HolidayUtil() throws Exception { + // 调用jiejiariapi.com API获取节假日信息 + String baiduUrl = "https://api.jiejiariapi.com/v1/holidays/2025"; + JSONObject jiejiariapiResponse = getJsonFromUrl(baiduUrl); + } + + private static JSONObject getJsonFromUrl(String urlString) throws Exception { + URL url = new URL(urlString); + HttpURLConnection connection = (HttpURLConnection) url.openConnection(); + connection.setRequestMethod("GET"); + connection.connect(); + + BufferedReader reader = new BufferedReader(new InputStreamReader(connection.getInputStream(), "UTF-8")); + StringBuilder response = new StringBuilder(); + String line; + while ((line = reader.readLine()) != null) { + response.append(line); + } + reader.close(); + + return new JSONObject(response.toString()); + } +}