diff --git a/backend/src/main/java/io/metersphere/controller/ProjectController.java b/backend/src/main/java/io/metersphere/controller/ProjectController.java index f2a5987386..acf07500a0 100644 --- a/backend/src/main/java/io/metersphere/controller/ProjectController.java +++ b/backend/src/main/java/io/metersphere/controller/ProjectController.java @@ -1,10 +1,12 @@ package io.metersphere.controller; +import com.github.pagehelper.Page; +import com.github.pagehelper.PageHelper; import io.metersphere.base.domain.Project; +import io.metersphere.commons.utils.PageUtils; +import io.metersphere.commons.utils.Pager; import io.metersphere.service.ProjectService; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.bind.annotation.*; import javax.annotation.Resource; import java.util.List; @@ -17,7 +19,28 @@ public class ProjectController { @GetMapping("/listAll") public List listAll() { - /// todo: 限制workspace和org + // todo: 限制workspace和org return projectService.listAll(); } + + @PostMapping("/add") + public Project addProject(@RequestBody Project project) { + return projectService.addProject(project); + } + + @PostMapping("/list/{goPage}/{pageSize}") + public Pager> getProjectList(@PathVariable int goPage, @PathVariable int pageSize) { + Page page = PageHelper.startPage(goPage, pageSize, true); + return PageUtils.setPageInfo(page, projectService.getProjectList()); + } + + @GetMapping("/delete/{projectId}") + public void deleteProject(@PathVariable(value = "projectId") String projectId) { + projectService.deleteProject(projectId); + } + + @PostMapping("/update") + public void updateProject(@RequestBody Project Project) { + projectService.updateProject(Project); + } } diff --git a/backend/src/main/java/io/metersphere/service/ProjectService.java b/backend/src/main/java/io/metersphere/service/ProjectService.java index 357de92f2b..2a9f1867cf 100644 --- a/backend/src/main/java/io/metersphere/service/ProjectService.java +++ b/backend/src/main/java/io/metersphere/service/ProjectService.java @@ -7,6 +7,7 @@ import org.springframework.transaction.annotation.Transactional; import javax.annotation.Resource; import java.util.List; +import java.util.UUID; @Service @Transactional(rollbackFor = Exception.class) @@ -14,6 +15,32 @@ public class ProjectService { @Resource private ProjectMapper projectMapper; + public Project addProject(Project project) { + project.setId(UUID.randomUUID().toString()); + long createTime = System.currentTimeMillis(); + project.setCreateTime(createTime); + project.setUpdateTime(createTime); + // todo set workspace id +// project.setWorkspaceId(); + projectMapper.insertSelective(project); + return project; + } + + public List getProjectList() { + // todo 查询条件设置 + return projectMapper.selectByExample(null); + } + + public void deleteProject(String projectId) { + projectMapper.deleteByPrimaryKey(projectId); + } + + public void updateProject(Project project) { + project.setCreateTime(null);// 创建时间禁止修改 + project.setUpdateTime(System.currentTimeMillis()); + projectMapper.updateByPrimaryKeySelective(project); + } + public List listAll() { return projectMapper.selectByExample(null); } diff --git a/frontend/src/performance/components/HeaderMenus.vue b/frontend/src/performance/components/HeaderMenus.vue index a4accf8d01..c7b97f699c 100644 --- a/frontend/src/performance/components/HeaderMenus.vue +++ b/frontend/src/performance/components/HeaderMenus.vue @@ -12,8 +12,12 @@ 项目1 项目2 - 显示全部 - + + + + 显示全部 + + 创建项目 diff --git a/frontend/src/performance/components/project/MsProject.vue b/frontend/src/performance/components/project/MsProject.vue new file mode 100644 index 0000000000..2d8e335ceb --- /dev/null +++ b/frontend/src/performance/components/project/MsProject.vue @@ -0,0 +1,143 @@ + + + + + diff --git a/frontend/src/performance/components/router/router.js b/frontend/src/performance/components/router/router.js index e06cafa28c..a5ada0f080 100644 --- a/frontend/src/performance/components/router/router.js +++ b/frontend/src/performance/components/router/router.js @@ -9,18 +9,21 @@ import AllTestPlan from "../testPlan/AllTestPlan"; import Organization from "../settings/Organization"; import WorkspaceUser from "../settings/WorkSpcaeUser"; import TestResourcePool from "../settings/TestResourcePool"; +import MsProject from "../project/MsProject"; Vue.use(VueRouter); const router = new VueRouter({ routes: [ { - path: "/sidebar", components: { + path: "/sidebar", + components: { sidebar: RouterSidebar } }, { - path: "/setting", components: { + path: "/setting", + components: { content: Setting }, children: [ @@ -75,6 +78,12 @@ const router = new VueRouter({ content: AllTestPlan } }, + { + path: "/project", + components: { + content: MsProject + } + } ] }); diff --git a/frontend/src/performance/components/settings/Workspace.vue b/frontend/src/performance/components/settings/Workspace.vue index f0e12604e5..81e3dc79fe 100644 --- a/frontend/src/performance/components/settings/Workspace.vue +++ b/frontend/src/performance/components/settings/Workspace.vue @@ -70,7 +70,6 @@ }, edit(row) { this.createVisible = true; - window.console.log(row); this.loading = true; this.form = row; @@ -95,7 +94,6 @@ }).catch(() => { }); - window.console.log(row); }, list() { this.$post('/workspace/list', {}, response => {