Initial commit
This commit is contained in:
@@ -0,0 +1,18 @@
|
||||
package com.bamanker.dailylove;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.cloud.openfeign.EnableFeignClients;
|
||||
import org.springframework.scheduling.annotation.EnableScheduling;
|
||||
|
||||
@SpringBootApplication
|
||||
@EnableFeignClients
|
||||
//开启定时任务
|
||||
@EnableScheduling
|
||||
public class DailyLoveApplication {
|
||||
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(DailyLoveApplication.class, args);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,158 @@
|
||||
package com.bamanker.dailylove.config;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Component
|
||||
public class DailyLoveConfigure {
|
||||
|
||||
// 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}")
|
||||
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;
|
||||
|
||||
@Value("${wechat.color.weather}")
|
||||
public void setColor_weather(String color_weather) {
|
||||
Color_weather = color_weather;
|
||||
}
|
||||
|
||||
@Value("${wechat.color.minTem}")
|
||||
public void setColor_minTem(String color_minTem) {
|
||||
Color_minTem = color_minTem;
|
||||
}
|
||||
|
||||
@Value("${wechat.color.maxTem}")
|
||||
public void setColor_maxTem(String color_maxTem) {
|
||||
Color_maxTem = color_maxTem;
|
||||
}
|
||||
|
||||
@Value("${wechat.color.tips}")
|
||||
public void setColor_tips(String color_tips) {
|
||||
Color_tips = color_tips;
|
||||
}
|
||||
|
||||
@Value("${wechat.color.dailyCn}")
|
||||
public void setColor_dailyCn(String color_dailyCn) {
|
||||
Color_dailyCn = color_dailyCn;
|
||||
}
|
||||
|
||||
@Value("${wechat.color.dailyEn}")
|
||||
public void setColor_dailyEn(String color_dailyEn) {
|
||||
Color_dailyEn = color_dailyEn;
|
||||
}
|
||||
|
||||
@Value("${wechat.color.gbir}")
|
||||
public void setColor_gbir(String color_gbir) {
|
||||
Color_gbir = color_gbir;
|
||||
}
|
||||
|
||||
@Value("${wechat.color.bbir}")
|
||||
public void setColor_bbir(String color_bbir) {
|
||||
Color_bbir = color_bbir;
|
||||
}
|
||||
|
||||
@Value("${wechat.color.loveDay}")
|
||||
public void setColor_loveDay(String color_loveDay) {
|
||||
Color_loveDay = color_loveDay;
|
||||
}
|
||||
|
||||
@Value("${wechat.color.remark}")
|
||||
public void setColor_remark(String color_remark) {
|
||||
Color_remark = color_remark;
|
||||
}
|
||||
|
||||
@Value("${wechat.color.now}")
|
||||
public void setColor_Now(String color_Now) {
|
||||
Color_Now = color_Now;
|
||||
}
|
||||
|
||||
public static String App_ID;
|
||||
|
||||
@Value("${wechat.app-id}")
|
||||
public void setAppID(String AppID) {
|
||||
App_ID = AppID;
|
||||
}
|
||||
|
||||
public static String App_Secret;
|
||||
|
||||
@Value("${wechat.app-secret}")
|
||||
public void setAppSecret(String AppSecret) {
|
||||
App_Secret = AppSecret;
|
||||
}
|
||||
|
||||
public static String Open_ID;
|
||||
|
||||
@Value("${wechat.open-id}")
|
||||
public void setOpenID(String OpenID) {
|
||||
Open_ID = OpenID;
|
||||
}
|
||||
|
||||
public static String Template_ID;
|
||||
|
||||
@Value("${wechat.template-id}")
|
||||
public void setTemplateID(String TemplateID) {
|
||||
Template_ID = TemplateID;
|
||||
}
|
||||
|
||||
public static String City_ID;
|
||||
|
||||
@Value("${DL.city-id}")
|
||||
public void setCity_ID(String city_ID) {
|
||||
City_ID = city_ID;
|
||||
}
|
||||
|
||||
|
||||
public static String Color_Top = null;
|
||||
|
||||
@Value("${wechat.color.top}")
|
||||
public void setColor_Top(String colorTop) {
|
||||
Color_Top = colorTop;
|
||||
}
|
||||
|
||||
public static String TianXin_Key;
|
||||
|
||||
@Value("${DL.tianxin-key}")
|
||||
public void setTianXin_Key(String tianXin_Key) {
|
||||
TianXin_Key = tianXin_Key;
|
||||
}
|
||||
|
||||
|
||||
public static String Boy_Birthday;
|
||||
|
||||
@Value("${DL.boy-birthday}")
|
||||
public void setBoyBirthday(String BoyBirthday) {
|
||||
Boy_Birthday = BoyBirthday;
|
||||
}
|
||||
|
||||
public static String Girl_Birthday;
|
||||
|
||||
@Value("${DL.girl-birthday}")
|
||||
public void setGirlBirthday(String GirlBirthday) {
|
||||
Girl_Birthday = GirlBirthday;
|
||||
}
|
||||
|
||||
//
|
||||
public static String Love_Day;
|
||||
|
||||
@Value("${DL.love-day}")
|
||||
public void setLoveDay(String LoveDay) {
|
||||
Love_Day = LoveDay;
|
||||
}
|
||||
}
|
||||
15
src/main/java/com/bamanker/dailylove/config/FeignConfig.java
Normal file
15
src/main/java/com/bamanker/dailylove/config/FeignConfig.java
Normal file
@@ -0,0 +1,15 @@
|
||||
package com.bamanker.dailylove.config;
|
||||
|
||||
import feign.Logger;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
@Configuration
|
||||
public class FeignConfig
|
||||
{
|
||||
@Bean
|
||||
Logger.Level feignLoggerLevel()
|
||||
{
|
||||
return Logger.Level.FULL;
|
||||
}
|
||||
}
|
||||
19
src/main/java/com/bamanker/dailylove/config/PushTask.java
Normal file
19
src/main/java/com/bamanker/dailylove/config/PushTask.java
Normal file
@@ -0,0 +1,19 @@
|
||||
package com.bamanker.dailylove.config;
|
||||
|
||||
import com.bamanker.dailylove.controller.PushDailyController;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.scheduling.annotation.Scheduled;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Component
|
||||
public class PushTask {
|
||||
|
||||
@Autowired
|
||||
PushDailyController pushDailyController;
|
||||
|
||||
//每日 早上8,12,22点 定时推送
|
||||
@Scheduled(cron = "0 0 8,12,22 * * ?")
|
||||
public void scheduledPush(){
|
||||
pushDailyController.push();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,136 @@
|
||||
package com.bamanker.dailylove.controller;
|
||||
|
||||
import com.alibaba.fastjson2.JSONArray;
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import com.bamanker.dailylove.config.DailyLoveConfigure;
|
||||
import com.bamanker.dailylove.domain.*;
|
||||
import com.bamanker.dailylove.service.DataRemoteClient;
|
||||
import com.bamanker.dailylove.service.WechatRequestClient;
|
||||
import com.bamanker.dailylove.utils.DataUtils;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
|
||||
@Slf4j
|
||||
@RestController
|
||||
public class PushDailyController {
|
||||
|
||||
@Resource
|
||||
DataRemoteClient dataRemoteClient;
|
||||
|
||||
@Resource
|
||||
WechatRequestClient wechatRequestClient;
|
||||
|
||||
String remark = "❤";
|
||||
|
||||
/**
|
||||
* 推送
|
||||
*/
|
||||
@GetMapping("/push")
|
||||
public String push() {
|
||||
|
||||
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());
|
||||
|
||||
|
||||
ResultVo resultVo = ResultVo.initializeResultVo(DailyLoveConfigure.Open_ID,
|
||||
DailyLoveConfigure.Template_ID,
|
||||
DailyLoveConfigure.Color_Top);
|
||||
|
||||
resultVo.setAttribute("now", new DataItem(weather.getDate() + " " + weather.getWeek(), DailyLoveConfigure.Color_Now));
|
||||
resultVo.setAttribute("city", new DataItem(weather.getArea(), 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("tips", new DataItem(weather.getTips(), DailyLoveConfigure.Color_tips));
|
||||
|
||||
|
||||
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);
|
||||
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);
|
||||
resultVo.setAttribute("daily_english_en", new DataItem(english, DailyLoveConfigure.Color_dailyEn));
|
||||
|
||||
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);
|
||||
log.debug("bbir_day:{}", boyBirthdays);
|
||||
resultVo.setAttribute("bbir_day", new DataItem(boyBirthdays + "", DailyLoveConfigure.Color_bbir));
|
||||
|
||||
if(DataUtils.getBirthdays(DailyLoveConfigure.Love_Day) == 0){
|
||||
remark = "今天是恋爱周年纪念日!永远爱你~mua";
|
||||
}else if((DataUtils.getLoveDays(DailyLoveConfigure.Love_Day))%100 == 0){
|
||||
remark = "今天是恋爱百日纪念日!永远爱你~";
|
||||
}else if(girlBirthdays == 0){
|
||||
remark = "今天是lili大宝贝的生日!生日快乐哟~";
|
||||
}else if(boyBirthdays == 0){
|
||||
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 + "", DailyLoveConfigure.Color_loveDay));
|
||||
|
||||
log.debug("resultVo:{}", resultVo);
|
||||
WechatTokenParam wechatTokenParam = new WechatTokenParam();
|
||||
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 responseStr = wechatRequestClient.sendMsg(resultVo, token);
|
||||
log.info("{}",responseStr);
|
||||
return responseStr;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 打印 response log
|
||||
*
|
||||
* @param responseStr
|
||||
*/
|
||||
private void printPushLog(String responseStr) {
|
||||
JSONObject jsonObject = JSONObject.parseObject(responseStr);
|
||||
String msgCode = jsonObject.getString("errcode");
|
||||
String msgContent = jsonObject.getString("errmsg");
|
||||
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
System.out.println("[ " + dateFormat.format(new Date()) + " ] : messageCode=" + msgCode + ",messageContent=" + msgContent);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
14
src/main/java/com/bamanker/dailylove/domain/DataItem.java
Normal file
14
src/main/java/com/bamanker/dailylove/domain/DataItem.java
Normal file
@@ -0,0 +1,14 @@
|
||||
package com.bamanker.dailylove.domain;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class DataItem {
|
||||
private String value;
|
||||
private String color;
|
||||
|
||||
}
|
||||
34
src/main/java/com/bamanker/dailylove/domain/ResultVo.java
Normal file
34
src/main/java/com/bamanker/dailylove/domain/ResultVo.java
Normal file
@@ -0,0 +1,34 @@
|
||||
package com.bamanker.dailylove.domain;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class ResultVo {
|
||||
private String touser;
|
||||
private String template_id;
|
||||
|
||||
private String topColor;
|
||||
private HashMap<String,DataItem> data;
|
||||
|
||||
public static ResultVo initializeResultVo(String _touser, String _template_id, String _topcolor){
|
||||
return new ResultVo(_touser,_template_id,_topcolor,null);
|
||||
}
|
||||
|
||||
public static ResultVo initializeResultVo(String _touser, String _template_id, String _topcolor,HashMap<String, DataItem> _data){
|
||||
return new ResultVo(_touser,_template_id,_topcolor,_data);
|
||||
}
|
||||
|
||||
public ResultVo setAttribute(String key, DataItem item){
|
||||
if(this.data==null) {
|
||||
this.data = new HashMap<String,DataItem>();
|
||||
}
|
||||
this.data.put(key,item);
|
||||
return this;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
package com.bamanker.dailylove.domain;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
@Builder
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class TianXinReqParam {
|
||||
private String key;
|
||||
private String city;
|
||||
private String type;
|
||||
|
||||
public TianXinReqParam(String key) {
|
||||
this.key=key;
|
||||
}
|
||||
}
|
||||
19
src/main/java/com/bamanker/dailylove/domain/Weather.java
Normal file
19
src/main/java/com/bamanker/dailylove/domain/Weather.java
Normal file
@@ -0,0 +1,19 @@
|
||||
package com.bamanker.dailylove.domain;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class Weather {
|
||||
private String date;
|
||||
private String week;
|
||||
private String area;
|
||||
private String weather;
|
||||
private String lowest;
|
||||
private String highest;
|
||||
private String tips;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
package com.bamanker.dailylove.domain;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class WechatTokenParam {
|
||||
private final String grant_type = "client_credential";
|
||||
private String appid;
|
||||
|
||||
private String secret;
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
package com.bamanker.dailylove.service;
|
||||
|
||||
|
||||
import com.bamanker.dailylove.domain.TianXinReqParam;
|
||||
import org.springframework.cloud.openfeign.FeignClient;
|
||||
import org.springframework.cloud.openfeign.SpringQueryMap;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
|
||||
/**
|
||||
* 天行数据第三方接口
|
||||
* @author baman
|
||||
*/
|
||||
@Component
|
||||
@FeignClient(value = "TianXinDataRemoteClient",url = "${tianxin.server}")
|
||||
public interface DataRemoteClient {
|
||||
|
||||
@GetMapping(value = "/tianqi/index",
|
||||
consumes = {MediaType.APPLICATION_JSON_VALUE},
|
||||
produces = {MediaType.APPLICATION_JSON_VALUE})
|
||||
String getWeather(@SpringQueryMap TianXinReqParam param);
|
||||
@GetMapping(value = "/caihongpi/index",
|
||||
consumes = {MediaType.APPLICATION_JSON_VALUE},
|
||||
produces = {MediaType.APPLICATION_JSON_VALUE})
|
||||
String getRainbow(@SpringQueryMap TianXinReqParam param);
|
||||
@GetMapping(value = "/ensentence/index",
|
||||
consumes = {MediaType.APPLICATION_JSON_VALUE},
|
||||
produces = {MediaType.APPLICATION_JSON_VALUE})
|
||||
String getDailyEnglish(@SpringQueryMap TianXinReqParam param);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
package com.bamanker.dailylove.service;
|
||||
|
||||
import com.bamanker.dailylove.config.DailyLoveConfigure;
|
||||
import com.bamanker.dailylove.domain.ResultVo;
|
||||
import com.bamanker.dailylove.domain.WechatTokenParam;
|
||||
import org.springframework.cloud.openfeign.FeignClient;
|
||||
import org.springframework.cloud.openfeign.SpringQueryMap;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
|
||||
@Component
|
||||
@FeignClient(value = "WechatRequestClient", url = "https://api.weixin.qq.com/cgi-bin")
|
||||
public interface WechatRequestClient {
|
||||
|
||||
@GetMapping("/token")
|
||||
String getAccessToken(@SpringQueryMap WechatTokenParam param);
|
||||
|
||||
@PostMapping("/message/template/send?access_token={token}")
|
||||
String sendMsg(ResultVo resultVo, @RequestParam("token") String token);
|
||||
}
|
||||
60
src/main/java/com/bamanker/dailylove/utils/DataUtils.java
Normal file
60
src/main/java/com/bamanker/dailylove/utils/DataUtils.java
Normal file
@@ -0,0 +1,60 @@
|
||||
package com.bamanker.dailylove.utils;
|
||||
|
||||
import org.springframework.util.unit.DataUnit;
|
||||
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Calendar;
|
||||
|
||||
public class DataUtils {
|
||||
|
||||
/**
|
||||
* 计算生日天数 days
|
||||
* @param birthday
|
||||
* @return
|
||||
*/
|
||||
public static int getBirthdays(String birthday) {
|
||||
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
|
||||
// 存今天
|
||||
Calendar dateToday = Calendar.getInstance();
|
||||
// 存生日
|
||||
Calendar dateBirth = Calendar.getInstance();
|
||||
int days = 0;
|
||||
try {
|
||||
// 设置生日
|
||||
dateBirth.setTime(dateFormat.parse(birthday));
|
||||
// 修改为本年
|
||||
dateBirth.set(Calendar.YEAR, dateToday.get(Calendar.YEAR));
|
||||
if (dateBirth.get(Calendar.DAY_OF_YEAR) < dateToday.get(Calendar.DAY_OF_YEAR)) {
|
||||
// 生日已经过了,要算明年的了
|
||||
days = (dateToday.getActualMaximum(Calendar.DAY_OF_YEAR) - dateToday.get(Calendar.DAY_OF_YEAR))
|
||||
+ dateBirth.get(Calendar.DAY_OF_YEAR);
|
||||
} else {
|
||||
// 生日还没过
|
||||
days = dateBirth.get(Calendar.DAY_OF_YEAR) - dateToday.get(Calendar.DAY_OF_YEAR);
|
||||
|
||||
}
|
||||
} catch (ParseException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return days;
|
||||
}
|
||||
|
||||
/**
|
||||
* 计算恋爱天数 days
|
||||
* @param loveday
|
||||
* @return
|
||||
*/
|
||||
public static int getLoveDays(String loveday) {
|
||||
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
|
||||
int days = 0;
|
||||
try {
|
||||
long time = System.currentTimeMillis() - dateFormat.parse(loveday).getTime();
|
||||
days = (int) (time / (24 * 60 * 60 * 1000));
|
||||
|
||||
} catch (ParseException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return days;
|
||||
}
|
||||
}
|
||||
57
src/main/resources/bootstrap.yml
Normal file
57
src/main/resources/bootstrap.yml
Normal file
@@ -0,0 +1,57 @@
|
||||
server:
|
||||
port: 13145
|
||||
|
||||
spring:
|
||||
application:
|
||||
name: dailyLove
|
||||
cloud:
|
||||
nacos:
|
||||
config:
|
||||
server-addr: ${url.nacos} # nacos地址配置中心
|
||||
file-extension: yaml
|
||||
group: Group1
|
||||
|
||||
discovery:
|
||||
#持久化实例 ture为临时实例 false为持久化实例 临时实例发生异常直接剔除, 而持久化实例等待恢复
|
||||
ephemeral: true
|
||||
#注册中心地址
|
||||
server-addr: ${url.nacos}
|
||||
url:
|
||||
nacos: 127.0.0.1:8848
|
||||
|
||||
DL:
|
||||
tianxin-key: 72fbbb9e75e338ea6a240e83972f287c
|
||||
city-id: 101270101
|
||||
girl-birthday: 1995-06-28
|
||||
boy-birthday: 1995-03-30
|
||||
love-day: 2022-07-16
|
||||
|
||||
wechat:
|
||||
app-id: wxba68702957f8b93e
|
||||
app-secret: 834078bb149409bfca4fe693ea7c4c1c
|
||||
#ME: oo5bL6bK_4TC0tb-Wa5oiugTPVeQ
|
||||
#LILI: oo5bL6QafHJa9zQNYKS0fIhFC0zM
|
||||
open-id: oo5bL6QafHJa9zQNYKS0fIhFC0zM
|
||||
template-id: QAEWkGL9HfDGxHQDilIBaux8HylTTsEn_3MjI6bTFhc
|
||||
|
||||
color:
|
||||
now: '#00BFFF'
|
||||
top: '#FF0000'
|
||||
weather: '#1f95c5'
|
||||
minTem: '#0ace3c'
|
||||
maxTem: '#dc1010'
|
||||
dailyCn: '#FF69B4'
|
||||
dailyEn: '#800080'
|
||||
gbir: '#FFA500'
|
||||
bbir: '#FFA500'
|
||||
loveDay: '#FF1493'
|
||||
remark: '#FF1493'
|
||||
city: ""
|
||||
tips: ""
|
||||
|
||||
tianxin:
|
||||
server: https://apis.tianapi.com
|
||||
|
||||
logging:
|
||||
level:
|
||||
com.bamanker.dailylove.service: debug #指定openfeign日志以什么级别监控哪个接口(可多个)
|
||||
Reference in New Issue
Block a user