This commit is contained in:
liqiang-fit2cloud 2022-12-20 10:06:26 +08:00
commit 11673b0a09
10 changed files with 56 additions and 40 deletions

View File

@ -66,6 +66,7 @@ import org.apache.jmeter.protocol.http.control.HeaderManager;
import org.apache.jmeter.protocol.http.sampler.HTTPSamplerProxy;
import org.apache.jmeter.protocol.http.util.HTTPArgument;
import org.apache.jmeter.protocol.http.util.HTTPFileArg;
import org.apache.jmeter.protocol.java.sampler.BeanShellSampler;
import org.apache.jmeter.protocol.java.sampler.JSR223Sampler;
import org.apache.jmeter.protocol.jdbc.config.DataSourceElement;
import org.apache.jmeter.protocol.jdbc.sampler.JDBCSampler;
@ -737,12 +738,21 @@ public class JMeterParser extends ApiImportAbstractParser<ScenarioImport> {
((MsJSR223Processor) elementNode).setScript(jsr223Sampler.getPropertyAsString(ElementConstants.SCRIPT));
((MsJSR223Processor) elementNode).setScriptLanguage(jsr223Sampler.getPropertyAsString("scriptLanguage"));
}
// BeanShell自定义脚本
else if (key instanceof BeanShellSampler) {
BeanShellSampler jsr223Sampler = (BeanShellSampler) key;
elementNode = new MsJSR223Processor();
BeanUtils.copyBean(elementNode, jsr223Sampler);
((MsJSR223Processor) elementNode).setJsrEnable(false);
((MsJSR223Processor) elementNode).setScript(jsr223Sampler.getPropertyAsString(ElementConstants.SCRIPT));
((MsJSR223Processor) elementNode).setScriptLanguage(jsr223Sampler.getPropertyAsString("scriptLanguage"));
}
// 后置脚本
else if (key instanceof JSR223PostProcessor) {
JSR223PostProcessor jsr223Sampler = (JSR223PostProcessor) key;
elementNode = new MsJSR223PostProcessor();
BeanUtils.copyBean(elementNode, jsr223Sampler);
((MsJSR223PostProcessor) elementNode).setScript(jsr223Sampler.getPropertyAsString(ElementConstants.SCRIPT));
((MsJSR223PostProcessor) elementNode).setScript(jsr223Sampler.getPropertyAsString("BeanShellSampler.query"));
((MsJSR223PostProcessor) elementNode).setScriptLanguage(jsr223Sampler.getPropertyAsString("scriptLanguage"));
} else if (key instanceof BeanShellPostProcessor) {
elementNode = getMsTestElement((BeanShellPostProcessor) key);

View File

@ -663,7 +663,7 @@ public class ApiDefinitionImportUtilService {
}
if (apiDefinition.getLatest()) {
for (ApiDefinitionWithBLOBs apiDefinitionWithBLOBs : repeatList) {
if (apiDefinitionWithBLOBs.getLatest()) {
if (apiDefinitionWithBLOBs.getLatest() && !apiDefinition.getId().equalsIgnoreCase(apiDefinitionWithBLOBs.getId())) {
apiDefinitionWithBLOBs.setLatest(false);
}
batchMapper.updateByPrimaryKey(apiDefinitionWithBLOBs);

View File

@ -621,7 +621,6 @@ public class TestPlanApiCaseService {
List<TestPlanApiCase> testPlanApiCases = testPlanApiCaseMapper.selectByExample(testPlanApiCaseExample);
TestPlanApiCaseMapper apiCaseMapper = sqlSession.getMapper(TestPlanApiCaseMapper.class);
if (!CollectionUtils.isEmpty(testPlanApiCases)) {
Long nextApiOrder = ServiceUtils.getNextOrder(targetPlanId, extTestPlanApiCaseMapper::getLastOrder);
for (TestPlanApiCase apiCase : testPlanApiCases) {
TestPlanApiCase api = new TestPlanApiCase();
api.setId(UUID.randomUUID().toString());
@ -631,8 +630,7 @@ public class TestPlanApiCaseService {
api.setCreateTime(System.currentTimeMillis());
api.setUpdateTime(System.currentTimeMillis());
api.setCreateUser(SessionUtils.getUserId());
api.setOrder(nextApiOrder);
nextApiOrder += 5000;
api.setOrder(apiCase.getOrder());
apiCaseMapper.insert(api);
}
}

View File

@ -711,7 +711,6 @@ public class TestPlanScenarioCaseService {
List<TestPlanApiScenario> apiScenarios = testPlanApiScenarioMapper.selectByExampleWithBLOBs(testPlanApiScenarioExample);
TestPlanApiScenarioMapper apiScenarioMapper = sqlSession.getMapper(TestPlanApiScenarioMapper.class);
if (!CollectionUtils.isEmpty(apiScenarios)) {
Long nextScenarioOrder = ServiceUtils.getNextOrder(targetPlanId, extTestPlanScenarioCaseMapper::getLastOrder);
for (TestPlanApiScenario apiScenario : apiScenarios) {
TestPlanApiScenario planScenario = new TestPlanApiScenario();
planScenario.setId(UUID.randomUUID().toString());
@ -724,8 +723,7 @@ public class TestPlanScenarioCaseService {
planScenario.setCreateTime(System.currentTimeMillis());
planScenario.setUpdateTime(System.currentTimeMillis());
planScenario.setCreateUser(SessionUtils.getUserId());
planScenario.setOrder(nextScenarioOrder);
nextScenarioOrder += 5000;
planScenario.setOrder(apiScenario.getOrder());
apiScenarioMapper.insert(planScenario);
}
}

View File

@ -18,21 +18,18 @@
:content="$t('commons.import')"
@click="importJSON"
/>
<el-popover
v-permission="['PROJECT_ENVIRONMENT:READ+EXPORT']"
placement="bottom"
trigger="hover"
:content="$t('envrionment.export_variable_tip')"
width="300">
<el-dropdown @command="handleExportCommand" class="scenario-ext-btn" trigger="hover"
v-permission="['PROJECT_ENVIRONMENT:READ+EXPORT']">
<ms-table-button
style="margin-left: 10px"
slot="reference"
v-permission="['PROJECT_ENVIRONMENT:READ+EXPORT']"
icon="el-icon-box"
:content="$t('commons.export')"
@click="exportJSON"
/>
</el-popover>
<el-dropdown-menu slot="dropdown">
<el-dropdown-item command="exportApi">{{ $t('envrionment.export_variable_tip') }}</el-dropdown-item>
</el-dropdown-menu>
</el-dropdown>
<el-link
style="margin-left: 10px"
@click="batchAdd"
@ -572,6 +569,9 @@ export default {
}
});
},
handleExportCommand(command){
this.exportJSON();
}
},
created() {
if (this.items.length === 0) {

View File

@ -1,6 +1,6 @@
package io.metersphere.utils;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import io.metersphere.vo.Condition;
import io.metersphere.vo.ElementCondition;
import net.minidev.json.JSONArray;
@ -106,7 +106,7 @@ public class DocumentUtils {
if (subj == null) {
str = "null";
} else if (subj instanceof Map) {
str = new Gson().toJson(subj);
str = new GsonBuilder().serializeNulls().create().toJson(subj);
} else if (!(subj instanceof Double) && !(subj instanceof Float)) {
str = subj.toString();
} else {

View File

@ -511,12 +511,10 @@ public class GroupService {
return;
}
if (StringUtils.equals(group.getType(), UserGroupType.SYSTEM)) {
this.addSystemGroupUser(group, request.getUserIds());
if (!StringUtils.equals(group.getType(), UserGroupType.SYSTEM) && CollectionUtils.isNotEmpty(request.getSourceIds())) {
this.addNotSystemGroupUser(group, request.getUserIds(), request.getSourceIds());
} else {
if (CollectionUtils.isNotEmpty(request.getSourceIds())) {
this.addNotSystemGroupUser(group, request.getUserIds(), request.getSourceIds());
}
LogUtil.warn("no permission to add system group!");
}
}

View File

@ -471,7 +471,13 @@ public class GroupService {
}
if (StringUtils.equals(group.getType(), UserGroupType.SYSTEM)) {
this.addSystemGroupUser(group, request.getUserIds());
SessionUser user = Objects.requireNonNull(SessionUtils.getUser());
long count = user.getGroups().stream().filter(g -> StringUtils.equals(g.getType(), UserGroupType.SYSTEM)).count();
if (count > 0) {
this.addSystemGroupUser(group, request.getUserIds());
} else {
LogUtil.warn("no permission to add system group!");
}
} else {
if (CollectionUtils.isNotEmpty(request.getSourceIds())) {
this.addNotSystemGroupUser(group, request.getUserIds(), request.getSourceIds());

View File

@ -808,25 +808,31 @@ public class UserService {
}
}
SessionUser user = Objects.requireNonNull(SessionUtils.getUser());
long systemGroupCount = user.getGroups().stream().filter(g -> StringUtils.equals(g.getType(), UserGroupType.SYSTEM)).count();
for (String userId : userIds) {
Set<String> set = sourceMap.keySet();
for (String group : set) {
Group gp = groupMapper.selectByPrimaryKey(group);
if (gp != null) {
if (StringUtils.equals(UserGroupType.SYSTEM, gp.getType())) {
UserGroupExample userGroupExample = new UserGroupExample();
userGroupExample.createCriteria().andGroupIdEqualTo(group).andUserIdEqualTo(userId);
List<UserGroup> userGroups = userGroupMapper.selectByExample(userGroupExample);
if (CollectionUtils.isEmpty(userGroups)) {
UserGroup userGroup = new UserGroup();
userGroup.setId(UUID.randomUUID().toString());
userGroup.setGroupId(group);
userGroup.setSourceId("system");
userGroup.setUserId(userId);
userGroup.setUpdateTime(System.currentTimeMillis());
userGroup.setCreateTime(System.currentTimeMillis());
userGroupMapper.insertSelective(userGroup);
if (systemGroupCount > 0) {
UserGroupExample userGroupExample = new UserGroupExample();
userGroupExample.createCriteria().andGroupIdEqualTo(group).andUserIdEqualTo(userId);
List<UserGroup> userGroups = userGroupMapper.selectByExample(userGroupExample);
if (CollectionUtils.isEmpty(userGroups)) {
UserGroup userGroup = new UserGroup();
userGroup.setId(UUID.randomUUID().toString());
userGroup.setGroupId(group);
userGroup.setSourceId("system");
userGroup.setUserId(userId);
userGroup.setUpdateTime(System.currentTimeMillis());
userGroup.setCreateTime(System.currentTimeMillis());
userGroupMapper.insertSelective(userGroup);
}
}
} else {
// 组织工作空间项目
UserGroupExample userGroupExample = new UserGroupExample();

View File

@ -19,9 +19,9 @@
</span>
<span v-if="report.endTime || report.createTime">
<span style="margin-left: 10px">{{ $t('report.test_start_time') }}</span>
<span class="time"> {{ report.createTime | timestampFormatDate }}</span>
<span class="time"> {{ report.createTime | datetimeFormat }}</span>
<span style="margin-left: 10px">{{ $t('report.test_end_time') }}</span>
<span class="time"> {{ report.endTime | timestampFormatDate }}</span>
<span class="time"> {{ report.endTime | datetimeFormat }}</span>
</span>
<div style="float: right">
<el-button v-if="!isPlan && (!debug || exportFlag) && !isTemplate && !isUi"