Merge remote-tracking branch 'origin/dev' into dev

This commit is contained in:
Captain.B 2020-03-03 15:36:32 +08:00
commit 715f654a6f
11 changed files with 67 additions and 232 deletions

View File

@ -3,7 +3,6 @@ package io.metersphere.service;
import io.metersphere.base.domain.*;
import io.metersphere.base.mapper.*;
import io.metersphere.base.mapper.ext.ExtUserRoleMapper;
import io.metersphere.commons.constants.RoleConstants;
import io.metersphere.commons.exception.MSException;
import io.metersphere.commons.utils.CodingUtil;
import io.metersphere.controller.request.member.AddMemberRequest;
@ -247,10 +246,17 @@ public class UserService {
return extUserRoleMapper.getMemberList(request);
}
@Transactional(rollbackFor = Exception.class)
public void addMember(AddMemberRequest request) {
if (!CollectionUtils.isEmpty(request.getUserIds())) {
for (String userId : request.getUserIds()) {
UserRoleExample userRoleExample = new UserRoleExample();
userRoleExample.createCriteria().andUserIdEqualTo(userId).andSourceIdEqualTo(request.getWorkspaceId());
List<UserRole> userRoles = userRoleMapper.selectByExample(userRoleExample);
if (userRoles.size() > 0) {
User user = userMapper.selectByPrimaryKey(userId);
String username = user.getName();
MSException.throwException("The user [" + username + "] already exists in the current workspace");
} else {
for (String roleId : request.getRoleIds()) {
UserRole userRole = new UserRole();
userRole.setRoleId(roleId);
@ -264,6 +270,7 @@ public class UserService {
}
}
}
}
public void deleteMember(String workspaceId, String userId) {
UserRoleExample example = new UserRoleExample();
@ -275,6 +282,14 @@ public class UserService {
public void addOrganizationMember(AddOrgMemberRequest request) {
if (!CollectionUtils.isEmpty(request.getUserIds())) {
for (String userId : request.getUserIds()) {
UserRoleExample userRoleExample = new UserRoleExample();
userRoleExample.createCriteria().andUserIdEqualTo(userId).andSourceIdEqualTo(request.getOrganizationId());
List<UserRole> userRoles = userRoleMapper.selectByExample(userRoleExample);
if (userRoles.size() > 0) {
User user = userMapper.selectByPrimaryKey(userId);
String username = user.getName();
MSException.throwException("The user [" + username + "] already exists in the current organization");
} else {
for (String roleId : request.getRoleIds()) {
UserRole userRole = new UserRole();
userRole.setId(UUID.randomUUID().toString());
@ -288,6 +303,7 @@ public class UserService {
}
}
}
}
public void delOrganizationMember(String organizationId, String userId) {
UserRoleExample userRoleExample = new UserRoleExample();

View File

@ -2,18 +2,17 @@ import Vue from "vue";
import VueRouter from 'vue-router'
import RouterSidebar from "./RouterSidebar";
import Setting from "../settings/Setting";
import Workspace from "../settings/Workspace";
import User from "../settings/User";
import User from "../settings/system/User";
import EditTestPlan from "../testPlan/EditTestPlan";
import AllTestPlan from "../testPlan/AllTestPlan";
import Organization from "../settings/Organization";
import OrganizationMember from "../settings/OrganizationMember";
import Member from "../settings/Member";
import TestResourcePool from "../settings/TestResourcePool";
import Organization from "../settings/system/Organization";
import OrganizationMember from "../settings/organization/OrganizationMember";
import Member from "../settings/workspace/WorkspaceMember";
import TestResourcePool from "../settings/system/TestResourcePool";
import MsProject from "../project/MsProject";
import OrganizationWorkspace from "../settings/OrganizationWorkspace";
import PersonSetting from "../settings/PersonSetting";
import SystemWorkspace from "../settings/SystemWorkspace";
import OrganizationWorkspace from "../settings/organization/OrganizationWorkspace";
import PersonSetting from "../settings/personal/PersonSetting";
import SystemWorkspace from "../settings/system/SystemWorkspace";
Vue.use(VueRouter);
@ -32,10 +31,6 @@ const router = new VueRouter({
content: Setting
},
children: [
{
path: 'workspace',
component: Workspace,
},
{
path: 'user',
component: User,

View File

@ -1,176 +0,0 @@
<template>
<div>
<el-card v-loading="result.loading">
<div slot="header">
<el-row type="flex" justify="space-between" align="middle">
<span class="title">
{{$t('commons.workspace')}}
<ms-create-box :tips="btnTips" :exec="create"/>
</span>
<span class="search">
<el-input type="text" size="small" :placeholder="$t('workspace.search_by_name')"
prefix-icon="el-icon-search"
maxlength="60" v-model="condition" clearable/>
</span>
</el-row>
</div>
<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>
<template slot-scope="scope">
<el-button @click="edit(scope.row)" type="primary" icon="el-icon-edit" size="mini" circle/>
<el-button @click="del(scope.row)" type="danger" icon="el-icon-delete" size="mini" circle/>
</template>
</el-table-column>
</el-table>
<div>
<el-row>
<el-col :span="22" :offset="1">
<div class="table-page">
<el-pagination
@size-change="handleSizeChange"
@current-change="handleCurrentChange"
:current-page.sync="currentPage"
:page-sizes="[5, 10, 20, 50, 100]"
:page-size="pageSize"
layout="total, sizes, prev, pager, next, jumper"
:total="total">
</el-pagination>
</div>
</el-col>
</el-row>
</div>
</el-card>
<el-dialog :title="$t('workspace.create')" :visible.sync="createVisible" width="30%">
<el-form :model="form" :rules="rules" ref="form" label-position="left" label-width="100px" size="small">
<el-form-item :label="$t('commons.name')" prop="name">
<el-input v-model="form.name" autocomplete="off"/>
</el-form-item>
<el-form-item :label="$t('commons.description')">
<el-input type="textarea" v-model="form.description"></el-input>
</el-form-item>
</el-form>
<span slot="footer" class="dialog-footer">
<el-button type="primary" @click="submit('form')" size="medium">{{$t('commons.save')}}</el-button>
</span>
</el-dialog>
</div>
</template>
<script>
import MsCreateBox from "./CreateBox";
import {Message} from "element-ui";
export default {
name: "MsWorkspace",
components: {MsCreateBox},
mounted() {
this.list();
},
methods: {
create() {
this.createVisible = true;
this.form = {};
},
submit(formName) {
this.$refs[formName].validate((valid) => {
if (valid) {
let saveType = 'add';
if (this.form.id) {
saveType = 'update'
}
this.$post("/workspace/" + saveType, this.form, () => {
this.createVisible = false;
this.list();
Message.success(this.$t('commons.save_success'));
});
} else {
return false;
}
});
},
edit(row) {
this.createVisible = true;
// copy user
this.form = Object.assign({}, 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.$confirm(this.$t('workspace.delete_confirm'), this.$t('commons.prompt'), {
confirmButtonText: this.$t('commons.confirm'),
cancelButtonText: this.$t('commons.cancel'),
type: 'warning'
}).then(() => {
this.$get('/workspace/delete/' + row.id, () => {
Message.success(this.$t('commons.delete_success'));
this.list();
});
}).catch(() => {
});
},
list() {
let url = '/workspace/list/' + this.currentPage + '/' + this.pageSize;
this.result = this.$post(url, {name: this.condition}, response => {
let data = response.data;
this.items = data.listObject;
this.total = data.itemCount;
});
},
handleSizeChange(size) {
this.pageSize = size;
this.list();
},
handleCurrentChange(current) {
this.currentPage = current;
this.list();
},
},
data() {
return {
result: {},
loading: false,
createVisible: false,
btnTips: this.$t('workspace.add'),
condition: "",
items: [],
currentPage: 1,
pageSize: 5,
total: 0,
form: {
// name: "",
// description: ""
},
rules: {
name: [
{required: true, message: this.$t('workspace.input_name'), trigger: 'blur'},
{min: 2, max: 50, message: this.$t('commons.input_limit', [2, 50]), trigger: 'blur'}
]
},
}
}
}
</script>
<style scoped>
.search {
width: 240px;
}
.edit {
opacity: 0;
}
.el-table__row:hover .edit {
opacity: 1;
}
</style>

View File

@ -112,8 +112,8 @@
</template>
<script>
import MsCreateBox from "./CreateBox";
import {TokenKey} from "../../../common/constants";
import MsCreateBox from "../CreateBox";
import {TokenKey} from "../../../../common/constants";
export default {
name: "MsOrganizationMember",

View File

@ -59,9 +59,9 @@
</template>
<script>
import MsCreateBox from "./CreateBox";
import MsCreateBox from "../CreateBox";
import {Message} from "element-ui";
import {TokenKey} from "../../../common/constants";
import {TokenKey} from "../../../../common/constants";
export default {
name: "MsOrganizationWorkspace",

View File

@ -50,7 +50,7 @@
</template>
<script>
import {TokenKey} from "../../../common/constants";
import {TokenKey} from "../../../../common/constants";
export default {
data() {

View File

@ -51,7 +51,7 @@
<!-- dialog of organization member -->
<el-dialog :visible.sync="memberVisible" width="70%" :destroy-on-close="true" @close="closeMemberFunc">
<el-row type="flex" justify="space-between" align="middle">
<span class="title">{{$t('commons.member')}}
<span class="member-title">{{$t('commons.member')}}
<ms-create-box :tips="btnTips" :exec="addMember"/>
</span>
<span class="search">
@ -195,7 +195,7 @@
</template>
<script>
import MsCreateBox from "./CreateBox";
import MsCreateBox from "../CreateBox";
export default {
name: "MsOrganization",
@ -377,7 +377,7 @@
})
},
initTableData() {
this.$post(this.buildPagePath(this.queryPath),{},response => {
this.result = this.$post(this.buildPagePath(this.queryPath),{},response => {
let data = response.data;
this.tableData = data.listObject;
for (let i = 0; i < this.tableData.length; i++) {
@ -479,13 +479,6 @@
cursor:pointer;
}
.title {
margin-bottom: 50px;
font-size: 32px;
letter-spacing: 0;
text-align: center;
}
.org-member-name {
float: left;
}
@ -499,4 +492,8 @@
.select-width {
width: 100%;
}
.member-title {
margin-bottom: 30px;
}
</style>

View File

@ -104,7 +104,7 @@
<!-- dialog of workspace member -->
<el-dialog :visible.sync="memberVisible" width="70%" :destroy-on-close="true" @close="closeMemberFunc">
<el-row type="flex" justify="space-between" align="middle">
<span class="title">{{$t('commons.member')}}
<span class="member-title">{{$t('commons.member')}}
<ms-create-box :tips="addTips" :exec="addMember"/>
</span>
<span class="search">
@ -218,7 +218,7 @@
</template>
<script>
import MsCreateBox from "./CreateBox";
import MsCreateBox from "../CreateBox";
import {Message} from "element-ui";
export default {
@ -520,5 +520,9 @@
width: 100%;
}
.member-title {
margin-bottom: 30px;
}
</style>

View File

@ -68,7 +68,7 @@
</template>
<script>
import MsCreateBox from "./CreateBox";
import MsCreateBox from "../CreateBox";
export default {
name: "MsTestResourcePool",

View File

@ -106,7 +106,7 @@
</template>
<script>
import MsCreateBox from "./CreateBox";
import MsCreateBox from "../CreateBox";
export default {
data() {

View File

@ -113,8 +113,8 @@
</template>
<script>
import MsCreateBox from "./CreateBox";
import {TokenKey} from "../../../common/constants";
import MsCreateBox from "../CreateBox";
import {TokenKey} from "../../../../common/constants";
export default {
name: "MsMember",
@ -265,7 +265,6 @@
})
},
submitForm(formName) {
this.loading = true;
this.$refs[formName].validate((valid) => {
if (valid) {
let param = {
@ -273,7 +272,7 @@
roleIds: this.form.roleIds,
workspaceId: this.currentUser().lastWorkspaceId
};
this.$post("user/member/add", param, () => {
this.result = this.$post("user/member/add", param, () => {
this.initTableData();
this.createVisible = false;
})