From 050103261f13afed3b0ce18367daddd316f246fc Mon Sep 17 00:00:00 2001 From: bamanker <27054792@qq.com> Date: Wed, 28 Dec 2022 00:20:12 +0800 Subject: [PATCH] =?UTF-8?q?0.0.4:=20=E4=BF=AE=E6=94=B9=E4=B8=BA=E6=97=A9?= =?UTF-8?q?=E5=AE=89=E6=8E=A8=E9=80=81=E5=92=8C=E6=99=9A=E5=AE=89=E6=8E=A8?= =?UTF-8?q?=E9=80=81=20=E5=A2=9E=E5=8A=A0=E4=BA=86=E5=86=9C=E5=8E=86?= =?UTF-8?q?=E6=97=A5=E6=9C=9F=E7=9A=84=E5=92=8C=E8=8A=82=E6=97=A5=E8=8A=82?= =?UTF-8?q?=E6=B0=94=E7=9A=84=E6=98=BE=E7=A4=BA=20=E6=9B=B4=E6=94=B9?= =?UTF-8?q?=E4=BA=86=E6=8E=A8=E9=80=81=E7=9A=84=E6=96=87=E5=AD=97=20?= =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E4=BA=86=E7=A9=BA=E6=B0=94=E8=B4=A8=E9=87=8F?= =?UTF-8?q?=20=E5=88=A0=E9=99=A4=E4=BA=86=E8=8B=B1=E6=96=87=E6=AF=8F?= =?UTF-8?q?=E6=97=A5=E4=B8=80=E5=8F=A5=20=E5=A2=9E=E5=8A=A0=E4=BA=86?= =?UTF-8?q?=E7=94=9F=E6=B4=BB=E5=B0=8F=E8=B4=B4=E5=A3=AB=20=E4=BF=AE?= =?UTF-8?q?=E6=94=B9=E4=BA=86=E5=AD=97=E4=BD=93=E9=A2=9C=E8=89=B2=20?= =?UTF-8?q?=E4=BC=98=E5=8C=96=E4=BA=86=E4=BB=A3=E7=A0=81=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pom.xml | 2 +- .../dailylove/config/DailyLoveConfigure.java | 102 +++++++--- .../bamanker/dailylove/config/PushTask.java | 11 +- .../controller/PushDailyController.java | 174 ++++++++++++++---- .../bamanker/dailylove/domain/Weather.java | 4 +- .../dailylove/service/DataRemoteClient.java | 12 ++ src/main/resources/bootstrap.yml | 29 +-- .../dailylove/DailyLoveApplicationTests.java | 108 +++++------ 8 files changed, 306 insertions(+), 136 deletions(-) diff --git a/pom.xml b/pom.xml index 6dc75f9..8a3b068 100644 --- a/pom.xml +++ b/pom.xml @@ -10,7 +10,7 @@ com.bamanker dailyLove - 0.0.3 + 0.0.4 dailyLove dailyLove diff --git a/src/main/java/com/bamanker/dailylove/config/DailyLoveConfigure.java b/src/main/java/com/bamanker/dailylove/config/DailyLoveConfigure.java index 59fa0a8..e6fb6d8 100644 --- a/src/main/java/com/bamanker/dailylove/config/DailyLoveConfigure.java +++ b/src/main/java/com/bamanker/dailylove/config/DailyLoveConfigure.java @@ -5,80 +5,118 @@ import org.springframework.stereotype.Component; @Component public class DailyLoveConfigure { + public static String Color_quality; + public static String Color_morning; + public static String Color_chineseDate; + public static String Color_festival; + public static String Color_night; + + public static String Color_tomorrow; + + @Value("${wechat.color.tomorrow:null}") + public void setColor_tomorrow(String color_tomorrow) { + Color_tomorrow = color_tomorrow; + } + + @Value("${wechat.color.quality:null}") + public void setColor_quality(String color_quality) { + Color_quality = color_quality; + } + + @Value("${wechat.color.morning:null}") + public void setColor_morning(String color_morning) { + Color_morning = color_morning; + } + + @Value("${wechat.color.chineseDate:null}") + public void setColor_chineseDate(String color_chineseDate) { + Color_chineseDate = color_chineseDate; + } + + @Value("${wechat.color.festival:null}") + public void setColor_festival(String color_festival) { + Color_festival = color_festival; + } + + @Value("${wechat.color.night:null}") + public void setColor_night(String color_night) { + Color_night = color_night; + } + // public static String Access_URL = "https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid={0}&secret={1}"; // public static String Send_URL = "https://api.weixin.qq.com/cgi-bin/message/template/send?access_token={0}"; - @Value("${wechat.color.city}") + @Value("${wechat.color.city:null}") public void setColor_city(String color_city) { Color_city = color_city; } - public static String Color_Now = null; - public static String Color_city = null; - public static String Color_weather = null; - public static String Color_minTem = null; - public static String Color_maxTem = null; - public static String Color_tips = null; - public static String Color_dailyCn = null; - public static String Color_dailyEn = null; - public static String Color_gbir = null; - public static String Color_bbir = null; - public static String Color_loveDay = null; - public static String Color_remark = null; + public static String Color_Now; + public static String Color_city; + public static String Color_weather; + public static String Color_minTem; + public static String Color_maxTem; + public static String Color_tips; + public static String Color_dailyCn; + public static String Color_dailyEn; + public static String Color_gbir; + public static String Color_bbir; + public static String Color_loveDay; + public static String Color_remark; - @Value("${wechat.color.weather}") + @Value("${wechat.color.weather:null}") public void setColor_weather(String color_weather) { Color_weather = color_weather; } - @Value("${wechat.color.minTem}") + @Value("${wechat.color.minTem:null}") public void setColor_minTem(String color_minTem) { Color_minTem = color_minTem; } - @Value("${wechat.color.maxTem}") + @Value("${wechat.color.maxTem:null}") public void setColor_maxTem(String color_maxTem) { Color_maxTem = color_maxTem; } - @Value("${wechat.color.tips}") + @Value("${wechat.color.tips:null}") public void setColor_tips(String color_tips) { Color_tips = color_tips; } - @Value("${wechat.color.dailyCn}") + @Value("${wechat.color.dailyCn:null}") public void setColor_dailyCn(String color_dailyCn) { Color_dailyCn = color_dailyCn; } - @Value("${wechat.color.dailyEn}") + @Value("${wechat.color.dailyEn:null}") public void setColor_dailyEn(String color_dailyEn) { Color_dailyEn = color_dailyEn; } - @Value("${wechat.color.gbir}") + @Value("${wechat.color.gbir:null}") public void setColor_gbir(String color_gbir) { Color_gbir = color_gbir; } - @Value("${wechat.color.bbir}") + @Value("${wechat.color.bbir:null}") public void setColor_bbir(String color_bbir) { Color_bbir = color_bbir; } - @Value("${wechat.color.loveDay}") + @Value("${wechat.color.loveDay:null}") public void setColor_loveDay(String color_loveDay) { Color_loveDay = color_loveDay; } - @Value("${wechat.color.remark}") + @Value("${wechat.color.remark:null}") public void setColor_remark(String color_remark) { Color_remark = color_remark; } - @Value("${wechat.color.now}") + @Value("${wechat.color.now:null}") public void setColor_Now(String color_Now) { Color_Now = color_Now; } @@ -104,13 +142,21 @@ public class DailyLoveConfigure { Open_ID = OpenID; } - public static String Template_ID; + public static String Template_ID_Morning; - @Value("${wechat.template-id}") - public void setTemplateID(String TemplateID) { - Template_ID = TemplateID; + @Value("${wechat.template-id-morning}") + public void setTemplateIDMorning(String templateIDMorning) { + Template_ID_Morning = templateIDMorning; } + public static String Template_ID_Night; + + @Value("${wechat.template-id-night}") + public void setTemplateIDNight(String templateIDNight) { + Template_ID_Night = templateIDNight; + } + + public static String City_ID; @Value("${DL.city-id}") diff --git a/src/main/java/com/bamanker/dailylove/config/PushTask.java b/src/main/java/com/bamanker/dailylove/config/PushTask.java index d758442..39e4a02 100644 --- a/src/main/java/com/bamanker/dailylove/config/PushTask.java +++ b/src/main/java/com/bamanker/dailylove/config/PushTask.java @@ -12,8 +12,13 @@ public class PushTask { PushDailyController pushDailyController; //每日 早上8,12,22点 定时推送 - @Scheduled(cron = "0 0 8 * * ?") - public void scheduledPush(){ - pushDailyController.push(); + @Scheduled(cron = "0 30 7 * * ?") + public void scheduledPushMorning(){ + pushDailyController.pushMorning(); + } + + @Scheduled(cron = "0 0 22 * * ?") + public void scheduledPushNight(){ + pushDailyController.pushNight(); } } diff --git a/src/main/java/com/bamanker/dailylove/controller/PushDailyController.java b/src/main/java/com/bamanker/dailylove/controller/PushDailyController.java index 660958d..0358c28 100644 --- a/src/main/java/com/bamanker/dailylove/controller/PushDailyController.java +++ b/src/main/java/com/bamanker/dailylove/controller/PushDailyController.java @@ -1,5 +1,7 @@ package com.bamanker.dailylove.controller; +import cn.hutool.core.date.ChineseDate; +import cn.hutool.core.date.DateUtil; import com.alibaba.fastjson2.JSONArray; import com.alibaba.fastjson2.JSONObject; import com.bamanker.dailylove.config.DailyLoveConfigure; @@ -14,6 +16,7 @@ import org.springframework.web.bind.annotation.RestController; import javax.annotation.Resource; import java.text.SimpleDateFormat; +import java.util.Calendar; import java.util.Date; @Slf4j @@ -29,30 +32,115 @@ public class PushDailyController { String remark = "❤"; /** - * 推送 + * 推送晚安 + * + * @return */ - @GetMapping("/push") - public String push() { + @GetMapping("/pushNight") + public String pushNight() { + + ResultVo resultVo = ResultVo.initializeResultVo(DailyLoveConfigure.Open_ID, + DailyLoveConfigure.Template_ID_Night, + DailyLoveConfigure.Color_Top); + + TianXinReqParam param1 = new TianXinReqParam(); + param1.setKey(DailyLoveConfigure.TianXin_Key); + param1.setCity(DailyLoveConfigure.City_ID); + param1.setType("7"); + String weatherResp = dataRemoteClient.getWeather(param1); + JSONObject weatherJson = JSONObject.parseObject(weatherResp).getJSONArray("result").getJSONObject(0).getJSONArray("list").getJSONObject(1); + String city = JSONObject.parseObject(weatherResp).getJSONArray("result").getJSONObject(0).getString("area"); + Weather weather = weatherJson.toJavaObject(Weather.class); + + resultVo.setAttribute("tomorrow", new DataItem(weather.getDate() + " " + weather.getWeek(), DailyLoveConfigure.Color_tomorrow)); + resultVo.setAttribute("city", new DataItem(city, DailyLoveConfigure.Color_city)); + resultVo.setAttribute("weather", new DataItem(weather.getWeather(), DailyLoveConfigure.Color_weather)); + resultVo.setAttribute("min_temperature", new DataItem(weather.getLowest(), DailyLoveConfigure.Color_minTem)); + resultVo.setAttribute("max_temperature", new DataItem(weather.getHighest(), DailyLoveConfigure.Color_maxTem)); + resultVo.setAttribute("quality", new DataItem(weather.getVis(), DailyLoveConfigure.Color_quality)); + + + TianXinReqParam param2 = new TianXinReqParam(); + param2.setKey(DailyLoveConfigure.TianXin_Key); + + String tipsResp = dataRemoteClient.getTips(param2); + String tips = JSONObject.parseObject(tipsResp).getJSONArray("result").getJSONObject(0).getString("content"); + resultVo.setAttribute("tips", new DataItem(tips, DailyLoveConfigure.Color_tips)); + + String nightResp = dataRemoteClient.getNight(param2); + String night = JSONObject.parseObject(nightResp).getJSONArray("result").getJSONObject(0).getString("content"); + resultVo.setAttribute("night", new DataItem(night, DailyLoveConfigure.Color_night)); + + String rainbowResp = dataRemoteClient.getRainbow(param2); + String rainbow = JSONObject.parseObject(rainbowResp).getJSONArray("result").getJSONObject(0).getString("content"); + resultVo.setAttribute("daily_english_cn", new DataItem(rainbow, DailyLoveConfigure.Color_dailyCn)); + + String englishResp = dataRemoteClient.getDailyEnglish(param2); + String english = JSONObject.parseObject(englishResp).getJSONArray("result").getJSONObject(0).getString("en"); + resultVo.setAttribute("daily_english_en", new DataItem(english, DailyLoveConfigure.Color_dailyEn)); + + + ChineseDate chineseDate = new ChineseDate(DateUtil.parseDate(weather.getDate())); + String festival = chineseDate.getFestivals(); + String term = chineseDate.getTerm(); + resultVo.setAttribute("lunar", new DataItem(chineseDate.toString(), DailyLoveConfigure.Color_chineseDate)); + resultVo.setAttribute("festival", new DataItem(festival + " " + term, DailyLoveConfigure.Color_festival)); + + + int girlBirthdays = DataUtils.getBirthdays(DailyLoveConfigure.Girl_Birthday); + log.debug("gbir_day:{}", girlBirthdays); + resultVo.setAttribute("gbir_day", new DataItem(girlBirthdays - 1 + "", DailyLoveConfigure.Color_gbir)); + + int boyBirthdays = DataUtils.getChineseBirthdays(DailyLoveConfigure.Boy_Birthday); + log.debug("bbir_day:{}", boyBirthdays); + resultVo.setAttribute("bbir_day", new DataItem(boyBirthdays - 1 + "", DailyLoveConfigure.Color_bbir)); + + if (DataUtils.getBirthdays(DailyLoveConfigure.Love_Day) == 1) { + remark = "明天是恋爱周年纪念日!永远爱你~mua"; + } else if ((DataUtils.getLoveDays(DailyLoveConfigure.Love_Day)) % 100 == 1) { + remark = "明天是恋爱百日纪念日!提前庆祝哦~"; + } else if (girlBirthdays == 1) { + remark = "明天是lili大宝贝的生日啦"; + } else if (boyBirthdays == 1) { + remark = "明天是songsong的生日!别忘了哦~"; + } + + resultVo.setAttribute("remark", new DataItem(remark, DailyLoveConfigure.Color_remark)); + + int loveDays = DataUtils.getLoveDays(DailyLoveConfigure.Love_Day); + log.debug("love_day:{}", loveDays); + resultVo.setAttribute("love_day", new DataItem(loveDays + 1 + "", DailyLoveConfigure.Color_loveDay)); + + log.debug("resultVo:{}", resultVo); + WechatTokenParam wechatTokenParam = new WechatTokenParam(); + wechatTokenParam.setAppid(DailyLoveConfigure.App_ID); + wechatTokenParam.setSecret(DailyLoveConfigure.App_Secret); + + String accessTokenResp = wechatRequestClient.getAccessToken(wechatTokenParam); + log.debug("accessTokenJson:{}", accessTokenResp); + String token = JSONObject.parseObject(accessTokenResp).getString("access_token"); + String responseStr = wechatRequestClient.sendMsg(resultVo, token); + return responseStr; + + } + + /** + * 推送早安 + */ + @GetMapping("/pushMorning") + public String pushMorning() { TianXinReqParam param1 = new TianXinReqParam(); param1.setKey(DailyLoveConfigure.TianXin_Key); param1.setCity(DailyLoveConfigure.City_ID); param1.setType("1"); - String weatherJson = dataRemoteClient.getWeather(param1); - - log.debug("weather:{}", weatherJson); - JSONObject responseWeather = JSONObject.parseObject(weatherJson); - log.debug("weatherJson:{}", responseWeather); - JSONObject resultWeather = responseWeather.getJSONArray("result").getJSONObject(0); - JSONArray result1 = responseWeather.getJSONArray("result"); - log.debug("-----------------{}", result1); - log.debug("weatherJsonNewList:{}", resultWeather); - Weather weather = resultWeather.toJavaObject(Weather.class); - log.debug("weatherJsonNewList:{}", weather.toString()); + String weatherResp = dataRemoteClient.getWeather(param1); + Weather weather = JSONObject.parseObject(weatherResp).getJSONArray("result").getJSONObject(0).toJavaObject(Weather.class); + ; ResultVo resultVo = ResultVo.initializeResultVo(DailyLoveConfigure.Open_ID, - DailyLoveConfigure.Template_ID, + DailyLoveConfigure.Template_ID_Morning, DailyLoveConfigure.Color_Top); resultVo.setAttribute("now", new DataItem(weather.getDate() + " " + weather.getWeek(), DailyLoveConfigure.Color_Now)); @@ -60,41 +148,53 @@ public class PushDailyController { resultVo.setAttribute("weather", new DataItem(weather.getWeather(), DailyLoveConfigure.Color_weather)); resultVo.setAttribute("min_temperature", new DataItem(weather.getLowest(), DailyLoveConfigure.Color_minTem)); resultVo.setAttribute("max_temperature", new DataItem(weather.getHighest(), DailyLoveConfigure.Color_maxTem)); - resultVo.setAttribute("tips", new DataItem(weather.getTips(), DailyLoveConfigure.Color_tips)); + resultVo.setAttribute("quality", new DataItem(weather.getQuality(), DailyLoveConfigure.Color_quality)); TianXinReqParam param2 = new TianXinReqParam(); param2.setKey(DailyLoveConfigure.TianXin_Key); - String rainbowJson = dataRemoteClient.getRainbow(param2); - log.debug("rainbowJson:{}", rainbowJson); - JSONObject responseRainbow = JSONObject.parseObject(rainbowJson); - String rainbow = responseRainbow.getJSONArray("result").getJSONObject(0).getString("content"); - log.debug("rainbow:{}", rainbow); + + String tipsResp = dataRemoteClient.getTips(param2); + String tips = JSONObject.parseObject(tipsResp).getJSONArray("result").getJSONObject(0).getString("content"); + resultVo.setAttribute("tips", new DataItem(tips, DailyLoveConfigure.Color_tips)); + + String morningResp = dataRemoteClient.getMorning(param2); + String morning = JSONObject.parseObject(morningResp).getJSONArray("result").getJSONObject(0).getString("content"); + resultVo.setAttribute("morning", new DataItem(morning, DailyLoveConfigure.Color_morning)); + + String rainbowResp = dataRemoteClient.getRainbow(param2); + String rainbow = JSONObject.parseObject(rainbowResp).getJSONArray("result").getJSONObject(0).getString("content"); resultVo.setAttribute("daily_english_cn", new DataItem(rainbow, DailyLoveConfigure.Color_dailyCn)); - - - String englishJson = dataRemoteClient.getDailyEnglish(param2); - log.debug("englishJson:{}", englishJson); - JSONObject responseEnglist = JSONObject.parseObject(englishJson); - String english = responseEnglist.getJSONArray("result").getJSONObject(0).getString("en"); - log.debug("english:{}", english); + String englishResp = dataRemoteClient.getDailyEnglish(param2); + String english = JSONObject.parseObject(englishResp).getJSONArray("result").getJSONObject(0).getString("en"); resultVo.setAttribute("daily_english_en", new DataItem(english, DailyLoveConfigure.Color_dailyEn)); + SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd"); + Date date = new Date(); + String currentTime = dateFormat.format(date); + ChineseDate chineseDate = new ChineseDate(DateUtil.parseDate(currentTime)); + String festival = chineseDate.getFestivals(); + String term = chineseDate.getTerm(); + resultVo.setAttribute("lunar", new DataItem(chineseDate.toString(), DailyLoveConfigure.Color_chineseDate)); + resultVo.setAttribute("festival", new DataItem(festival + " " + term, DailyLoveConfigure.Color_festival)); + + int girlBirthdays = DataUtils.getBirthdays(DailyLoveConfigure.Girl_Birthday); log.debug("gbir_day:{}", girlBirthdays); resultVo.setAttribute("gbir_day", new DataItem(girlBirthdays + "", DailyLoveConfigure.Color_gbir)); - int boyBirthdays = DataUtils.getBirthdays(DailyLoveConfigure.Boy_Birthday); + + int boyBirthdays = DataUtils.getChineseBirthdays(DailyLoveConfigure.Boy_Birthday); log.debug("bbir_day:{}", boyBirthdays); resultVo.setAttribute("bbir_day", new DataItem(boyBirthdays + "", DailyLoveConfigure.Color_bbir)); - if(DataUtils.getBirthdays(DailyLoveConfigure.Love_Day) == 0){ + if (DataUtils.getBirthdays(DailyLoveConfigure.Love_Day) == 0) { remark = "今天是恋爱周年纪念日!永远爱你~mua"; - }else if((DataUtils.getLoveDays(DailyLoveConfigure.Love_Day))%100 == 0){ + } else if ((DataUtils.getLoveDays(DailyLoveConfigure.Love_Day)) % 100 == 0) { remark = "今天是恋爱百日纪念日!永远爱你~"; - }else if(girlBirthdays == 0){ + } else if (girlBirthdays == 0) { remark = "今天是lili大宝贝的生日!生日快乐哟~"; - }else if(boyBirthdays == 0){ + } else if (boyBirthdays == 0) { remark = "今天是songsong的生日!别忘了好好爱他~"; } @@ -109,12 +209,10 @@ public class PushDailyController { wechatTokenParam.setAppid(DailyLoveConfigure.App_ID); wechatTokenParam.setSecret(DailyLoveConfigure.App_Secret); - String accessTokenJson = wechatRequestClient.getAccessToken(wechatTokenParam); - log.debug("accessTokenJson:{}", accessTokenJson); - JSONObject responseToken = JSONObject.parseObject(accessTokenJson); - String token = responseToken.getString("access_token"); + String accessTokenResp = wechatRequestClient.getAccessToken(wechatTokenParam); + log.debug("accessTokenJson:{}", accessTokenResp); + String token = JSONObject.parseObject(accessTokenResp).getString("access_token"); String responseStr = wechatRequestClient.sendMsg(resultVo, token); - log.info("{}",responseStr); return responseStr; } diff --git a/src/main/java/com/bamanker/dailylove/domain/Weather.java b/src/main/java/com/bamanker/dailylove/domain/Weather.java index 12da99c..8400c87 100644 --- a/src/main/java/com/bamanker/dailylove/domain/Weather.java +++ b/src/main/java/com/bamanker/dailylove/domain/Weather.java @@ -13,7 +13,9 @@ public class Weather { private String area; private String weather; private String lowest; + + private String vis; private String highest; - private String tips; + private String quality; } diff --git a/src/main/java/com/bamanker/dailylove/service/DataRemoteClient.java b/src/main/java/com/bamanker/dailylove/service/DataRemoteClient.java index ef148c9..19474fe 100644 --- a/src/main/java/com/bamanker/dailylove/service/DataRemoteClient.java +++ b/src/main/java/com/bamanker/dailylove/service/DataRemoteClient.java @@ -28,5 +28,17 @@ public interface DataRemoteClient { consumes = {MediaType.APPLICATION_JSON_VALUE}, produces = {MediaType.APPLICATION_JSON_VALUE}) String getDailyEnglish(@SpringQueryMap TianXinReqParam param); + @GetMapping(value = "/qiaomen/index", + consumes = {MediaType.APPLICATION_JSON_VALUE}, + produces = {MediaType.APPLICATION_JSON_VALUE}) + String getTips(@SpringQueryMap TianXinReqParam param); + @GetMapping(value = "/zaoan/index", + consumes = {MediaType.APPLICATION_JSON_VALUE}, + produces = {MediaType.APPLICATION_JSON_VALUE}) + String getMorning(@SpringQueryMap TianXinReqParam param); + @GetMapping(value = "/wanan/index", + consumes = {MediaType.APPLICATION_JSON_VALUE}, + produces = {MediaType.APPLICATION_JSON_VALUE}) + String getNight(@SpringQueryMap TianXinReqParam param); } diff --git a/src/main/resources/bootstrap.yml b/src/main/resources/bootstrap.yml index 49e210f..e2db220 100644 --- a/src/main/resources/bootstrap.yml +++ b/src/main/resources/bootstrap.yml @@ -32,22 +32,29 @@ wechat: #ME: oo5bL6bK_4TC0tb-Wa5oiugTPVeQ #LILI: oo5bL6QafHJa9zQNYKS0fIhFC0zM open-id: oo5bL6QafHJa9zQNYKS0fIhFC0zM - template-id: QAEWkGL9HfDGxHQDilIBaux8HylTTsEn_3MjI6bTFhc + template-id-morning: 0qVcDob-3INv8Jh_Odd5nl9gfgA0LYpvBMYcqqP03rA + template-id-night: TUL17fAJ4g69_7PjpgvrQwKxr8KC4fYQxMIAl0e3L9s color: - now: '#00BFFF' + now: '#99CCCC' + tomorrow: '#99CCCC' + chineseDate: '#99CC66' top: '#FF0000' - weather: '#1f95c5' - minTem: '#0ace3c' - maxTem: '#dc1010' - dailyCn: '#FF69B4' - dailyEn: '#800080' - gbir: '#FFA500' - bbir: '#FFA500' - loveDay: '#FF1493' - remark: '#FF1493' + weather: '#66CCCC' + minTem: '#0066CC' + maxTem: '#FF0033' + dailyCn: '#993366' + dailyEn: '#CC99CC' + gbir: '#FF3399' + bbir: '#FF3399' + loveDay: '#FF3399' + remark: '#FF6666' city: "" tips: "" + quality: '#99CC66' + festival: '#FF6666' + morning: '#FFFF99' + night: '#006699' tianxin: server: https://apis.tianapi.com diff --git a/src/test/java/com/bamanker/dailylove/DailyLoveApplicationTests.java b/src/test/java/com/bamanker/dailylove/DailyLoveApplicationTests.java index 8d17542..fd1b22e 100644 --- a/src/test/java/com/bamanker/dailylove/DailyLoveApplicationTests.java +++ b/src/test/java/com/bamanker/dailylove/DailyLoveApplicationTests.java @@ -145,60 +145,60 @@ class DailyLoveApplicationTests { @Test void contextLoads() { - TianXinReqParam param1 = new TianXinReqParam(); - param1.setKey(DailyLoveConfigure.TianXin_Key); - param1.setCity(DailyLoveConfigure.City_ID); - param1.setType("1"); - String weatherJson = dataRemoteClient.getWeather(param1); - log.info("weather:{}", weatherJson); - JSONObject responseWeather = JSONObject.parseObject(weatherJson); - log.info("weatherJson:{}", responseWeather); - JSONObject resultWeather = responseWeather.getJSONArray("result").getJSONObject(0); - JSONArray result1 = responseWeather.getJSONArray("result"); - log.info("-----------------{}", result1); - log.info("weatherJsonNewList:{}", resultWeather); - Weather weather = resultWeather.toJavaObject(Weather.class); - log.info("weatherJsonNewList:{}", weather.toString()); - - - ResultVo resultVo = ResultVo.initializeResultVo(DailyLoveConfigure.Open_ID, - DailyLoveConfigure.Template_ID, - DailyLoveConfigure.Color_Top); - resultVo.setAttribute("now", new DataItem(weather.getDate() + " " + weather.getWeek(), "#00BFFF")); - resultVo.setAttribute("city", new DataItem(weather.getArea(), null)); - resultVo.setAttribute("weather", new DataItem(weather.getWeather(), "#1f95c5")); - resultVo.setAttribute("min_temperature", new DataItem(weather.getLowest(), "#0ace3c")); - resultVo.setAttribute("max_temperature", new DataItem(weather.getHighest(), "#dc1010")); - resultVo.setAttribute("tips", new DataItem(weather.getTips(), null)); - - - TianXinReqParam param2 = new TianXinReqParam(); - param2.setKey(DailyLoveConfigure.TianXin_Key); - String rainbowJson = dataRemoteClient.getRainbow(param2); - log.info("rainbowJson:{}", rainbowJson); - JSONObject responseRainbow = JSONObject.parseObject(rainbowJson); - String rainbow = responseRainbow.getJSONArray("result").getJSONObject(0).getString("content"); - log.info("rainbow:{}", rainbow); - resultVo.setAttribute("daily_english_cn", new DataItem(rainbow, "#FF69B4")); - resultVo.setAttribute("remark", new DataItem(remark, "#FF1493")); - - - String englishJson = dataRemoteClient.getDailyEnglish(param2); - log.info("englishJson:{}", englishJson); - JSONObject responseEnglist = JSONObject.parseObject(englishJson); - String englist = responseEnglist.getJSONArray("result").getJSONObject(0).getString("en"); - log.info("english:{}", englist); - resultVo.setAttribute("daily_english_en", new DataItem(rainbow, "#800080")); - - int birthdays = DataUtils.getBirthdays(DailyLoveConfigure.Girl_Birthday); - log.info("bir_day:{}", birthdays); - resultVo.setAttribute("bir_day", new DataItem(birthdays + "", "#FFA500")); - - int loveDays = DataUtils.getLoveDays(DailyLoveConfigure.Love_Day); - log.info("love_day:{}", loveDays); - resultVo.setAttribute("love_day", new DataItem(loveDays + "", "#FFA500")); - - log.info("resultVo:{}", resultVo); +// TianXinReqParam param1 = new TianXinReqParam(); +// param1.setKey(DailyLoveConfigure.TianXin_Key); +// param1.setCity(DailyLoveConfigure.City_ID); +// param1.setType("1"); +// String weatherJson = dataRemoteClient.getWeather(param1); +// log.info("weather:{}", weatherJson); +// JSONObject responseWeather = JSONObject.parseObject(weatherJson); +// log.info("weatherJson:{}", responseWeather); +// JSONObject resultWeather = responseWeather.getJSONArray("result").getJSONObject(0); +// JSONArray result1 = responseWeather.getJSONArray("result"); +// log.info("-----------------{}", result1); +// log.info("weatherJsonNewList:{}", resultWeather); +// Weather weather = resultWeather.toJavaObject(Weather.class); +// log.info("weatherJsonNewList:{}", weather.toString()); +// +// +// ResultVo resultVo = ResultVo.initializeResultVo(DailyLoveConfigure.Open_ID, +// DailyLoveConfigure.Template_ID, +// DailyLoveConfigure.Color_Top); +// resultVo.setAttribute("now", new DataItem(weather.getDate() + " " + weather.getWeek(), "#00BFFF")); +// resultVo.setAttribute("city", new DataItem(weather.getArea(), null)); +// resultVo.setAttribute("weather", new DataItem(weather.getWeather(), "#1f95c5")); +// resultVo.setAttribute("min_temperature", new DataItem(weather.getLowest(), "#0ace3c")); +// resultVo.setAttribute("max_temperature", new DataItem(weather.getHighest(), "#dc1010")); +// resultVo.setAttribute("tips", new DataItem(weather.getTips(), null)); +// +// +// TianXinReqParam param2 = new TianXinReqParam(); +// param2.setKey(DailyLoveConfigure.TianXin_Key); +// String rainbowJson = dataRemoteClient.getRainbow(param2); +// log.info("rainbowJson:{}", rainbowJson); +// JSONObject responseRainbow = JSONObject.parseObject(rainbowJson); +// String rainbow = responseRainbow.getJSONArray("result").getJSONObject(0).getString("content"); +// log.info("rainbow:{}", rainbow); +// resultVo.setAttribute("daily_english_cn", new DataItem(rainbow, "#FF69B4")); +// resultVo.setAttribute("remark", new DataItem(remark, "#FF1493")); +// +// +// String englishJson = dataRemoteClient.getDailyEnglish(param2); +// log.info("englishJson:{}", englishJson); +// JSONObject responseEnglist = JSONObject.parseObject(englishJson); +// String englist = responseEnglist.getJSONArray("result").getJSONObject(0).getString("en"); +// log.info("english:{}", englist); +// resultVo.setAttribute("daily_english_en", new DataItem(rainbow, "#800080")); +// +// int birthdays = DataUtils.getBirthdays(DailyLoveConfigure.Girl_Birthday); +// log.info("bir_day:{}", birthdays); +// resultVo.setAttribute("bir_day", new DataItem(birthdays + "", "#FFA500")); +// +// int loveDays = DataUtils.getLoveDays(DailyLoveConfigure.Love_Day); +// log.info("love_day:{}", loveDays); +// resultVo.setAttribute("love_day", new DataItem(loveDays + "", "#FFA500")); +// +// log.info("resultVo:{}", resultVo); }