敏感用户污染值统计

This commit is contained in:
xy
2025-12-13 20:33:08 +08:00
parent 3a97f01383
commit 12cfecac7e
12 changed files with 235 additions and 9 deletions

View File

@@ -0,0 +1,28 @@
package com.njcn.supervision.api;
import com.njcn.common.pojo.constant.ServerInfo;
import com.njcn.common.pojo.response.HttpResult;
import com.njcn.supervision.api.fallback.UserReportFeignClientFallbackFactory;
import com.njcn.supervision.pojo.param.SensitiveUserParam;
import com.njcn.supervision.pojo.po.user.UserReportPO;
import io.swagger.annotations.ApiOperation;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import java.util.List;
/**
*
* @author 徐扬
*/
@FeignClient(value = ServerInfo.SUPERVISION, path = "/userReport", fallbackFactory = UserReportFeignClientFallbackFactory.class)
public interface UserReportManageFeignClient {
@PostMapping("/getSensitiveUserByDept")
@ApiOperation("根据部门获取敏感用户信息")
HttpResult<List<UserReportPO>> getSensitiveUserByDept(@RequestBody @Validated SensitiveUserParam param) ;
}

View File

@@ -0,0 +1,38 @@
package com.njcn.supervision.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.supervision.api.UserReportManageFeignClient;
import com.njcn.supervision.pojo.param.SensitiveUserParam;
import com.njcn.supervision.pojo.po.user.UserReportPO;
import com.njcn.supervision.utils.SupervisionEnumUtil;
import feign.hystrix.FallbackFactory;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
import java.util.List;
@Slf4j
@Component
public class UserReportFeignClientFallbackFactory implements FallbackFactory<UserReportManageFeignClient> {
@Override
public UserReportManageFeignClient create(Throwable throwable) {
//判断抛出异常是否为解码器抛出的业务异常
Enum<?> exceptionEnum = CommonResponseEnum.SERVICE_FALLBACK;
if (throwable.getCause() instanceof BusinessException) {
BusinessException businessException = (BusinessException) throwable.getCause();
exceptionEnum = SupervisionEnumUtil.getExceptionEnum(businessException.getResult());
}
Enum<?> finalExceptionEnum = exceptionEnum;
return new UserReportManageFeignClient() {
@Override
public HttpResult<List<UserReportPO>> getSensitiveUserByDept(SensitiveUserParam param) {
log.error("{}异常,降级处理,异常为:{}", "根据部门获取敏感用户信息异常", throwable.toString());
throw new BusinessException(finalExceptionEnum);
}
};
}
}

View File

@@ -0,0 +1,30 @@
package com.njcn.supervision.pojo.param;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.io.Serializable;
import java.util.Set;
/**
* @author xy
*/
@Data
@AllArgsConstructor
@NoArgsConstructor
public class SensitiveUserParam implements Serializable {
@ApiModelProperty("部门id")
private String deptId;
@ApiModelProperty("项目名称")
private String projectName;
}