parent
2789140740
commit
c0cce9fb0b
|
|
@ -57,7 +57,7 @@
|
||||||
:default-expand-all="isExpandAll"
|
:default-expand-all="isExpandAll"
|
||||||
:tree-props="{children: 'children', hasChildren: 'hasChildren'}"
|
:tree-props="{children: 'children', hasChildren: 'hasChildren'}"
|
||||||
>
|
>
|
||||||
<el-table-column prop="menuName" label="菜单名称" :show-overflow-tooltip="true" width="160"></el-table-column>
|
<el-table-column prop="menuName" label="菜单名称" :show-overflow-tooltip="true" width="200"></el-table-column>
|
||||||
<el-table-column prop="icon" label="图标" align="center" width="100">
|
<el-table-column prop="icon" label="图标" align="center" width="100">
|
||||||
<template slot-scope="scope">
|
<template slot-scope="scope">
|
||||||
<svg-icon :icon-class="scope.row.icon" />
|
<svg-icon :icon-class="scope.row.icon" />
|
||||||
|
|
@ -76,7 +76,7 @@
|
||||||
<span>{{ parseTime(scope.row.createTime) }}</span>
|
<span>{{ parseTime(scope.row.createTime) }}</span>
|
||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
|
<el-table-column label="操作" align="center" class-name="small-padding fixed-width" width="200px">
|
||||||
<template slot-scope="scope">
|
<template slot-scope="scope">
|
||||||
<el-button
|
<el-button
|
||||||
size="mini"
|
size="mini"
|
||||||
|
|
|
||||||
|
|
@ -1,12 +1,24 @@
|
||||||
package com.xjs.apitools.controller;
|
package com.xjs.apitools.controller;
|
||||||
|
|
||||||
|
import cn.hutool.core.collection.CollUtil;
|
||||||
|
import com.ruoyi.common.core.domain.R;
|
||||||
|
import com.ruoyi.common.log.annotation.Log;
|
||||||
|
import com.ruoyi.common.security.annotation.RequiresPermissions;
|
||||||
|
import com.xjs.apitools.domain.ApiHoliday;
|
||||||
|
import com.xjs.apitools.service.ApiToolsService;
|
||||||
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.web.bind.annotation.GetMapping;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* api小工具控制器
|
* api小工具控制器
|
||||||
|
*
|
||||||
* @author xiejs
|
* @author xiejs
|
||||||
* @since 2022-01-17
|
* @since 2022-01-17
|
||||||
*/
|
*/
|
||||||
|
|
@ -15,4 +27,20 @@ import org.springframework.web.bind.annotation.RestController;
|
||||||
@Api(tags = "业务模块-API小工具")
|
@Api(tags = "业务模块-API小工具")
|
||||||
@Log4j2
|
@Log4j2
|
||||||
public class ApiToolsController {
|
public class ApiToolsController {
|
||||||
|
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private ApiToolsService apiToolsService;
|
||||||
|
|
||||||
|
|
||||||
|
@GetMapping
|
||||||
|
@ApiOperation("获取节假日信息")
|
||||||
|
@Log(title = "获取节假日")
|
||||||
|
@RequiresPermissions("open:apitools:holiday")
|
||||||
|
public R<List<ApiHoliday>> getHolidayApiData() {
|
||||||
|
List<ApiHoliday> apiHolidayList = apiToolsService.getApiHolidayList();
|
||||||
|
return CollUtil.isNotEmpty(apiHolidayList) ? R.ok(apiHolidayList) : R.fail();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,8 @@
|
||||||
package com.xjs.apitools.factory;
|
package com.xjs.apitools.factory;
|
||||||
|
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* api工具工厂接口
|
* api工具工厂接口
|
||||||
*
|
*
|
||||||
|
|
@ -15,7 +17,15 @@ public interface ApiToolsFactory<T, R> {
|
||||||
*
|
*
|
||||||
* @return T
|
* @return T
|
||||||
*/
|
*/
|
||||||
default T ApiData() {
|
default T apiData() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取api数据工厂方法 (无参)
|
||||||
|
* @return List<T>
|
||||||
|
*/
|
||||||
|
default List<T> apiDataList() {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -25,9 +35,20 @@ public interface ApiToolsFactory<T, R> {
|
||||||
* @param req 请求参数
|
* @param req 请求参数
|
||||||
* @return T
|
* @return T
|
||||||
*/
|
*/
|
||||||
default T ApiData(R req) {
|
default T apiData(R req) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取api数据工厂方法 (有参)
|
||||||
|
*
|
||||||
|
* @param req 请求参数
|
||||||
|
* @return List<T>
|
||||||
|
*/
|
||||||
|
default List<T> apiDataList(R req) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,31 +1,51 @@
|
||||||
package com.xjs.apitools.factory.impl;
|
package com.xjs.apitools.factory.impl;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson.JSONArray;
|
||||||
|
import com.alibaba.fastjson.JSONObject;
|
||||||
import com.xjs.apitools.domain.ApiHoliday;
|
import com.xjs.apitools.domain.ApiHoliday;
|
||||||
import com.xjs.apitools.factory.ApiToolsFactory;
|
import com.xjs.apitools.factory.ApiToolsFactory;
|
||||||
|
import com.xjs.common.client.api.roll.RollHolidayFeignClient;
|
||||||
import com.xjs.config.RollProperties;
|
import com.xjs.config.RollProperties;
|
||||||
|
import com.xjs.copywriting.domain.RequestBody;
|
||||||
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.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
import static com.xjs.consts.ApiConst.DEMOTE_ERROR;
|
||||||
|
import static com.xjs.consts.ApiConst.ROLL_CODE_SUCCESS;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* roll平台获取节假日api工厂实现
|
* roll平台获取节假日api工厂实现
|
||||||
|
*
|
||||||
* @author xiejs
|
* @author xiejs
|
||||||
* @since 2022-01-17
|
* @since 2022-01-17
|
||||||
*/
|
*/
|
||||||
@Component
|
@Component
|
||||||
@Log4j2
|
@Log4j2
|
||||||
public class RollHolidayFactory implements ApiToolsFactory<ApiHoliday,Object> {
|
public class RollHolidayFactory implements ApiToolsFactory<ApiHoliday, Object> {
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private RollProperties rollProperties;
|
private RollProperties rollProperties;
|
||||||
|
@Autowired
|
||||||
|
private RollHolidayFeignClient rollHolidayFeignClient;
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ApiHoliday ApiData() {
|
public List<ApiHoliday> apiDataList() {
|
||||||
|
RequestBody requestBody = new RequestBody();
|
||||||
|
requestBody.setApp_id(rollProperties.getApp_id());
|
||||||
|
requestBody.setApp_secret(rollProperties.getApp_secret());
|
||||||
|
JSONObject jsonObject = rollHolidayFeignClient.holidayApi(requestBody);
|
||||||
|
if (!jsonObject.containsKey(DEMOTE_ERROR) && jsonObject.getInteger("code") == ROLL_CODE_SUCCESS.intValue()) {
|
||||||
|
JSONArray jsonArrayData = jsonObject.getJSONArray("data");
|
||||||
|
return jsonArrayData.stream().map(data -> {
|
||||||
|
JSONObject jsonData = (JSONObject) data;
|
||||||
|
return jsonData.toJavaObject(ApiHoliday.class);
|
||||||
|
}).collect(Collectors.toList());
|
||||||
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,20 @@
|
||||||
|
package com.xjs.apitools.service;
|
||||||
|
|
||||||
|
import com.xjs.apitools.domain.ApiHoliday;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* api工具服务接口
|
||||||
|
* @author xiejs
|
||||||
|
* @since 2022-01-18
|
||||||
|
*/
|
||||||
|
public interface ApiToolsService {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取节假日信息(获取未来节假日,已过的节假日排除)
|
||||||
|
* @return List<ApiHoliday>
|
||||||
|
*/
|
||||||
|
List<ApiHoliday> getApiHolidayList();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,44 @@
|
||||||
|
package com.xjs.apitools.service.impl;
|
||||||
|
|
||||||
|
import com.xjs.apitools.domain.ApiHoliday;
|
||||||
|
import com.xjs.apitools.factory.ApiToolsFactory;
|
||||||
|
import com.xjs.apitools.factory.impl.RollHolidayFactory;
|
||||||
|
import com.xjs.apitools.service.ApiToolsService;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Objects;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* api工具服务实现
|
||||||
|
*
|
||||||
|
* @author xiejs
|
||||||
|
* @since 2022-01-18
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
public class ApiToolsServiceImpl implements ApiToolsService {
|
||||||
|
|
||||||
|
private ApiToolsFactory<ApiHoliday, Object> holidayFactory;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
public void setHolidayFactory(RollHolidayFactory rollHolidayFactory) {
|
||||||
|
this.holidayFactory = rollHolidayFactory;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<ApiHoliday> getApiHolidayList() {
|
||||||
|
List<ApiHoliday> apiHolidayList = holidayFactory.apiDataList();
|
||||||
|
List<ApiHoliday> collect = apiHolidayList.stream().map(holidayFactory -> {
|
||||||
|
if (holidayFactory.getResidueDays() >= 0) {
|
||||||
|
return holidayFactory;
|
||||||
|
}else {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}).collect(Collectors.toList());
|
||||||
|
collect.removeIf(Objects::isNull);
|
||||||
|
return collect;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,27 @@
|
||||||
|
package com.xjs.common.client.api.roll;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson.JSONObject;
|
||||||
|
import com.xjs.annotation.ApiLog;
|
||||||
|
import com.xjs.common.client.factory.RollHolidayFeignFactory;
|
||||||
|
import com.xjs.copywriting.domain.RequestBody;
|
||||||
|
import org.springframework.cloud.openfeign.FeignClient;
|
||||||
|
import org.springframework.cloud.openfeign.SpringQueryMap;
|
||||||
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
|
||||||
|
import static com.xjs.consts.ApiConst.ROLL_HOLIDAYS;
|
||||||
|
import static com.xjs.consts.ApiConst.ROLL_HOLIDAYS_URL;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* roll节假日api接口feign远程调用
|
||||||
|
* @author xiejs
|
||||||
|
* @since 2022-01-18
|
||||||
|
*/
|
||||||
|
@FeignClient(name = "rollHoliday", url = ROLL_HOLIDAYS_URL, fallbackFactory = RollHolidayFeignFactory.class)
|
||||||
|
public interface RollHolidayFeignClient {
|
||||||
|
|
||||||
|
@GetMapping()
|
||||||
|
@ApiLog(name = ROLL_HOLIDAYS,
|
||||||
|
url = ROLL_HOLIDAYS_URL,
|
||||||
|
method = "Get")
|
||||||
|
JSONObject holidayApi(@SpringQueryMap RequestBody requestBody);
|
||||||
|
}
|
||||||
|
|
@ -24,6 +24,6 @@ public interface RollIPFeignClient {
|
||||||
@ApiLog(name = ROLL_IP,
|
@ApiLog(name = ROLL_IP,
|
||||||
url = ROLL_IP_URL,
|
url = ROLL_IP_URL,
|
||||||
method = "Get")
|
method = "Get")
|
||||||
JSONObject IpApi(@SpringQueryMap RequestBody requestBody);
|
JSONObject ipApi(@SpringQueryMap RequestBody requestBody);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -10,9 +10,9 @@ import org.springframework.stereotype.Component;
|
||||||
import static com.xjs.consts.ApiConst.DEMOTE_ERROR;
|
import static com.xjs.consts.ApiConst.DEMOTE_ERROR;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* 百度翻译平台服务降级处理类
|
||||||
* @author xiejs
|
* @author xiejs
|
||||||
* @desc 百度翻译平台服务降级处理类
|
* @since 2021-12-28
|
||||||
* @create 2021-12-28
|
|
||||||
*/
|
*/
|
||||||
@Log4j2
|
@Log4j2
|
||||||
@Component
|
@Component
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,29 @@
|
||||||
|
package com.xjs.common.client.factory;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson.JSONObject;
|
||||||
|
import com.ruoyi.common.core.domain.R;
|
||||||
|
import com.xjs.common.client.api.roll.RollHolidayFeignClient;
|
||||||
|
import lombok.extern.log4j.Log4j2;
|
||||||
|
import org.springframework.cloud.openfeign.FallbackFactory;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import static com.xjs.consts.ApiConst.DEMOTE_ERROR;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* roll节假日api feign 降级
|
||||||
|
* @author xiejs
|
||||||
|
* @since 2022-01-18
|
||||||
|
*/
|
||||||
|
@Component
|
||||||
|
@Log4j2
|
||||||
|
public class RollHolidayFeignFactory implements FallbackFactory<RollHolidayFeignClient> {
|
||||||
|
@Override
|
||||||
|
public RollHolidayFeignClient create(Throwable cause) {
|
||||||
|
log.error("api模块roll 节假日服务调用失败:{},执行降级处理", cause.getMessage());
|
||||||
|
return requestBody -> {
|
||||||
|
JSONObject jsonObject = new JSONObject();
|
||||||
|
jsonObject.put(DEMOTE_ERROR, R.FAIL);
|
||||||
|
return jsonObject;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -7,8 +7,6 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.scheduling.annotation.Scheduled;
|
import org.springframework.scheduling.annotation.Scheduled;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author xiejs
|
* @author xiejs
|
||||||
* @desc 删除重复文案数据
|
* @desc 删除重复文案数据
|
||||||
|
|
@ -37,7 +35,7 @@ public class DeleteRepeatTask {
|
||||||
* 2022-01-07 09:00:00
|
* 2022-01-07 09:00:00
|
||||||
* 2022-01-07 10:00:00
|
* 2022-01-07 10:00:00
|
||||||
*/
|
*/
|
||||||
@Scheduled(cron = "0 0 7-23 * * ? ")
|
@Scheduled(cron = "0 0 10,14,20 * * ? ")
|
||||||
public void execute() {
|
public void execute() {
|
||||||
int copyWritingCount = copyWritingService.deleteRepeatData();
|
int copyWritingCount = copyWritingService.deleteRepeatData();
|
||||||
log.info("thread id:{},定时清除文案重复数据,重复数:{}", Thread.currentThread().getId(),copyWritingCount);
|
log.info("thread id:{},定时清除文案重复数据,重复数:{}", Thread.currentThread().getId(),copyWritingCount);
|
||||||
|
|
|
||||||
|
|
@ -41,7 +41,7 @@ public class RollIPFactory implements IPFactory<IPInfoVo> {
|
||||||
requestBody.setIp(ip);
|
requestBody.setIp(ip);
|
||||||
requestBody.setApp_id(rollProperties.getApp_id());
|
requestBody.setApp_id(rollProperties.getApp_id());
|
||||||
requestBody.setApp_secret(rollProperties.getApp_secret());
|
requestBody.setApp_secret(rollProperties.getApp_secret());
|
||||||
JSONObject jsonObject = rollIPFeignClient.IpApi(requestBody);
|
JSONObject jsonObject = rollIPFeignClient.ipApi(requestBody);
|
||||||
if (!jsonObject.containsKey(DEMOTE_ERROR) && jsonObject.getInteger("code") == ROLL_CODE_SUCCESS.intValue()) {
|
if (!jsonObject.containsKey(DEMOTE_ERROR) && jsonObject.getInteger("code") == ROLL_CODE_SUCCESS.intValue()) {
|
||||||
JSONObject data = jsonObject.getJSONObject("data");
|
JSONObject data = jsonObject.getJSONObject("data");
|
||||||
return data.toJavaObject(IPInfoVo.class);
|
return data.toJavaObject(IPInfoVo.class);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue