workspace delete
This commit is contained in:
parent
7ca97ac14a
commit
3982976042
|
@ -2,10 +2,7 @@ package io.metersphere.controller;
|
|||
|
||||
import io.metersphere.base.domain.Workspace;
|
||||
import io.metersphere.service.WorkspaceService;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
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;
|
||||
|
@ -16,9 +13,14 @@ public class WorkspaceController {
|
|||
@Resource
|
||||
private WorkspaceService workspaceService;
|
||||
|
||||
@PostMapping("add")
|
||||
public Workspace addWorkspace(@RequestBody Workspace workspace) {
|
||||
return workspaceService.add(workspace);
|
||||
@PostMapping("save")
|
||||
public Workspace saveWorkspace(@RequestBody Workspace workspace) {
|
||||
return workspaceService.saveWorkspace(workspace);
|
||||
}
|
||||
|
||||
@GetMapping("delete/{workspaceId}")
|
||||
public void saveWorkspace(@PathVariable String workspaceId) {
|
||||
workspaceService.deleteWorkspace(workspaceId);
|
||||
}
|
||||
|
||||
@PostMapping("list")
|
||||
|
|
|
@ -17,7 +17,7 @@ public class WorkspaceService {
|
|||
@Resource
|
||||
private WorkspaceMapper workspaceMapper;
|
||||
|
||||
public Workspace add(Workspace workspace) {
|
||||
public Workspace saveWorkspace(Workspace workspace) {
|
||||
if (StringUtils.isBlank(workspace.getName())) {
|
||||
MSException.throwException("Workspace name cannot be null.");
|
||||
}
|
||||
|
@ -25,15 +25,24 @@ public class WorkspaceService {
|
|||
if (StringUtils.isBlank(workspace.getOrganizationId())) {
|
||||
workspace.setOrganizationId("root");
|
||||
}
|
||||
long createTime = System.currentTimeMillis();
|
||||
workspace.setCreateTime(createTime);
|
||||
workspace.setUpdateTime(createTime); // 首次 update time
|
||||
long currentTime = System.currentTimeMillis();
|
||||
if (StringUtils.isBlank(workspace.getId())) {
|
||||
workspace.setId(UUID.randomUUID().toString()); // 设置ID
|
||||
workspace.setCreateTime(currentTime);
|
||||
workspace.setUpdateTime(currentTime); // 首次 update time
|
||||
workspaceMapper.insertSelective(workspace);
|
||||
} else {
|
||||
workspace.setUpdateTime(currentTime);
|
||||
workspaceMapper.updateByPrimaryKeySelective(workspace);
|
||||
}
|
||||
return workspace;
|
||||
}
|
||||
|
||||
public List<Workspace> getWorkspaceList() {
|
||||
return workspaceMapper.selectByExample(null);
|
||||
}
|
||||
|
||||
public void deleteWorkspace(String workspaceId) {
|
||||
workspaceMapper.deleteByPrimaryKey(workspaceId);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -13,10 +13,15 @@
|
|||
<el-table :data="items" style="width: 100%">
|
||||
<el-table-column prop="name" label="名称"/>
|
||||
<el-table-column prop="description" label="描述"/>
|
||||
<el-table-column width="50">
|
||||
<el-table-column width="100">
|
||||
<template slot-scope="scope">
|
||||
<el-button @click="edit(scope.row)" type="primary" icon="el-icon-edit" size="mini" circle
|
||||
class="edit"/>
|
||||
<el-popconfirm title="这个工作空间确定要删除吗?" @onConfirm="del(scope.row)">
|
||||
<el-button slot="reference" type="primary" icon="el-icon-delete" size="mini"
|
||||
circle
|
||||
class="edit"/>
|
||||
</el-popconfirm>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
|
@ -40,25 +45,28 @@
|
|||
|
||||
<script>
|
||||
import MsCreateBox from "./CreateBox";
|
||||
import {Message} from "element-ui";
|
||||
|
||||
export default {
|
||||
name: "MsWorkspace",
|
||||
components: {MsCreateBox},
|
||||
mounted() {
|
||||
this.$post('/workspace/list', {}, response => {
|
||||
this.items = response.data;
|
||||
})
|
||||
this.list();
|
||||
},
|
||||
methods: {
|
||||
create() {
|
||||
this.createVisible = true;
|
||||
this.form = {};
|
||||
},
|
||||
submit(formName) {
|
||||
this.$refs[formName].validate((valid) => {
|
||||
if (valid) {
|
||||
this.loading = true;
|
||||
this.$post("/workspace/save", this.form, () => {
|
||||
this.createVisible = false;
|
||||
this.$post("/workspace/add", this.form, () => {
|
||||
this.$message({message: '保存成功', type: 'success'});
|
||||
this.loading = false;
|
||||
this.list();
|
||||
Message.success('保存成功');
|
||||
})
|
||||
} else {
|
||||
return false;
|
||||
|
@ -66,15 +74,30 @@
|
|||
});
|
||||
},
|
||||
edit(row) {
|
||||
this.createVisible = true;
|
||||
window.console.log(row);
|
||||
this.loading = true;
|
||||
let self = this;
|
||||
let getUser1 = this.$get("/test/user");
|
||||
let getUser2 = this.$get("/test/sleep");
|
||||
this.$all([getUser1, getUser2], function (r1, r2) {
|
||||
window.console.log(r1.data.data, r2.data.data);
|
||||
self.loading = false;
|
||||
this.form = row;
|
||||
|
||||
// let self = this;
|
||||
// let getUser1 = this.$get("/test/user");
|
||||
// let getUser2 = this.$get("/test/sleep");
|
||||
// this.$all([getUser1, getUser2], function (r1, r2) {
|
||||
// window.console.log(r1.data.data, r2.data.data);
|
||||
// self.loading = false;
|
||||
// });
|
||||
},
|
||||
del(row) {
|
||||
this.$get('/workspace/delete/' + row.id, () => {
|
||||
Message.success('删除成功');
|
||||
this.list();
|
||||
});
|
||||
window.console.log(row);
|
||||
},
|
||||
list() {
|
||||
this.$post('/workspace/list', {}, response => {
|
||||
this.items = response.data;
|
||||
})
|
||||
}
|
||||
},
|
||||
data() {
|
||||
|
|
Loading…
Reference in New Issue