| | |
| | | import com.xiaopeng.common.core.utils.HttpUtils; |
| | | import com.xiaopeng.common.redis.service.RedisService; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.data.redis.core.RedisTemplate; |
| | | import org.springframework.beans.factory.annotation.Value; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | import java.time.Duration; |
| | |
| | | @Autowired |
| | | private RedisService redisService; |
| | | |
| | | @Value("${holiday.api.url}") |
| | | private String holidayApiUrl; |
| | | |
| | | |
| | | public boolean isHoliday() { |
| | | LocalDate now = LocalDate.now(); |
| | |
| | | if (redisService.getCacheObject(CacheConstants.IS_HOLIDAY+now) != null && ("1").equals(redisService.getCacheObject(CacheConstants.IS_HOLIDAY+now).toString())) { |
| | | return true; |
| | | } |
| | | String result = HttpUtils.sendGet("https://publicapi.xiaoai.me/holiday/day?date=" + now); |
| | | String result = HttpUtils.sendGet(holidayApiUrl + now); |
| | | // String result = HttpUtil.get("https://publicapi.xiaoai.me/holiday/day?date=" +now); |
| | | JSONObject jsonObject = JSONObject.parseObject(result); |
| | | Object data = jsonObject.get("data"); |
| | |
| | | if (cacheObject!=null) { |
| | | return Integer.valueOf(cacheObject.toString()); |
| | | } |
| | | String result = HttpUtils.sendGet("https://publicapi.xiaoai.me/holiday/day?date=" +now); |
| | | String result = HttpUtils.sendGet(holidayApiUrl + now); |
| | | |
| | | // String result = HttpUtils.sendGet("https://publicapi.xiaoai.me/holiday/day?date=2026-01-04"); |
| | | JSONObject jsonObject = JSONObject.parseObject(result); |
| | |
| | | if (cacheObject!=null) { |
| | | return Integer.valueOf(cacheObject.toString()); |
| | | } |
| | | String result = HttpUtils.sendGet("https://publicapi.xiaoai.me/holiday/day?date=" +now); |
| | | String result = HttpUtils.sendGet(holidayApiUrl + now); |
| | | |
| | | // String result = HttpUtils.sendGet("https://publicapi.xiaoai.me/holiday/day?date=2026-01-04"); |
| | | JSONObject jsonObject = JSONObject.parseObject(result); |