提交代码
This commit is contained in:
@@ -0,0 +1,33 @@
|
||||
package com.njcn.system.api;
|
||||
|
||||
import com.njcn.common.pojo.annotation.OperateInfo;
|
||||
import com.njcn.common.pojo.constant.OperateType;
|
||||
import com.njcn.common.pojo.constant.ServerInfo;
|
||||
import com.njcn.common.pojo.dto.LogInfoDTO;
|
||||
import com.njcn.common.pojo.enums.common.LogEnum;
|
||||
import com.njcn.common.pojo.response.HttpResult;
|
||||
import com.njcn.system.api.fallback.FrontLogsFeignClientFallbackFactory;
|
||||
import com.njcn.system.api.fallback.UserLogFeignClientFallbackFactory;
|
||||
import com.njcn.system.pojo.dto.PqFrontLogsDTO;
|
||||
import io.swagger.annotations.ApiImplicitParam;
|
||||
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 hongawen
|
||||
* @version 1.0.0
|
||||
* @date 2022年07月12日 15:20
|
||||
*/
|
||||
@FeignClient(value = ServerInfo.SYSTEM,path = "/frontLog",fallbackFactory = FrontLogsFeignClientFallbackFactory.class,contextId = "frontLog")
|
||||
public interface FrontLogsFeignClient {
|
||||
|
||||
/**
|
||||
* 插入前置日志
|
||||
*
|
||||
*/
|
||||
@PostMapping("/add")
|
||||
HttpResult<Object> addFrontLogs(@RequestBody PqFrontLogsDTO pqFrontLogsDTO);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
package com.njcn.system.api.fallback;
|
||||
|
||||
import com.njcn.common.pojo.dto.LogInfoDTO;
|
||||
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.FrontLogsFeignClient;
|
||||
import com.njcn.system.api.UserLogFeignClient;
|
||||
import com.njcn.system.pojo.dto.PqFrontLogsDTO;
|
||||
import com.njcn.system.utils.SystemEnumUtil;
|
||||
import feign.hystrix.FallbackFactory;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
|
||||
/**
|
||||
* @author hongawen
|
||||
* @version 1.0.0
|
||||
* @date 2022年07月12日 15:21
|
||||
*/
|
||||
@Slf4j
|
||||
@Component
|
||||
public class FrontLogsFeignClientFallbackFactory implements FallbackFactory<FrontLogsFeignClient> {
|
||||
|
||||
/**
|
||||
* 输出远程请求接口异常日志
|
||||
* @param cause RPC请求异常
|
||||
*/
|
||||
@Override
|
||||
public FrontLogsFeignClient 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 FrontLogsFeignClient() {
|
||||
@Override
|
||||
public HttpResult<Object> addFrontLogs(PqFrontLogsDTO pqFrontLogsDTO) {
|
||||
log.error("{}异常,降级处理,异常为:{}","插入前置日志",cause.toString());
|
||||
throw new BusinessException(finalExceptionEnum);
|
||||
}
|
||||
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
package com.njcn.system.pojo.dto;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.njcn.db.bo.BaseEntity;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* Description:
|
||||
* Date: 2025/05/15 下午 2:19【需求编号】
|
||||
*
|
||||
* @author clam
|
||||
* @version V1.0.0
|
||||
*/
|
||||
@Data
|
||||
public class PqFrontLogsDTO {
|
||||
private String nodeId;
|
||||
private String processNo;
|
||||
private String businessId;
|
||||
private String level;
|
||||
private String logType;
|
||||
private String grade;
|
||||
private String frontType;
|
||||
private String log;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
package com.njcn.system.pojo.param;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.njcn.db.bo.BaseEntity;
|
||||
import com.njcn.web.pojo.param.BaseParam;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* Description:
|
||||
* Date: 2025/05/15 下午 2:19【需求编号】
|
||||
*
|
||||
* @author clam
|
||||
* @version V1.0.0
|
||||
*/
|
||||
@Data
|
||||
public class PqFrontLogsParam extends BaseParam {
|
||||
|
||||
|
||||
private String level;
|
||||
private String logType;
|
||||
private String grade;
|
||||
private String frontType;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
package com.njcn.system.pojo.po;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.njcn.db.bo.BaseEntity;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
/**
|
||||
* Description:
|
||||
* Date: 2025/05/15 下午 2:19【需求编号】
|
||||
*
|
||||
* @author clam
|
||||
* @version V1.0.0
|
||||
*/
|
||||
@Data
|
||||
@TableName(value = "PQ_FRONT_LOGS")
|
||||
public class PqFrontLogs extends BaseEntity {
|
||||
@TableId(value = "id", type = IdType.ASSIGN_UUID)
|
||||
private String id;
|
||||
private String nodeId;
|
||||
private String processNo;
|
||||
private String businessId;
|
||||
private String level;
|
||||
private String logType;
|
||||
private String grade;
|
||||
private String frontType;
|
||||
private String log;
|
||||
private Integer state;
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
package com.njcn.system.pojo.vo;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.njcn.db.bo.BaseEntity;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* Description:
|
||||
* Date: 2025/05/15 下午 2:19【需求编号】
|
||||
*
|
||||
* @author clam
|
||||
* @version V1.0.0
|
||||
*/
|
||||
@Data
|
||||
public class PqFrontLogsVO extends BaseEntity {
|
||||
@TableId(value = "id", type = IdType.ASSIGN_UUID)
|
||||
private String id;
|
||||
private String nodeId;
|
||||
private String processNo;
|
||||
private String businessId;
|
||||
private String businessName;
|
||||
private String level;
|
||||
private String logType;
|
||||
private String grade;
|
||||
private String frontType;
|
||||
private String log;
|
||||
private Integer state;
|
||||
}
|
||||
Reference in New Issue
Block a user