Commit 278ee1cd authored by suhuiguang's avatar suhuiguang

feat(jyjc):调试接口

1.增加调试接口生产时禁用功能
parent f2a802e7
...@@ -23,20 +23,19 @@ import com.yeejoin.amos.boot.module.ymt.api.enums.FlowStatusEnum; ...@@ -23,20 +23,19 @@ import com.yeejoin.amos.boot.module.ymt.api.enums.FlowStatusEnum;
import com.yeejoin.amos.boot.module.ymt.api.mapper.IdxBizJgProjectContraptionMapper; import com.yeejoin.amos.boot.module.ymt.api.mapper.IdxBizJgProjectContraptionMapper;
import com.yeejoin.amos.boot.module.ymt.api.mapper.IdxBizJgUseInfoMapper; import com.yeejoin.amos.boot.module.ymt.api.mapper.IdxBizJgUseInfoMapper;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import org.typroject.tyboot.core.foundation.context.RequestContext; import org.typroject.tyboot.core.foundation.context.RequestContext;
import org.typroject.tyboot.core.foundation.utils.Bean; import org.typroject.tyboot.core.foundation.utils.Bean;
import java.util.ArrayList; import java.util.*;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@Service @Service
@RequiredArgsConstructor @RequiredArgsConstructor
@Slf4j
public class InspectAppMockServiceImpl { public class InspectAppMockServiceImpl {
private final SnowflakeIdUtil sequence; private final SnowflakeIdUtil sequence;
...@@ -47,8 +46,7 @@ public class InspectAppMockServiceImpl { ...@@ -47,8 +46,7 @@ public class InspectAppMockServiceImpl {
private final JyjcInspectionResultServiceImpl inspectionResultService; private final JyjcInspectionResultServiceImpl inspectionResultService;
@Autowired private final JyjcInspectionResultParamServiceImpl jyjcInspectionResultParamServiceImpl;
private JyjcInspectionResultParamServiceImpl jyjcInspectionResultParamServiceImpl;
private final JyjcInspectionApplicationServiceImpl jyjcInspectionApplicationService; private final JyjcInspectionApplicationServiceImpl jyjcInspectionApplicationService;
...@@ -56,9 +54,33 @@ public class InspectAppMockServiceImpl { ...@@ -56,9 +54,33 @@ public class InspectAppMockServiceImpl {
private final IdxBizJgProjectContraptionMapper idxBizJgProjectContraptionMapper; private final IdxBizJgProjectContraptionMapper idxBizJgProjectContraptionMapper;
/**
* 当前环境
*/
@Value("${spring.profiles.active:dev}")
private String currentEnv;
/**
* 禁止调试的环境,多个逗号分割开
*/
@Value("${disabled.test.api.env:prod,cluster}")
private String disabledEnvs;
private List<String> getDisabledEnvList() {
return Arrays.stream(disabledEnvs.split(","))
.map(String::trim) // 去除空格
.filter(env -> !env.isEmpty())
.collect(Collectors.toList());
}
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public Boolean testAppAndPassApp(InspectMockAppData appData) { public Boolean testAppAndPassApp(InspectMockAppData appData) {
// 生产环境时禁止调试,生产环境可以调试
if (getDisabledEnvList().contains(currentEnv)) {
log.warn("非法调试尝试! 环境: {}, 调用参数: {}", currentEnv, appData);
return false;
}
if (appData.getSize() > 10) { if (appData.getSize() > 10) {
appData.setSize(1); appData.setSize(1);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment