fit: 解决冲突

This commit is contained in:
Coooder-X 2021-02-03 11:19:39 +08:00 committed by chenjianxing
parent 9a9f8f628b
commit 21f8e54069
2 changed files with 24 additions and 28 deletions

View File

@ -39,7 +39,6 @@ import io.metersphere.track.request.testplan.LoadCaseRequest;
import io.metersphere.track.request.testplan.RunTestPlanRequest; import io.metersphere.track.request.testplan.RunTestPlanRequest;
import io.metersphere.track.request.testplancase.QueryTestPlanCaseRequest; import io.metersphere.track.request.testplancase.QueryTestPlanCaseRequest;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.session.ExecutorType; import org.apache.ibatis.session.ExecutorType;
import org.apache.ibatis.session.SqlSession; import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory; import org.apache.ibatis.session.SqlSessionFactory;
@ -171,33 +170,30 @@ public class TestPlanService {
checkTestPlanExist(testPlan); checkTestPlanExist(testPlan);
TestPlan res = testPlanMapper.selectByPrimaryKey(testPlan.getId()); // 先查一次库 TestPlan res = testPlanMapper.selectByPrimaryKey(testPlan.getId()); // 先查一次库
if (!res.getStatus().equals(testPlan.getStatus())) { // 若有改变才更新时间 if (!res.getStatus().equals(testPlan.getStatus())) { // 若有改变才更新时间
res.setUpdateTime(System.currentTimeMillis()); testPlan.setUpdateTime(System.currentTimeMillis());
if (TestPlanStatus.Underway.name().equals(testPlan.getStatus())) { if (TestPlanStatus.Underway.name().equals(testPlan.getStatus())) {
if (res.getStatus().equals(TestPlanStatus.Prepare.name())) { if (res.getStatus().equals(TestPlanStatus.Prepare.name())) {
res.setActualStartTime(System.currentTimeMillis()); testPlan.setActualStartTime(System.currentTimeMillis());
} // 未开始->进行中写入实际开始时间 } // 未开始->进行中写入实际开始时间
else if (res.getStatus().equals(TestPlanStatus.Completed.name())) { else if (res.getStatus().equals(TestPlanStatus.Completed.name())) {
res.setActualEndTime(null); testPlan.setActualEndTime(null);
} // 已完成->进行中结束时间置空 } // 已完成->进行中结束时间置空
} else if (!StringUtils.equals(res.getStatus(), TestPlanStatus.Prepare.name()) && } else if (!res.getStatus().equals(TestPlanStatus.Prepare.name()) &&
StringUtils.equals(testPlan.getStatus(), TestPlanStatus.Prepare.name())) { testPlan.getStatus().equals(TestPlanStatus.Prepare.name())) {
res.setActualStartTime(null); testPlan.setActualStartTime(null);
res.setActualEndTime(null); testPlan.setActualEndTime(null);
} // 非未开始->未开始时间都置空 } // 非未开始->未开始时间都置空
else if (TestPlanStatus.Completed.name().equals(testPlan.getStatus()) && else if (TestPlanStatus.Completed.name().equals(testPlan.getStatus()) &&
!TestPlanStatus.Completed.name().equals(res.getStatus())) { !TestPlanStatus.Completed.name().equals(res.getStatus())) {
//已完成写入实际完成时间 //已完成写入实际完成时间
res.setActualEndTime(System.currentTimeMillis()); testPlan.setActualEndTime(System.currentTimeMillis());
}
if(StringUtils.isNotEmpty(testPlan.getStatus())){
res.setStatus(testPlan.getStatus());
} }
} }
List<String> userIds = new ArrayList<>(); List<String> userIds = new ArrayList<>();
userIds.add(testPlan.getPrincipal()); userIds.add(testPlan.getPrincipal());
AddTestPlanRequest testPlans = new AddTestPlanRequest(); AddTestPlanRequest testPlans = new AddTestPlanRequest();
int i = testPlanMapper.updateByPrimaryKey(res); // 更新 int i = testPlanMapper.updateByPrimaryKey(testPlan); // 更新
if (!StringUtils.isBlank(testPlan.getStatus())) { if (!StringUtils.isBlank(testPlan.getStatus())) {
BeanUtils.copyBean(testPlans, getTestPlan(testPlan.getId())); BeanUtils.copyBean(testPlans, getTestPlan(testPlan.getId()));
String context = getTestPlanContext(testPlans, NoticeConstants.Event.UPDATE); String context = getTestPlanContext(testPlans, NoticeConstants.Event.UPDATE);

View File

@ -63,23 +63,23 @@
</template> </template>
<script> <script>
import MsAssertionResults from "./AssertionResults"; import MsAssertionResults from "./AssertionResults";
import MsCodeEdit from "../MsCodeEdit"; import MsCodeEdit from "../MsCodeEdit";
import MsDropdown from "../../../../common/components/MsDropdown"; import MsDropdown from "../../../../common/components/MsDropdown";
import {BODY_FORMAT} from "../../model/ApiTestModel"; import {BODY_FORMAT} from "../../model/ApiTestModel";
import MsSqlResultTable from "./SqlResultTable"; import MsSqlResultTable from "./SqlResultTable";
export default { export default {
name: "MsResponseResult", name: "MsResponseResult",
components: { components: {
MsDropdown, MsDropdown,
MsCodeEdit, MsCodeEdit,
MsAssertionResults, MsAssertionResults,
MsSqlResultTable MsSqlResultTable
}, },
props: { props: {
response: Object, response: Object,
currentProtocol: String, currentProtocol: String,
}, },
@ -107,7 +107,7 @@
this.mode = mode; this.mode = mode;
}, },
setBodyType() { setBodyType() {
if (!this.response.responseResult.headers) { if (!this.response.responseResult || !this.response.responseResult.headers) {
return; return;
} }
if (this.response.responseResult.headers.indexOf("Content-Type: application/json") > 0) { if (this.response.responseResult.headers.indexOf("Content-Type: application/json") > 0) {