parent
0ee72c1206
commit
b47e51233f
|
|
@ -1,8 +1,9 @@
|
||||||
package com.ruoyi.common.core.domain;
|
package com.ruoyi.common.core.domain;
|
||||||
|
|
||||||
import java.io.Serializable;
|
|
||||||
import com.ruoyi.common.core.constant.Constants;
|
import com.ruoyi.common.core.constant.Constants;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 响应信息主体
|
* 响应信息主体
|
||||||
*
|
*
|
||||||
|
|
@ -26,12 +27,12 @@ public class R<T> implements Serializable
|
||||||
|
|
||||||
public static <T> R<T> ok()
|
public static <T> R<T> ok()
|
||||||
{
|
{
|
||||||
return restResult(null, SUCCESS, null);
|
return restResult(null, SUCCESS, "操作成功");
|
||||||
}
|
}
|
||||||
|
|
||||||
public static <T> R<T> ok(T data)
|
public static <T> R<T> ok(T data)
|
||||||
{
|
{
|
||||||
return restResult(data, SUCCESS, null);
|
return restResult(data, SUCCESS, "操作成功");
|
||||||
}
|
}
|
||||||
|
|
||||||
public static <T> R<T> ok(T data, String msg)
|
public static <T> R<T> ok(T data, String msg)
|
||||||
|
|
@ -41,7 +42,7 @@ public class R<T> implements Serializable
|
||||||
|
|
||||||
public static <T> R<T> fail()
|
public static <T> R<T> fail()
|
||||||
{
|
{
|
||||||
return restResult(null, FAIL, null);
|
return restResult(null, FAIL, "操作失败");
|
||||||
}
|
}
|
||||||
|
|
||||||
public static <T> R<T> fail(String msg)
|
public static <T> R<T> fail(String msg)
|
||||||
|
|
@ -51,7 +52,7 @@ public class R<T> implements Serializable
|
||||||
|
|
||||||
public static <T> R<T> fail(T data)
|
public static <T> R<T> fail(T data)
|
||||||
{
|
{
|
||||||
return restResult(data, FAIL, null);
|
return restResult(data, FAIL, "操作失败");
|
||||||
}
|
}
|
||||||
|
|
||||||
public static <T> R<T> fail(T data, String msg)
|
public static <T> R<T> fail(T data, String msg)
|
||||||
|
|
|
||||||
|
|
@ -52,7 +52,9 @@ public class ApiConst {
|
||||||
|
|
||||||
public static final String ROLL_MOBILE_BELONG = "ROLL-手机归属地";
|
public static final String ROLL_MOBILE_BELONG = "ROLL-手机归属地";
|
||||||
|
|
||||||
public static final String ROLL_WEATHER = "ROLL-天气预报";
|
public static final String ROLL_NOW_WEATHER = "ROLL-实时天气";
|
||||||
|
|
||||||
|
public static final String ROLL_FORECAST_WEATHER = "ROLL-预报天气";
|
||||||
|
|
||||||
|
|
||||||
//-------------------url------------------------------
|
//-------------------url------------------------------
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,7 @@ package com.xjs.apitools.controller;
|
||||||
import com.ruoyi.common.core.domain.R;
|
import com.ruoyi.common.core.domain.R;
|
||||||
import com.ruoyi.common.log.annotation.Log;
|
import com.ruoyi.common.log.annotation.Log;
|
||||||
import com.ruoyi.common.security.annotation.RequiresPermissions;
|
import com.ruoyi.common.security.annotation.RequiresPermissions;
|
||||||
|
import com.xjs.apitools.domain.ApiForecastWeather;
|
||||||
import com.xjs.apitools.domain.ApiHoliday;
|
import com.xjs.apitools.domain.ApiHoliday;
|
||||||
import com.xjs.apitools.domain.ApiMobileBelong;
|
import com.xjs.apitools.domain.ApiMobileBelong;
|
||||||
import com.xjs.apitools.domain.ApiNowWeather;
|
import com.xjs.apitools.domain.ApiNowWeather;
|
||||||
|
|
@ -63,6 +64,12 @@ public class ApiToolsController {
|
||||||
return R.ok(apiToolsService.getNowWeather(city));
|
return R.ok(apiToolsService.getNowWeather(city));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@GetMapping("forecastweather/{city}")
|
||||||
|
@ApiOperation("获取预报天气信息")
|
||||||
|
@Log(title = "获取预报天气")
|
||||||
|
public R<ApiForecastWeather> getForecastWeatherApiData(@PathVariable("city") String city) {
|
||||||
|
return R.ok(apiToolsService.getForecastWeather(city));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,36 @@
|
||||||
|
package com.xjs.apitools.domain;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* api预报天气实体
|
||||||
|
* @author xiejs
|
||||||
|
* @since 2022-01-18
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class ApiForecastWeather {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 城市具体信息,比如 “广东省 深圳市”
|
||||||
|
*/
|
||||||
|
private String address;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 城市code
|
||||||
|
*/
|
||||||
|
private String cityCode;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 此次天气发布时间
|
||||||
|
*/
|
||||||
|
private String reportTime;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 今天及未来天气列表
|
||||||
|
*/
|
||||||
|
private List<Forecasts> forecasts;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -1,10 +1,11 @@
|
||||||
package com.xjs.apitools.domain;
|
package com.xjs.apitools.domain;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||||
import com.xjs.weather.domain.NowWeather;
|
import com.xjs.weather.domain.NowWeather;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* api天气实体
|
* api实时天气实体
|
||||||
*
|
*
|
||||||
* @author xiejs
|
* @author xiejs
|
||||||
* @since 2022-01-18
|
* @since 2022-01-18
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,20 @@
|
||||||
|
package com.xjs.apitools.domain;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||||
|
import com.xjs.weather.domain.Casts;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* roll预报天气实体
|
||||||
|
* @author xiejs
|
||||||
|
* @since 2022-01-18
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class Forecasts extends Casts {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 星期
|
||||||
|
*/
|
||||||
|
private String dayOfWeek;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,42 @@
|
||||||
|
package com.xjs.apitools.factory.impl;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson.JSONObject;
|
||||||
|
import com.xjs.apitools.domain.ApiForecastWeather;
|
||||||
|
import com.xjs.apitools.domain.RequestBody;
|
||||||
|
import com.xjs.apitools.factory.ApiToolsFactory;
|
||||||
|
import com.xjs.common.client.api.roll.RollWeatherFeignClient;
|
||||||
|
import com.xjs.config.RollProperties;
|
||||||
|
import lombok.extern.log4j.Log4j2;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import static com.xjs.consts.ApiConst.DEMOTE_ERROR;
|
||||||
|
import static com.xjs.consts.ApiConst.ROLL_CODE_SUCCESS;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author xiejs
|
||||||
|
* @since 2022-01-18
|
||||||
|
*/
|
||||||
|
@Component
|
||||||
|
@Log4j2
|
||||||
|
public class RollForecastWeatherFactory implements ApiToolsFactory<ApiForecastWeather, RequestBody> {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private RollProperties rollProperties;
|
||||||
|
@Autowired
|
||||||
|
private RollWeatherFeignClient rollWeatherFeignClient;
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ApiForecastWeather apiData(RequestBody requestBody) {
|
||||||
|
requestBody.setApp_id(rollProperties.getApp_id());
|
||||||
|
requestBody.setApp_secret(rollProperties.getApp_secret());
|
||||||
|
JSONObject jsonObject = rollWeatherFeignClient.forecastWeatherApi(requestBody, requestBody.getCity());
|
||||||
|
if (!jsonObject.containsKey(DEMOTE_ERROR) && jsonObject.getInteger("code") == ROLL_CODE_SUCCESS.intValue()) {
|
||||||
|
JSONObject jsonData = jsonObject.getJSONObject("data");
|
||||||
|
return jsonData.toJavaObject(ApiForecastWeather.class);
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
package com.xjs.apitools.service;
|
package com.xjs.apitools.service;
|
||||||
|
|
||||||
|
import com.xjs.apitools.domain.ApiForecastWeather;
|
||||||
import com.xjs.apitools.domain.ApiHoliday;
|
import com.xjs.apitools.domain.ApiHoliday;
|
||||||
import com.xjs.apitools.domain.ApiMobileBelong;
|
import com.xjs.apitools.domain.ApiMobileBelong;
|
||||||
import com.xjs.apitools.domain.ApiNowWeather;
|
import com.xjs.apitools.domain.ApiNowWeather;
|
||||||
|
|
@ -35,4 +36,13 @@ public interface ApiToolsService {
|
||||||
*/
|
*/
|
||||||
ApiNowWeather getNowWeather(String city);
|
ApiNowWeather getNowWeather(String city);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取预报天气
|
||||||
|
* @param city 目标城市
|
||||||
|
* @return ApiForecastWeather
|
||||||
|
*/
|
||||||
|
ApiForecastWeather getForecastWeather(String city);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,8 @@
|
||||||
package com.xjs.apitools.service.impl;
|
package com.xjs.apitools.service.impl;
|
||||||
|
|
||||||
import com.xjs.apitools.domain.ApiHoliday;
|
import com.xjs.apitools.domain.*;
|
||||||
import com.xjs.apitools.domain.ApiMobileBelong;
|
|
||||||
import com.xjs.apitools.domain.ApiNowWeather;
|
|
||||||
import com.xjs.apitools.domain.RequestBody;
|
|
||||||
import com.xjs.apitools.factory.ApiToolsFactory;
|
import com.xjs.apitools.factory.ApiToolsFactory;
|
||||||
|
import com.xjs.apitools.factory.impl.RollForecastWeatherFactory;
|
||||||
import com.xjs.apitools.factory.impl.RollHolidayFactory;
|
import com.xjs.apitools.factory.impl.RollHolidayFactory;
|
||||||
import com.xjs.apitools.factory.impl.RollMobileBelongFactory;
|
import com.xjs.apitools.factory.impl.RollMobileBelongFactory;
|
||||||
import com.xjs.apitools.factory.impl.RollNowWeatherFactory;
|
import com.xjs.apitools.factory.impl.RollNowWeatherFactory;
|
||||||
|
|
@ -30,6 +28,7 @@ public class ApiToolsServiceImpl implements ApiToolsService {
|
||||||
private ApiToolsFactory<ApiHoliday, Object> holidayFactory;
|
private ApiToolsFactory<ApiHoliday, Object> holidayFactory;
|
||||||
private ApiToolsFactory<ApiMobileBelong, RequestBody> mobileBelongFactory;
|
private ApiToolsFactory<ApiMobileBelong, RequestBody> mobileBelongFactory;
|
||||||
private ApiToolsFactory<ApiNowWeather, RequestBody> nowWeatherFactory;
|
private ApiToolsFactory<ApiNowWeather, RequestBody> nowWeatherFactory;
|
||||||
|
private ApiToolsFactory<ApiForecastWeather,RequestBody> forecastWeatherFactory;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
public void setHolidayFactory(RollHolidayFactory rollHolidayFactory) {
|
public void setHolidayFactory(RollHolidayFactory rollHolidayFactory) {
|
||||||
|
|
@ -46,6 +45,11 @@ public class ApiToolsServiceImpl implements ApiToolsService {
|
||||||
this.nowWeatherFactory = rollNowWeatherFactory;
|
this.nowWeatherFactory = rollNowWeatherFactory;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
public void setForecastWeatherFactory(RollForecastWeatherFactory rollForecastWeatherFactory) {
|
||||||
|
this.forecastWeatherFactory = rollForecastWeatherFactory;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<ApiHoliday> getApiHolidayList() {
|
public List<ApiHoliday> getApiHolidayList() {
|
||||||
|
|
@ -77,4 +81,12 @@ public class ApiToolsServiceImpl implements ApiToolsService {
|
||||||
return Optional.ofNullable(nowWeatherFactory.apiData(requestBody))
|
return Optional.ofNullable(nowWeatherFactory.apiData(requestBody))
|
||||||
.orElseThrow(ApiException::new);
|
.orElseThrow(ApiException::new);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ApiForecastWeather getForecastWeather(String city) {
|
||||||
|
RequestBody requestBody = new RequestBody();
|
||||||
|
requestBody.setCity(city);
|
||||||
|
return Optional.ofNullable(forecastWeatherFactory.apiData(requestBody))
|
||||||
|
.orElseThrow(ApiException::new);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -53,6 +53,7 @@ public class ApiAWordController extends BaseController {
|
||||||
/**
|
/**
|
||||||
* 查询每日一句列表
|
* 查询每日一句列表
|
||||||
*/
|
*/
|
||||||
|
@ApiOperation("查询每日一句列表")
|
||||||
@RequiresPermissions("openapi:aword:list")
|
@RequiresPermissions("openapi:aword:list")
|
||||||
@GetMapping("/list")
|
@GetMapping("/list")
|
||||||
public TableDataInfo list(ApiAWord apiAWord) {
|
public TableDataInfo list(ApiAWord apiAWord) {
|
||||||
|
|
@ -67,6 +68,7 @@ public class ApiAWordController extends BaseController {
|
||||||
@RequiresPermissions("openapi:aword:export")
|
@RequiresPermissions("openapi:aword:export")
|
||||||
@Log(title = "每日一句", businessType = BusinessType.EXPORT)
|
@Log(title = "每日一句", businessType = BusinessType.EXPORT)
|
||||||
@PostMapping("/export")
|
@PostMapping("/export")
|
||||||
|
@ApiOperation("导出每日一句列表")
|
||||||
public void export(HttpServletResponse response, ApiAWord apiAWord) {
|
public void export(HttpServletResponse response, ApiAWord apiAWord) {
|
||||||
List<ApiAWord> list = apiAWordService.selectApiAWordList(apiAWord);
|
List<ApiAWord> list = apiAWordService.selectApiAWordList(apiAWord);
|
||||||
ExcelUtil<ApiAWord> util = new ExcelUtil<ApiAWord>(ApiAWord.class);
|
ExcelUtil<ApiAWord> util = new ExcelUtil<ApiAWord>(ApiAWord.class);
|
||||||
|
|
@ -78,6 +80,7 @@ public class ApiAWordController extends BaseController {
|
||||||
*/
|
*/
|
||||||
@RequiresPermissions("openapi:aword:query")
|
@RequiresPermissions("openapi:aword:query")
|
||||||
@GetMapping(value = "/{id}")
|
@GetMapping(value = "/{id}")
|
||||||
|
@ApiOperation("获取每日一句详细信息")
|
||||||
public AjaxResult getInfo(@PathVariable("id") Long id) {
|
public AjaxResult getInfo(@PathVariable("id") Long id) {
|
||||||
return AjaxResult.success(apiAWordService.selectApiAWordById(id));
|
return AjaxResult.success(apiAWordService.selectApiAWordById(id));
|
||||||
}
|
}
|
||||||
|
|
@ -88,6 +91,7 @@ public class ApiAWordController extends BaseController {
|
||||||
@RequiresPermissions("openapi:aword:remove")
|
@RequiresPermissions("openapi:aword:remove")
|
||||||
@Log(title = "每日一句", businessType = BusinessType.DELETE)
|
@Log(title = "每日一句", businessType = BusinessType.DELETE)
|
||||||
@DeleteMapping("/{ids}")
|
@DeleteMapping("/{ids}")
|
||||||
|
@ApiOperation("删除每日一句")
|
||||||
public AjaxResult remove(@PathVariable Long[] ids) {
|
public AjaxResult remove(@PathVariable Long[] ids) {
|
||||||
return toAjax(apiAWordService.deleteApiAWordByIds(ids));
|
return toAjax(apiAWordService.deleteApiAWordByIds(ids));
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -9,8 +9,7 @@ import org.springframework.cloud.openfeign.SpringQueryMap;
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
import org.springframework.web.bind.annotation.PathVariable;
|
import org.springframework.web.bind.annotation.PathVariable;
|
||||||
|
|
||||||
import static com.xjs.consts.ApiConst.ROLL_WEATHER;
|
import static com.xjs.consts.ApiConst.*;
|
||||||
import static com.xjs.consts.ApiConst.ROLL_WEATHER_URL;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* roll 天气预报api调用feign
|
* roll 天气预报api调用feign
|
||||||
|
|
@ -21,14 +20,14 @@ import static com.xjs.consts.ApiConst.ROLL_WEATHER_URL;
|
||||||
public interface RollWeatherFeignClient {
|
public interface RollWeatherFeignClient {
|
||||||
|
|
||||||
@GetMapping("/current/{city}")
|
@GetMapping("/current/{city}")
|
||||||
@ApiLog(name = ROLL_WEATHER,
|
@ApiLog(name = ROLL_NOW_WEATHER,
|
||||||
url = ROLL_WEATHER_URL+"/current",
|
url = ROLL_WEATHER_URL+"/current",
|
||||||
method = "Get")
|
method = "Get")
|
||||||
JSONObject nowWeatherApi(@SpringQueryMap RequestBody requestBody, @PathVariable("city")String city);
|
JSONObject nowWeatherApi(@SpringQueryMap RequestBody requestBody, @PathVariable("city")String city);
|
||||||
|
|
||||||
|
|
||||||
@GetMapping("/forecast/{city}")
|
@GetMapping("/forecast/{city}")
|
||||||
@ApiLog(name = ROLL_WEATHER,
|
@ApiLog(name = ROLL_FORECAST_WEATHER,
|
||||||
url = ROLL_WEATHER_URL+"/forecast",
|
url = ROLL_WEATHER_URL+"/forecast",
|
||||||
method = "Get")
|
method = "Get")
|
||||||
JSONObject forecastWeatherApi(@SpringQueryMap RequestBody requestBody,@PathVariable("city")String city);
|
JSONObject forecastWeatherApi(@SpringQueryMap RequestBody requestBody,@PathVariable("city")String city);
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,7 @@ import com.xjs.translation.domain.qo.translation.TranslationQo;
|
||||||
import com.xjs.translation.domain.vo.translation.TranslationVo;
|
import com.xjs.translation.domain.vo.translation.TranslationVo;
|
||||||
import com.xjs.translation.factory.TranslationFactory;
|
import com.xjs.translation.factory.TranslationFactory;
|
||||||
import io.swagger.annotations.Api;
|
import io.swagger.annotations.Api;
|
||||||
|
import io.swagger.annotations.ApiOperation;
|
||||||
import lombok.extern.log4j.Log4j2;
|
import lombok.extern.log4j.Log4j2;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
|
@ -26,6 +27,7 @@ public class TranDictController {
|
||||||
private TranslationFactory tianXingTranDictFactory;
|
private TranslationFactory tianXingTranDictFactory;
|
||||||
|
|
||||||
@GetMapping("tranDictForRPC")
|
@GetMapping("tranDictForRPC")
|
||||||
|
@ApiOperation("获取翻译字典RPC")
|
||||||
public R<TranslationVo> tranDict(String content) {
|
public R<TranslationVo> tranDict(String content) {
|
||||||
TranslationQo translationQo = new TranslationQo();
|
TranslationQo translationQo = new TranslationQo();
|
||||||
translationQo.setQ(content);
|
translationQo.setQ(content);
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,10 @@
|
||||||
package com.xjs.weather.domain;
|
package com.xjs.weather.domain;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 预报天气某天数据
|
* 高德预报天气某天数据
|
||||||
* @author xiejs
|
* @author xiejs
|
||||||
* @since 2022-01-16
|
* @since 2022-01-16
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -1,12 +1,13 @@
|
||||||
package com.xjs.weather.domain;
|
package com.xjs.weather.domain;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 预报天气实体
|
* 高德预报天气实体
|
||||||
*
|
*
|
||||||
* @author xiejs
|
* @author xiejs
|
||||||
* @since 2022-01-16
|
* @since 2022-01-16
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue