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.domain.*;
import io.metersphere.base.mapper.*; import io.metersphere.base.mapper.*;
import io.metersphere.base.mapper.ext.ExtUserRoleMapper; import io.metersphere.base.mapper.ext.ExtUserRoleMapper;
import io.metersphere.commons.constants.RoleConstants;
import io.metersphere.commons.exception.MSException; import io.metersphere.commons.exception.MSException;
import io.metersphere.commons.utils.CodingUtil; import io.metersphere.commons.utils.CodingUtil;
import io.metersphere.controller.request.member.AddMemberRequest; import io.metersphere.controller.request.member.AddMemberRequest;
@ -247,19 +246,27 @@ public class UserService {
return extUserRoleMapper.getMemberList(request); return extUserRoleMapper.getMemberList(request);
} }
@Transactional(rollbackFor = Exception.class)
public void addMember(AddMemberRequest request) { public void addMember(AddMemberRequest request) {
if (!CollectionUtils.isEmpty(request.getUserIds())) { if (!CollectionUtils.isEmpty(request.getUserIds())) {
for (String userId : request.getUserIds()) { for (String userId : request.getUserIds()) {
for (String roleId : request.getRoleIds()) { UserRoleExample userRoleExample = new UserRoleExample();
UserRole userRole = new UserRole(); userRoleExample.createCriteria().andUserIdEqualTo(userId).andSourceIdEqualTo(request.getWorkspaceId());
userRole.setRoleId(roleId); List<UserRole> userRoles = userRoleMapper.selectByExample(userRoleExample);
userRole.setSourceId(request.getWorkspaceId()); if (userRoles.size() > 0) {
userRole.setUserId(userId); User user = userMapper.selectByPrimaryKey(userId);
userRole.setId(UUID.randomUUID().toString()); String username = user.getName();
userRole.setUpdateTime(System.currentTimeMillis()); MSException.throwException("The user [" + username + "] already exists in the current workspace");
userRole.setCreateTime(System.currentTimeMillis()); } else {
userRoleMapper.insertSelective(userRole); for (String roleId : request.getRoleIds()) {
UserRole userRole = new UserRole();
userRole.setRoleId(roleId);
userRole.setSourceId(request.getWorkspaceId());
userRole.setUserId(userId);
userRole.setId(UUID.randomUUID().toString());
userRole.setUpdateTime(System.currentTimeMillis());
userRole.setCreateTime(System.currentTimeMillis());
userRoleMapper.insertSelective(userRole);
}
} }
} }
} }
@ -275,15 +282,24 @@ public class UserService {
public void addOrganizationMember(AddOrgMemberRequest request) { public void addOrganizationMember(AddOrgMemberRequest request) {
if (!CollectionUtils.isEmpty(request.getUserIds())) { if (!CollectionUtils.isEmpty(request.getUserIds())) {
for (String userId : request.getUserIds()) { for (String userId : request.getUserIds()) {
for (String roleId : request.getRoleIds()) { UserRoleExample userRoleExample = new UserRoleExample();
UserRole userRole = new UserRole(); userRoleExample.createCriteria().andUserIdEqualTo(userId).andSourceIdEqualTo(request.getOrganizationId());
userRole.setId(UUID.randomUUID().toString()); List<UserRole> userRoles = userRoleMapper.selectByExample(userRoleExample);
userRole.setRoleId(roleId); if (userRoles.size() > 0) {
userRole.setSourceId(request.getOrganizationId()); User user = userMapper.selectByPrimaryKey(userId);
userRole.setUserId(userId); String username = user.getName();
userRole.setUpdateTime(System.currentTimeMillis()); MSException.throwException("The user [" + username + "] already exists in the current organization");
userRole.setCreateTime(System.currentTimeMillis()); } else {
userRoleMapper.insertSelective(userRole); for (String roleId : request.getRoleIds()) {
UserRole userRole = new UserRole();
userRole.setId(UUID.randomUUID().toString());
userRole.setRoleId(roleId);
userRole.setSourceId(request.getOrganizationId());
userRole.setUserId(userId);
userRole.setUpdateTime(System.currentTimeMillis());
userRole.setCreateTime(System.currentTimeMillis());
userRoleMapper.insertSelective(userRole);
}
} }
} }
} }

View File

@ -2,18 +2,17 @@ import Vue from "vue";
import VueRouter from 'vue-router' import VueRouter from 'vue-router'
import RouterSidebar from "./RouterSidebar"; import RouterSidebar from "./RouterSidebar";
import Setting from "../settings/Setting"; import Setting from "../settings/Setting";
import Workspace from "../settings/Workspace"; import User from "../settings/system/User";
import User from "../settings/User";
import EditTestPlan from "../testPlan/EditTestPlan"; import EditTestPlan from "../testPlan/EditTestPlan";
import AllTestPlan from "../testPlan/AllTestPlan"; import AllTestPlan from "../testPlan/AllTestPlan";
import Organization from "../settings/Organization"; import Organization from "../settings/system/Organization";
import OrganizationMember from "../settings/OrganizationMember"; import OrganizationMember from "../settings/organization/OrganizationMember";
import Member from "../settings/Member"; import Member from "../settings/workspace/WorkspaceMember";
import TestResourcePool from "../settings/TestResourcePool"; import TestResourcePool from "../settings/system/TestResourcePool";
import MsProject from "../project/MsProject"; import MsProject from "../project/MsProject";
import OrganizationWorkspace from "../settings/OrganizationWorkspace"; import OrganizationWorkspace from "../settings/organization/OrganizationWorkspace";
import PersonSetting from "../settings/PersonSetting"; import PersonSetting from "../settings/personal/PersonSetting";
import SystemWorkspace from "../settings/SystemWorkspace"; import SystemWorkspace from "../settings/system/SystemWorkspace";
Vue.use(VueRouter); Vue.use(VueRouter);
@ -32,10 +31,6 @@ const router = new VueRouter({
content: Setting content: Setting
}, },
children: [ children: [
{
path: 'workspace',
component: Workspace,
},
{ {
path: 'user', path: 'user',
component: 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> </template>
<script> <script>
import MsCreateBox from "./CreateBox"; import MsCreateBox from "../CreateBox";
import {TokenKey} from "../../../common/constants"; import {TokenKey} from "../../../../common/constants";
export default { export default {
name: "MsOrganizationMember", name: "MsOrganizationMember",

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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