字典录入功能调整

This commit is contained in:
2023-07-31 20:42:40 +08:00
parent 098bcfde03
commit 9d20b33fea
16 changed files with 319 additions and 10 deletions

View File

@@ -0,0 +1,25 @@
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.EleEvtFeignClientFallbackFactory;
import com.njcn.system.pojo.param.EleEvtParam;
import com.njcn.system.pojo.po.EleEpdPqd;
import io.swagger.annotations.ApiOperation;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
/**
* @author xuyang
* @version 1.0.0
* @date 2021年05月08日 15:11
*/
@FeignClient(value = ServerInfo.SYSTEM,path = "/eleEvtParm",fallbackFactory = EleEvtFeignClientFallbackFactory.class,contextId = "eleEvtParm")
public interface EleEvtFeignClient {
@PostMapping("/add")
@ApiOperation("新增事件拓展数据")
HttpResult<EleEpdPqd> add(@RequestBody EleEvtParam evtParam);
}

View File

@@ -25,6 +25,9 @@ public interface EpdFeignClient {
@PostMapping("/addByModel")
HttpResult<String> addByModel(@RequestBody List<EleEpdPqdParam> eleEpdPqdParam);
@PostMapping("/add")
HttpResult<EleEpdPqd> add(@RequestBody EleEpdPqdParam eleEpdPqdParam);
@PostMapping("/dictMarkByDataType")
HttpResult<List<EleEpdPqd>> dictMarkByDataType(@RequestParam("dataType") String dataType);
@@ -37,4 +40,6 @@ public interface EpdFeignClient {
@PostMapping("/selectByIds")
HttpResult<List<EleEpdPqd>> selectByIds(@RequestBody List<String> ids);
@PostMapping("/judgeExist")
HttpResult<List<EleEpdPqd>> judgeExist(@RequestParam("name") String name,@RequestParam("dataType") String dataType);
}

View File

@@ -0,0 +1,46 @@
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.EleEvtFeignClient;
import com.njcn.system.api.EpdFeignClient;
import com.njcn.system.pojo.param.EleEpdPqdParam;
import com.njcn.system.pojo.param.EleEvtParam;
import com.njcn.system.pojo.po.EleEpdPqd;
import com.njcn.system.utils.SystemEnumUtil;
import feign.hystrix.FallbackFactory;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
import java.util.List;
import java.util.Map;
/**
* 类的介绍:
*
* @author xuyang
* @version 1.0.0
* @createTime 2023/5/24 18:46
*/
@Slf4j
@Component
public class EleEvtFeignClientFallbackFactory implements FallbackFactory<EleEvtFeignClient> {
@Override
public EleEvtFeignClient 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 EleEvtFeignClient() {
@Override
public HttpResult<EleEpdPqd> add(EleEvtParam evtParam) {
log.error("{}异常,降级处理,异常为:{}","新增事件拓展数据",cause.toString());
throw new BusinessException(finalExceptionEnum);
}
};
}
}

View File

@@ -40,6 +40,12 @@ public class EpdFeignClientFallbackFactory implements FallbackFactory<EpdFeignCl
throw new BusinessException(finalExceptionEnum);
}
@Override
public HttpResult<EleEpdPqd> add(EleEpdPqdParam eleEpdPqdParam) {
log.error("{}异常,降级处理,异常为:{}","新增字典数据",cause.toString());
throw new BusinessException(finalExceptionEnum);
}
@Override
public HttpResult<List<EleEpdPqd>> dictMarkByDataType(String dataType) {
log.error("{}异常,降级处理,异常为:{}","通过数据模型获取字典数据组装唯一标识",cause.toString());
@@ -63,6 +69,12 @@ public class EpdFeignClientFallbackFactory implements FallbackFactory<EpdFeignCl
log.error("{}异常,降级处理,异常为:{}","根据ids查询字典数据",cause.toString());
throw new BusinessException(finalExceptionEnum);
}
@Override
public HttpResult<List<EleEpdPqd>> judgeExist(String name, String dataType) {
log.error("{}异常,降级处理,异常为:{}","校验字典是否存在",cause.toString());
throw new BusinessException(finalExceptionEnum);
}
};
}
}