报告菜单 0.1
This commit is contained in:
parent
761dea73aa
commit
0714200b5f
|
@ -0,0 +1,36 @@
|
||||||
|
package io.metersphere.controller;
|
||||||
|
|
||||||
|
import com.github.pagehelper.PageHelper;
|
||||||
|
import io.metersphere.base.domain.LoadTestReport;
|
||||||
|
import io.metersphere.commons.constants.RoleConstants;
|
||||||
|
import io.metersphere.controller.request.ReportRequest;
|
||||||
|
import io.metersphere.service.ReportService;
|
||||||
|
import io.metersphere.user.SessionUtils;
|
||||||
|
import org.apache.shiro.authz.annotation.Logical;
|
||||||
|
import org.apache.shiro.authz.annotation.RequiresRoles;
|
||||||
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
import org.springframework.web.bind.annotation.PathVariable;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@RestController
|
||||||
|
@RequestMapping(value = "report")
|
||||||
|
public class ReportController {
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private ReportService reportService;
|
||||||
|
|
||||||
|
@GetMapping("/recent/{count}")
|
||||||
|
@RequiresRoles(value = {RoleConstants.TEST_MANAGER, RoleConstants.TEST_USER, RoleConstants.TEST_VIEWER}, logical = Logical.OR)
|
||||||
|
public List<LoadTestReport> recentProjects(@PathVariable int count) {
|
||||||
|
String currentWorkspaceId = SessionUtils.getCurrentWorkspaceId();
|
||||||
|
ReportRequest request = new ReportRequest();
|
||||||
|
request.setWorkspaceId(currentWorkspaceId);
|
||||||
|
// 最近 `count` 个项目
|
||||||
|
PageHelper.startPage(1, count);
|
||||||
|
return reportService.getRecentReportList(request);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,13 @@
|
||||||
|
package io.metersphere.controller.request;
|
||||||
|
|
||||||
|
public class ReportRequest {
|
||||||
|
private String workspaceId;
|
||||||
|
|
||||||
|
public String getWorkspaceId() {
|
||||||
|
return workspaceId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setWorkspaceId(String workspaceId) {
|
||||||
|
this.workspaceId = workspaceId;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,28 @@
|
||||||
|
package io.metersphere.service;
|
||||||
|
|
||||||
|
import io.metersphere.base.domain.LoadTestReport;
|
||||||
|
import io.metersphere.base.domain.LoadTestReportExample;
|
||||||
|
import io.metersphere.base.mapper.LoadTestReportMapper;
|
||||||
|
import io.metersphere.controller.request.ReportRequest;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
@Transactional(rollbackFor = Exception.class)
|
||||||
|
public class ReportService {
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private LoadTestReportMapper loadTestReportMapper;
|
||||||
|
|
||||||
|
public List<LoadTestReport> getRecentReportList(ReportRequest request) {
|
||||||
|
LoadTestReportExample example = new LoadTestReportExample();
|
||||||
|
LoadTestReportExample.Criteria criteria = example.createCriteria();
|
||||||
|
//
|
||||||
|
|
||||||
|
example.setOrderByClause("update_time desc");
|
||||||
|
return loadTestReportMapper.selectByExample(example);
|
||||||
|
}
|
||||||
|
}
|
|
@ -30,9 +30,12 @@
|
||||||
</el-submenu>
|
</el-submenu>
|
||||||
<el-submenu index="5" popper-class="submenu" v-permission="['test_manager', 'test_user', 'test_viewer']">
|
<el-submenu index="5" popper-class="submenu" v-permission="['test_manager', 'test_user', 'test_viewer']">
|
||||||
<template slot="title">报告</template>
|
<template slot="title">报告</template>
|
||||||
<el-menu-item index="5-1">报告1</el-menu-item>
|
<ms-recent-report/>
|
||||||
<el-menu-item index="5-2">报告2</el-menu-item>
|
<el-divider/>
|
||||||
<el-menu-item index="5-3">显示全部</el-menu-item>
|
<el-menu-item index="/report/all">
|
||||||
|
<font-awesome-icon :icon="['fa', 'list-ul']"/>
|
||||||
|
<span style="padding-left: 5px;">显示全部</span>
|
||||||
|
</el-menu-item>
|
||||||
</el-submenu>
|
</el-submenu>
|
||||||
</el-menu>
|
</el-menu>
|
||||||
</template>
|
</template>
|
||||||
|
@ -40,10 +43,11 @@
|
||||||
<script>
|
<script>
|
||||||
import MsRecentTestPlan from "./testPlan/RecentTestPlan";
|
import MsRecentTestPlan from "./testPlan/RecentTestPlan";
|
||||||
import MsRecentProject from "./project/RecentProject";
|
import MsRecentProject from "./project/RecentProject";
|
||||||
|
import MsRecentReport from "./report/RecentReport";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: "MsMenus",
|
name: "MsMenus",
|
||||||
components: {MsRecentTestPlan, MsRecentProject}
|
components: {MsRecentReport, MsRecentTestPlan, MsRecentProject}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,36 @@
|
||||||
|
<template>
|
||||||
|
<el-menu router menu-trigger="click" :default-active="$route.path">
|
||||||
|
<el-menu-item :key="p.id" v-for="p in recentReports"
|
||||||
|
:index="'/report/' + p.id" :route="{name:'report', params:{projectId:p.id, projectName:p.name}}">
|
||||||
|
{{ p.name }}
|
||||||
|
</el-menu-item>
|
||||||
|
</el-menu>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
import {ROLE_TEST_MANAGER, ROLE_TEST_USER, ROLE_TEST_VIEWER} from "../../../common/constants";
|
||||||
|
|
||||||
|
export default {
|
||||||
|
name: "MsRecentReport",
|
||||||
|
mounted() {
|
||||||
|
const rolesString = localStorage.getItem("roles");
|
||||||
|
const roles = rolesString.split(',');
|
||||||
|
|
||||||
|
if (roles.indexOf(ROLE_TEST_MANAGER) > -1 || roles.indexOf(ROLE_TEST_USER) > -1 || roles.indexOf(ROLE_TEST_VIEWER) > -1) {
|
||||||
|
this.$get('/report/recent/5', (response) => {
|
||||||
|
this.recentReports = response.data;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
},
|
||||||
|
methods: {},
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
recentReports: [],
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style scoped>
|
||||||
|
|
||||||
|
</style>
|
Loading…
Reference in New Issue