最近的项目
This commit is contained in:
parent
3923aca94f
commit
32df172547
|
@ -9,6 +9,7 @@ import io.metersphere.commons.utils.Pager;
|
|||
import io.metersphere.controller.request.ProjectRequest;
|
||||
import io.metersphere.service.ProjectService;
|
||||
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.*;
|
||||
|
||||
|
@ -29,6 +30,17 @@ public class ProjectController {
|
|||
return projectService.getProjectList(request);
|
||||
}
|
||||
|
||||
@GetMapping("/recent/{count}")
|
||||
@RequiresRoles(value = {RoleConstants.TEST_MANAGER, RoleConstants.TEST_USER, RoleConstants.TEST_VIEWER}, logical = Logical.OR)
|
||||
public List<Project> recentProjects(@PathVariable int count) {
|
||||
String currentWorkspaceId = SessionUtils.getCurrentWorkspaceId();
|
||||
ProjectRequest request = new ProjectRequest();
|
||||
request.setWorkspaceId(currentWorkspaceId);
|
||||
// 最近 `count` 个项目
|
||||
PageHelper.startPage(1, count);
|
||||
return projectService.getRecentProjectList(request);
|
||||
}
|
||||
|
||||
@PostMapping("/add")
|
||||
@RequiresRoles(RoleConstants.TEST_MANAGER)
|
||||
public Project addProject(@RequestBody Project project) {
|
||||
|
|
|
@ -63,4 +63,15 @@ public class ProjectService {
|
|||
public List<Project> listAll() {
|
||||
return projectMapper.selectByExample(null);
|
||||
}
|
||||
|
||||
public List<Project> getRecentProjectList(ProjectRequest request) {
|
||||
ProjectExample example = new ProjectExample();
|
||||
ProjectExample.Criteria criteria = example.createCriteria();
|
||||
if (StringUtils.isNotBlank(request.getWorkspaceId())) {
|
||||
criteria.andWorkspaceIdEqualTo(request.getWorkspaceId());
|
||||
}
|
||||
// 按照修改时间排序
|
||||
example.setOrderByClause("update_time desc");
|
||||
return projectMapper.selectByExample(example);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -18,6 +18,9 @@ const en_US = {
|
|||
'input_name_2_50': '2 to 50 characters in length',
|
||||
'search_by_name': 'Search by name',
|
||||
},
|
||||
project: {
|
||||
'recent': 'Recent Projects'
|
||||
},
|
||||
i18n: {
|
||||
'home': 'Home',
|
||||
}
|
||||
|
|
|
@ -18,6 +18,9 @@ const zh_CN = {
|
|||
'input_name_2_50': '长度在 2 到 50 个字符',
|
||||
'search_by_name': '根据名称搜索',
|
||||
},
|
||||
project: {
|
||||
'recent': '最近的项目'
|
||||
},
|
||||
i18n: {
|
||||
'home': '首页',
|
||||
}
|
||||
|
|
|
@ -2,10 +2,10 @@
|
|||
<div>
|
||||
<div class="recent-text">
|
||||
<i class="el-icon-time"/>
|
||||
最近的项目
|
||||
{{$t('project.recent')}}
|
||||
</div>
|
||||
<el-menu-item v-bind:key="recentTestPlan.id" v-for="recentTestPlan in recentTestPlans">
|
||||
{{ recentTestPlan.name }}
|
||||
<el-menu-item :key="recentProject.id" v-for="recentProject in recentProjects" @click="goTest(recentProject)">
|
||||
{{ recentProject.name }}
|
||||
</el-menu-item>
|
||||
</div>
|
||||
</template>
|
||||
|
@ -13,26 +13,20 @@
|
|||
<script>
|
||||
export default {
|
||||
name: "RecentProject",
|
||||
mounted() {
|
||||
this.$get('/project/recent/5', (response) => {
|
||||
this.recentProjects = response.data;
|
||||
});
|
||||
},
|
||||
methods: {
|
||||
goTest(project) {
|
||||
window.console.log(project);
|
||||
// this.$router.push({path: '/allTest', params: {projectId: project.id, projectName: project.name}});
|
||||
}
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
recentTestPlans: [
|
||||
{
|
||||
id: 1,
|
||||
name: "项目1"
|
||||
},
|
||||
{
|
||||
id: 2,
|
||||
name: "项目2"
|
||||
},
|
||||
{
|
||||
id: 3,
|
||||
name: "项目3"
|
||||
},
|
||||
{
|
||||
id: 4,
|
||||
name: "项目4"
|
||||
}
|
||||
]
|
||||
recentProjects: [],
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -86,7 +86,8 @@ const router = new VueRouter({
|
|||
path: "/allTest",
|
||||
components: {
|
||||
content: AllTestPlan
|
||||
}
|
||||
},
|
||||
props: true,
|
||||
},
|
||||
{
|
||||
path: "/project",
|
||||
|
|
|
@ -80,6 +80,10 @@
|
|||
|
||||
<script>
|
||||
export default {
|
||||
props: {
|
||||
projectId: String,
|
||||
projectName: String
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
result: {},
|
||||
|
|
Loading…
Reference in New Issue