feat(系统): 系统设置-系统参数-基础设置新增接口任务并发数配置
This commit is contained in:
parent
29ac3d47be
commit
528b3388d0
|
@ -81,4 +81,20 @@ public interface ParamConstants {
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
enum ApiConcurrentConfig implements ParamConstants {
|
||||||
|
API_CONCURRENT_CONFIG("api.concurrent.config");
|
||||||
|
|
||||||
|
private String value;
|
||||||
|
|
||||||
|
private ApiConcurrentConfig(String value) {
|
||||||
|
this.value = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getValue() {
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -92,4 +92,12 @@ public class SystemParameterController {
|
||||||
public BaseCleanConfigDTO getLogConfigInfo() {
|
public BaseCleanConfigDTO getLogConfigInfo() {
|
||||||
return systemParameterService.getLogConfigInfo();
|
return systemParameterService.getLogConfigInfo();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@GetMapping("/get/api-concurrent-config")
|
||||||
|
@Operation(summary = "系统设置-系统-系统参数-单接口任务并发数-获取")
|
||||||
|
@RequiresPermissions(PermissionConstants.SYSTEM_PARAMETER_SETTING_BASE_READ)
|
||||||
|
public String getApiConcurrentConfig() {
|
||||||
|
return systemParameterService.getApiConcurrentConfig();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -48,6 +48,7 @@ public class SystemParameterService {
|
||||||
|
|
||||||
private static final String DEFAULT_LOG_TIME = "6D";
|
private static final String DEFAULT_LOG_TIME = "6D";
|
||||||
private static final String DEFAULT_HISTORY_TIME = "10";
|
private static final String DEFAULT_HISTORY_TIME = "10";
|
||||||
|
private static final String DEFAULT_API_CONCURRENT_CONFIG = "3";
|
||||||
|
|
||||||
public void saveBaseInfo(List<SystemParameter> parameters) {
|
public void saveBaseInfo(List<SystemParameter> parameters) {
|
||||||
SystemParameterExample example = new SystemParameterExample();
|
SystemParameterExample example = new SystemParameterExample();
|
||||||
|
@ -324,4 +325,12 @@ public class SystemParameterService {
|
||||||
}
|
}
|
||||||
return configDTO;
|
return configDTO;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getApiConcurrentConfig() {
|
||||||
|
List<SystemParameter> paramList = this.getParamList(ParamConstants.ApiConcurrentConfig.API_CONCURRENT_CONFIG.getValue());
|
||||||
|
if (CollectionUtils.isNotEmpty(paramList)) {
|
||||||
|
return paramList.get(0).getParamValue();
|
||||||
|
}
|
||||||
|
return DEFAULT_API_CONCURRENT_CONFIG;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,12 +1,14 @@
|
||||||
package io.metersphere.system.controller;
|
package io.metersphere.system.controller;
|
||||||
|
|
||||||
import io.metersphere.system.base.BaseTest;
|
import io.metersphere.sdk.constants.ParamConstants;
|
||||||
import io.metersphere.sdk.constants.PermissionConstants;
|
import io.metersphere.sdk.constants.PermissionConstants;
|
||||||
import io.metersphere.sdk.constants.SessionConstants;
|
import io.metersphere.sdk.constants.SessionConstants;
|
||||||
import io.metersphere.sdk.util.JSON;
|
import io.metersphere.sdk.util.JSON;
|
||||||
|
import io.metersphere.system.base.BaseTest;
|
||||||
import io.metersphere.system.domain.SystemParameter;
|
import io.metersphere.system.domain.SystemParameter;
|
||||||
import io.metersphere.system.job.CleanHistoryJob;
|
import io.metersphere.system.job.CleanHistoryJob;
|
||||||
import io.metersphere.system.job.CleanLogJob;
|
import io.metersphere.system.job.CleanLogJob;
|
||||||
|
import io.metersphere.system.mapper.SystemParameterMapper;
|
||||||
import jakarta.annotation.Resource;
|
import jakarta.annotation.Resource;
|
||||||
import org.junit.jupiter.api.MethodOrderer;
|
import org.junit.jupiter.api.MethodOrderer;
|
||||||
import org.junit.jupiter.api.Order;
|
import org.junit.jupiter.api.Order;
|
||||||
|
@ -25,11 +27,10 @@ import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
|
||||||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content;
|
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content;
|
||||||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
|
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
|
||||||
|
|
||||||
@SpringBootTest(webEnvironment= SpringBootTest.WebEnvironment.RANDOM_PORT)
|
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
|
||||||
@AutoConfigureMockMvc
|
@AutoConfigureMockMvc
|
||||||
@TestMethodOrder(MethodOrderer.OrderAnnotation.class)
|
@TestMethodOrder(MethodOrderer.OrderAnnotation.class)
|
||||||
public class SystemParameterControllerTests extends BaseTest {
|
public class SystemParameterControllerTests extends BaseTest {
|
||||||
|
@ -53,12 +54,14 @@ public class SystemParameterControllerTests extends BaseTest {
|
||||||
|
|
||||||
public static final String LOG_CONFIG_URL = "/system/parameter/edit/clean-config";
|
public static final String LOG_CONFIG_URL = "/system/parameter/edit/clean-config";
|
||||||
public static final String GET_LOG_CONFIG_URL = "/system/parameter/get/clean-config";
|
public static final String GET_LOG_CONFIG_URL = "/system/parameter/get/clean-config";
|
||||||
|
public static final String GET_API_CONCURRENT_CONFIG_URL = "/system/parameter/get/api-concurrent-config";
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
private CleanHistoryJob cleanHistoryJob;
|
private CleanHistoryJob cleanHistoryJob;
|
||||||
@Resource
|
@Resource
|
||||||
private CleanLogJob cleanLogJob;
|
private CleanLogJob cleanLogJob;
|
||||||
|
@Resource
|
||||||
|
private SystemParameterMapper systemParameterMapper;
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@Order(1)
|
@Order(1)
|
||||||
|
@ -178,7 +181,7 @@ public class SystemParameterControllerTests extends BaseTest {
|
||||||
.contentType(MediaType.APPLICATION_JSON))
|
.contentType(MediaType.APPLICATION_JSON))
|
||||||
.andExpect(status().isOk())
|
.andExpect(status().isOk())
|
||||||
.andExpect(content().contentType(MediaType.APPLICATION_JSON))
|
.andExpect(content().contentType(MediaType.APPLICATION_JSON))
|
||||||
|
|
||||||
.andReturn();
|
.andReturn();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -200,7 +203,6 @@ public class SystemParameterControllerTests extends BaseTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@Order(6)
|
@Order(6)
|
||||||
@Sql(scripts = {"/dml/init_operation_history_test.sql"}, config = @SqlConfig(encoding = "utf-8", transactionMode = SqlConfig.TransactionMode.ISOLATED))
|
@Sql(scripts = {"/dml/init_operation_history_test.sql"}, config = @SqlConfig(encoding = "utf-8", transactionMode = SqlConfig.TransactionMode.ISOLATED))
|
||||||
|
@ -292,4 +294,18 @@ public class SystemParameterControllerTests extends BaseTest {
|
||||||
cleanLogJob.cleanupLog();
|
cleanLogJob.cleanupLog();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@Order(7)
|
||||||
|
public void testGetApiConcurrentConfig() throws Exception {
|
||||||
|
this.requestGet(GET_API_CONCURRENT_CONFIG_URL);
|
||||||
|
|
||||||
|
SystemParameter parameter = new SystemParameter() {{
|
||||||
|
setParamKey(ParamConstants.ApiConcurrentConfig.API_CONCURRENT_CONFIG.getValue());
|
||||||
|
setParamValue("4");
|
||||||
|
setType("String");
|
||||||
|
}};
|
||||||
|
systemParameterMapper.insert(parameter);
|
||||||
|
this.requestGet(GET_API_CONCURRENT_CONFIG_URL);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue