字典树新增接口
This commit is contained in:
@@ -71,7 +71,8 @@ public class Knife4jSwaggerConfig {
|
|||||||
"com.njcn.cswarn.controller",
|
"com.njcn.cswarn.controller",
|
||||||
"com.njcn.csharmonic.controller",
|
"com.njcn.csharmonic.controller",
|
||||||
"com.njcn.cssystem.controller",
|
"com.njcn.cssystem.controller",
|
||||||
"com.njcn.advance.controller"
|
"com.njcn.advance.controller",
|
||||||
|
"com.njcn.access.controller"
|
||||||
)
|
)
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
List<GrantType> grantTypes = new ArrayList<>();
|
List<GrantType> grantTypes = new ArrayList<>();
|
||||||
|
|||||||
@@ -167,6 +167,13 @@ spring:
|
|||||||
filters:
|
filters:
|
||||||
- SwaggerHeaderFilter
|
- SwaggerHeaderFilter
|
||||||
- StripPrefix=1
|
- StripPrefix=1
|
||||||
|
- id: access-boot
|
||||||
|
uri: lb://access-boot
|
||||||
|
predicates:
|
||||||
|
- Path=/access-boot/**
|
||||||
|
filters:
|
||||||
|
- SwaggerHeaderFilter
|
||||||
|
- StripPrefix=1
|
||||||
#项目日志的配置
|
#项目日志的配置
|
||||||
logging:
|
logging:
|
||||||
config: http://@nacos.url@/nacos/v1/cs/configs?tenant=@nacos.namespace@&group=DEFAULT_GROUP&dataId=logback.xml
|
config: http://@nacos.url@/nacos/v1/cs/configs?tenant=@nacos.namespace@&group=DEFAULT_GROUP&dataId=logback.xml
|
||||||
|
|||||||
@@ -0,0 +1,19 @@
|
|||||||
|
package com.njcn.system.api;
|
||||||
|
|
||||||
|
import com.njcn.common.pojo.constant.ServerInfo;
|
||||||
|
import com.njcn.common.pojo.response.HttpResult;
|
||||||
|
import com.njcn.system.api.fallback.DictTreeFeignClientFallbackFactory;
|
||||||
|
import com.njcn.system.pojo.po.SysDicTreePO;
|
||||||
|
import org.springframework.cloud.openfeign.FeignClient;
|
||||||
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestParam;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author xuyang
|
||||||
|
*/
|
||||||
|
@FeignClient(value = ServerInfo.SYSTEM, path = "/dictTree", fallbackFactory = DictTreeFeignClientFallbackFactory.class, contextId = "dictTree")
|
||||||
|
public interface DictTreeFeignClient {
|
||||||
|
|
||||||
|
@PostMapping("/queryById")
|
||||||
|
HttpResult<SysDicTreePO> queryById(@RequestParam("id") String id);
|
||||||
|
}
|
||||||
@@ -0,0 +1,43 @@
|
|||||||
|
package com.njcn.system.api.fallback;
|
||||||
|
|
||||||
|
|
||||||
|
import com.njcn.common.pojo.enums.response.CommonResponseEnum;
|
||||||
|
import com.njcn.common.pojo.exception.BusinessException;
|
||||||
|
import com.njcn.common.pojo.response.HttpResult;
|
||||||
|
import com.njcn.system.api.DicDataFeignClient;
|
||||||
|
import com.njcn.system.api.DictTreeFeignClient;
|
||||||
|
import com.njcn.system.pojo.po.DictData;
|
||||||
|
import com.njcn.system.pojo.po.SysDicTreePO;
|
||||||
|
import com.njcn.system.utils.SystemEnumUtil;
|
||||||
|
import feign.hystrix.FallbackFactory;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author hongawen
|
||||||
|
* @version 1.0.0
|
||||||
|
* @date 2021年09月09日 15:19
|
||||||
|
*/
|
||||||
|
@Slf4j
|
||||||
|
@Component
|
||||||
|
public class DictTreeFeignClientFallbackFactory implements FallbackFactory<DictTreeFeignClient> {
|
||||||
|
@Override
|
||||||
|
public DictTreeFeignClient create(Throwable cause) {
|
||||||
|
//判断抛出异常是否为解码器抛出的业务异常
|
||||||
|
Enum<?> exceptionEnum = CommonResponseEnum.SERVICE_FALLBACK;
|
||||||
|
if(cause.getCause() instanceof BusinessException){
|
||||||
|
BusinessException businessException = (BusinessException) cause.getCause();
|
||||||
|
exceptionEnum = SystemEnumUtil.getExceptionEnum(businessException.getResult());
|
||||||
|
}
|
||||||
|
Enum<?> finalExceptionEnum = exceptionEnum;
|
||||||
|
return new DictTreeFeignClient() {
|
||||||
|
@Override
|
||||||
|
public HttpResult<SysDicTreePO> queryById(String id) {
|
||||||
|
log.error("{}异常,降级处理,异常为:{}","根据字典id获取字典数据",cause.toString());
|
||||||
|
throw new BusinessException(finalExceptionEnum);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -365,8 +365,10 @@ public enum DicDataEnum {
|
|||||||
/**
|
/**
|
||||||
* 装置类型(治理)
|
* 装置类型(治理)
|
||||||
*/
|
*/
|
||||||
GATEWAY_DEV("网关", "Gateway_Dev"),
|
GATEWAY_DEV("网关", "Gateway"),
|
||||||
CONNECT_DEV("直连设备", "Connect_Dev"),
|
CONNECT_DEV("直连设备", "Direct_Connected_Device"),
|
||||||
|
DEV("装置", "Device"),
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 治理数据模型
|
* 治理数据模型
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ import com.njcn.common.utils.LogUtil;
|
|||||||
import com.njcn.system.pojo.param.DictDataParam;
|
import com.njcn.system.pojo.param.DictDataParam;
|
||||||
import com.njcn.system.pojo.param.DictTreeParam;
|
import com.njcn.system.pojo.param.DictTreeParam;
|
||||||
import com.njcn.system.pojo.po.DictData;
|
import com.njcn.system.pojo.po.DictData;
|
||||||
|
import com.njcn.system.pojo.po.SysDicTreePO;
|
||||||
import com.njcn.system.pojo.vo.DictDataVO;
|
import com.njcn.system.pojo.vo.DictDataVO;
|
||||||
import com.njcn.system.pojo.vo.DictTreeVO;
|
import com.njcn.system.pojo.vo.DictTreeVO;
|
||||||
import com.njcn.system.service.IDictDataService;
|
import com.njcn.system.service.IDictDataService;
|
||||||
@@ -110,7 +111,15 @@ public class DictTreeController extends BaseController {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@OperateInfo(info = LogEnum.SYSTEM_COMMON, operateType = OperateType.QUERY)
|
||||||
|
@PostMapping("/queryById")
|
||||||
|
@ApiOperation("根据id查询数据")
|
||||||
|
public HttpResult<SysDicTreePO> queryById(@RequestParam("id") String id) {
|
||||||
|
String methodDescribe = getMethodDescribe("queryById");
|
||||||
|
LogUtil.njcnDebug(log, "{},字典数据为:{}", methodDescribe, id);
|
||||||
|
SysDicTreePO result = sysDicTreePOService.queryById(id);
|
||||||
|
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -25,4 +25,11 @@ public interface SysDicTreePOService extends IService<SysDicTreePO>{
|
|||||||
DictTreeVO queryByCode(String code);
|
DictTreeVO queryByCode(String code);
|
||||||
|
|
||||||
List<DictTreeVO> queryByid(String id);
|
List<DictTreeVO> queryByid(String id);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据id查询字典数据
|
||||||
|
* @param id
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
SysDicTreePO queryById(String id);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -95,4 +95,9 @@ public class SysDicTreePOServiceImpl extends ServiceImpl<SysDicTreePOMapper, Sys
|
|||||||
return dictTreeVOS;
|
return dictTreeVOS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public SysDicTreePO queryById(String id) {
|
||||||
|
return this.lambdaQuery().eq(SysDicTreePO::getId,id).eq(SysDicTreePO::getStatus,0).one();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user