Merge branch 'dev' of github.com:fit2cloudrd/metersphere-server into dev
This commit is contained in:
commit
caa3d87bc0
|
@ -0,0 +1,12 @@
|
|||
package io.metersphere.base.mapper.ext;
|
||||
|
||||
import io.metersphere.controller.request.ProjectRequest;
|
||||
import io.metersphere.dto.ProjectDTO;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface ExtProjectMapper {
|
||||
|
||||
List<ProjectDTO> getProjectWithWorkspace(@Param("proRequest") ProjectRequest request);
|
||||
}
|
|
@ -0,0 +1,15 @@
|
|||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
|
||||
<mapper namespace="io.metersphere.base.mapper.ext.ExtProjectMapper">
|
||||
|
||||
<select id="getProjectWithWorkspace" resultType="io.metersphere.dto.ProjectDTO">
|
||||
select p.id, p.workspace_id, p.name, p.description, p.update_time,
|
||||
p.create_time, w.id as workspaceId, w.name as workspaceName
|
||||
from project p
|
||||
join workspace w on p.workspace_id = w.id
|
||||
<if test="proRequest.workspaceId != null">
|
||||
where w.id = #{proRequest.workspaceId}
|
||||
</if>
|
||||
</select>
|
||||
|
||||
</mapper>
|
|
@ -7,6 +7,7 @@ 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.dto.ProjectDTO;
|
||||
import io.metersphere.service.ProjectService;
|
||||
import io.metersphere.user.SessionUtils;
|
||||
import org.apache.shiro.authz.annotation.Logical;
|
||||
|
@ -23,7 +24,7 @@ public class ProjectController {
|
|||
private ProjectService projectService;
|
||||
|
||||
@GetMapping("/listAll")
|
||||
public List<Project> listAll() {
|
||||
public List<ProjectDTO> listAll() {
|
||||
String currentWorkspaceId = SessionUtils.getCurrentWorkspaceId();
|
||||
ProjectRequest request = new ProjectRequest();
|
||||
request.setWorkspaceId(currentWorkspaceId);
|
||||
|
@ -49,7 +50,7 @@ public class ProjectController {
|
|||
|
||||
@PostMapping("/list/{goPage}/{pageSize}")
|
||||
@RequiresRoles(RoleConstants.TEST_MANAGER)
|
||||
public Pager<List<Project>> getProjectList(@PathVariable int goPage, @PathVariable int pageSize, @RequestBody ProjectRequest request) {
|
||||
public Pager<List<ProjectDTO>> getProjectList(@PathVariable int goPage, @PathVariable int pageSize, @RequestBody ProjectRequest request) {
|
||||
request.setWorkspaceId(SessionUtils.getCurrentWorkspaceId());
|
||||
Page<Object> page = PageHelper.startPage(goPage, pageSize, true);
|
||||
return PageUtils.setPageInfo(page, projectService.getProjectList(request));
|
||||
|
|
|
@ -0,0 +1,68 @@
|
|||
package io.metersphere.dto;
|
||||
|
||||
public class ProjectDTO {
|
||||
|
||||
private String id;
|
||||
private String name;
|
||||
private String workspaceId;
|
||||
private String workspaceName;
|
||||
private String description;
|
||||
private Long createTime;
|
||||
private Long updateTime;
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getWorkspaceId() {
|
||||
return workspaceId;
|
||||
}
|
||||
|
||||
public void setWorkspaceId(String workspaceId) {
|
||||
this.workspaceId = workspaceId;
|
||||
}
|
||||
|
||||
public String getWorkspaceName() {
|
||||
return workspaceName;
|
||||
}
|
||||
|
||||
public void setWorkspaceName(String workspaceName) {
|
||||
this.workspaceName = workspaceName;
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
public void setDescription(String description) {
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
public Long getCreateTime() {
|
||||
return createTime;
|
||||
}
|
||||
|
||||
public void setCreateTime(Long createTime) {
|
||||
this.createTime = createTime;
|
||||
}
|
||||
|
||||
public Long getUpdateTime() {
|
||||
return updateTime;
|
||||
}
|
||||
|
||||
public void setUpdateTime(Long updateTime) {
|
||||
this.updateTime = updateTime;
|
||||
}
|
||||
}
|
|
@ -3,10 +3,13 @@ package io.metersphere.service;
|
|||
import io.metersphere.base.domain.Project;
|
||||
import io.metersphere.base.domain.ProjectExample;
|
||||
import io.metersphere.base.mapper.ProjectMapper;
|
||||
import io.metersphere.base.mapper.ext.ExtProjectMapper;
|
||||
import io.metersphere.commons.exception.MSException;
|
||||
import io.metersphere.controller.request.ProjectRequest;
|
||||
import io.metersphere.dto.ProjectDTO;
|
||||
import io.metersphere.user.SessionUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
|
@ -19,6 +22,8 @@ import java.util.UUID;
|
|||
public class ProjectService {
|
||||
@Resource
|
||||
private ProjectMapper projectMapper;
|
||||
@Resource
|
||||
private ExtProjectMapper extProjectMapper;
|
||||
|
||||
public Project addProject(Project project) {
|
||||
if (StringUtils.isBlank(project.getName())) {
|
||||
|
@ -41,13 +46,8 @@ public class ProjectService {
|
|||
return project;
|
||||
}
|
||||
|
||||
public List<Project> getProjectList(ProjectRequest request) {
|
||||
ProjectExample example = new ProjectExample();
|
||||
ProjectExample.Criteria criteria = example.createCriteria();
|
||||
if (StringUtils.isNotBlank(request.getWorkspaceId())) {
|
||||
criteria.andWorkspaceIdEqualTo(request.getWorkspaceId());
|
||||
}
|
||||
return projectMapper.selectByExample(example);
|
||||
public List<ProjectDTO> getProjectList(ProjectRequest request) {
|
||||
return extProjectMapper.getProjectWithWorkspace(request);
|
||||
}
|
||||
|
||||
public void deleteProject(String projectId) {
|
||||
|
|
|
@ -58,6 +58,8 @@ export default {
|
|||
'delete_confirm': 'Are you sure you want to delete this project?',
|
||||
'search_by_name': 'Search by name',
|
||||
'input_name': 'Please enter a workspace name',
|
||||
'owning_workspace': 'Owning Workspace',
|
||||
'please_choose_workspace': 'Please select Workspace',
|
||||
},
|
||||
member: {
|
||||
'create': 'Create',
|
||||
|
|
|
@ -35,7 +35,7 @@ export default {
|
|||
workspace: {
|
||||
'create': '创建工作空间',
|
||||
'update': '修改工作空间',
|
||||
'delete_confirm': '这个工作空间确定要删除吗?',
|
||||
'delete_confirm': '删除工作空间会级联删除该工作空间下的资源,确定要删除吗?',
|
||||
'add': '添加工作空间',
|
||||
'input_name': '请输入工作空间名称',
|
||||
'search_by_name': '根据名称搜索',
|
||||
|
@ -58,6 +58,8 @@ export default {
|
|||
'delete_confirm': '这个项目确定要删除吗?',
|
||||
'search_by_name': '根据名称搜索',
|
||||
'input_name': '请输入项目名称',
|
||||
'owning_workspace': '所属工作空间',
|
||||
'please_choose_workspace': '选择工作空间',
|
||||
},
|
||||
member: {
|
||||
'create': '添加成员',
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
<el-table :data="items" style="width: 100%">
|
||||
<el-table-column prop="name" :label="$t('commons.name')"/>
|
||||
<el-table-column prop="description" :label="$t('commons.description')"/>
|
||||
<el-table-column prop="workspaceName" label="所属工作空间"/>
|
||||
<el-table-column>
|
||||
<template slot-scope="scope">
|
||||
<el-button @click="edit(scope.row)" type="primary" icon="el-icon-edit" size="mini" circle/>
|
||||
|
@ -52,6 +53,16 @@
|
|||
<el-form-item :label="$t('commons.description')">
|
||||
<el-input type="textarea" v-model="form.description"></el-input>
|
||||
</el-form-item>
|
||||
<el-form-item :label="$t('project.owning_workspace')" v-permission="['org_admin']">
|
||||
<el-select v-model="form.workspaceId" :placeholder="$t('project.please_choose_workspace')" class="select-width">
|
||||
<el-option
|
||||
v-for="item in form.allWorkspace"
|
||||
:key="item.id"
|
||||
:label="item.name"
|
||||
:value="item.id">
|
||||
</el-option>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<div slot="footer" class="dialog-footer">
|
||||
<el-button type="primary" @click="submit('form')" size="medium">{{$t('commons.save')}}</el-button>
|
||||
|
@ -116,6 +127,13 @@
|
|||
this.title = this.$t('project.edit');
|
||||
this.createVisible = true;
|
||||
this.form = Object.assign({}, row);
|
||||
|
||||
let workspaceId = this.form.workspaceId;
|
||||
this.result = this.$get('workspace/list/orgworkspace/', response => {
|
||||
this.$set(this.form, "allWorkspace", response.data);
|
||||
})
|
||||
// 编辑使填充角色信息
|
||||
this.$set(this.form, 'workspaceId', workspaceId);
|
||||
},
|
||||
submit(formName) {
|
||||
this.$refs[formName].validate((valid) => {
|
||||
|
@ -186,4 +204,8 @@
|
|||
margin-right: -9px;
|
||||
float: right;
|
||||
}
|
||||
|
||||
.select-width {
|
||||
width: 100%;
|
||||
}
|
||||
</style>
|
||||
|
|
Loading…
Reference in New Issue