最近的测试

This commit is contained in:
Captain.B 2020-02-26 14:57:43 +08:00
parent bbd28d0ef9
commit 2d0d1c5279
5 changed files with 39 additions and 13 deletions

View File

@ -19,6 +19,9 @@
AND project.workspace_id = #{request.workspaceId}
</if>
</where>
<if test="request.recent">
order by load_test.update_time desc
</if>
</select>
</mapper>

View File

@ -3,13 +3,17 @@ package io.metersphere.controller;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import io.metersphere.base.domain.FileMetadata;
import io.metersphere.commons.constants.RoleConstants;
import io.metersphere.commons.utils.PageUtils;
import io.metersphere.commons.utils.Pager;
import io.metersphere.controller.request.ProjectRequest;
import io.metersphere.controller.request.testplan.*;
import io.metersphere.dto.LoadTestDTO;
import io.metersphere.service.FileService;
import io.metersphere.service.LoadTestService;
import io.metersphere.user.SessionUtils;
import org.apache.shiro.authz.annotation.Logical;
import org.apache.shiro.authz.annotation.RequiresRoles;
import org.springframework.http.HttpHeaders;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
@ -27,6 +31,16 @@ public class LoadTestController {
@Resource
private FileService fileService;
@GetMapping("recent/{count}")
@RequiresRoles(value = {RoleConstants.TEST_MANAGER, RoleConstants.TEST_USER, RoleConstants.TEST_VIEWER}, logical = Logical.OR)
public List<LoadTestDTO> recentTestPlans(@PathVariable int count) {
String currentWorkspaceId = SessionUtils.getCurrentWorkspaceId();
QueryTestPlanRequest request = new QueryTestPlanRequest();
request.setWorkspaceId(currentWorkspaceId);
PageHelper.startPage(1, count, true);
return loadTestService.recentTestPlans(request);
}
@PostMapping("/list/{goPage}/{pageSize}")
public Pager<List<LoadTestDTO>> list(@PathVariable int goPage, @PathVariable int pageSize, @RequestBody QueryTestPlanRequest request) {
Page<Object> page = PageHelper.startPage(goPage, pageSize, true);

View File

@ -3,6 +3,7 @@ package io.metersphere.controller.request.testplan;
public class QueryTestPlanRequest extends TestPlanRequest {
private String name;
private String workspaceId;
private boolean recent = false; // 表示查询最近的测试
@Override
public String getName() {
@ -21,4 +22,12 @@ public class QueryTestPlanRequest extends TestPlanRequest {
public void setWorkspaceId(String workspaceId) {
this.workspaceId = workspaceId;
}
public boolean isRecent() {
return recent;
}
public void setRecent(boolean recent) {
this.recent = recent;
}
}

View File

@ -10,6 +10,7 @@ import io.metersphere.dto.LoadTestDTO;
import io.metersphere.engine.Engine;
import io.metersphere.engine.EngineFactory;
import org.apache.commons.lang3.RandomUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;
@ -189,4 +190,10 @@ public class LoadTestService {
/// todo通过调用stop方法能够停止正在运行的engine但是如果部署了多个backend实例页面发送的停止请求如何定位到具体的engine
}
public List<LoadTestDTO> recentTestPlans(QueryTestPlanRequest request) {
// 查询最近的测试计划
request.setRecent(true);
return extLoadTestMapper.list(request);
}
}

View File

@ -13,21 +13,14 @@
<script>
export default {
name: "RecentTestPlan",
mounted() {
this.$get('/testplan/recent/5', (response) => {
this.recentTestPlans = response.data;
});
},
data() {
return {
recentTestPlans: [{
id: 1,
name: "测试1"
}, {
id: 2,
name: "测试2"
}, {
id: 3,
name: "测试3"
}, {
id: 4,
name: "测试4"
}]
recentTestPlans: []
}
}
}