Merge branch 'dev' of https://github.com/fit2cloudrd/metersphere-server into dev
This commit is contained in:
commit
8c4afc465b
|
@ -17,15 +17,14 @@ import io.metersphere.controller.request.member.SetAdminRequest;
|
|||
import io.metersphere.controller.request.organization.AddOrgMemberRequest;
|
||||
import io.metersphere.controller.request.organization.QueryOrgMemberRequest;
|
||||
import io.metersphere.dto.UserDTO;
|
||||
import io.metersphere.dto.UserRoleDTO;
|
||||
import io.metersphere.service.OrganizationService;
|
||||
import io.metersphere.service.UserService;
|
||||
import io.metersphere.service.WorkspaceService;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.shiro.authz.annotation.Logical;
|
||||
import org.apache.shiro.authz.annotation.RequiresRoles;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
|
||||
|
@ -54,6 +53,12 @@ public class UserController {
|
|||
return PageUtils.setPageInfo(page, userService.getUserListWithRequest(request));
|
||||
}
|
||||
|
||||
@GetMapping("/special/user/role/{userId}")
|
||||
@RequiresRoles(RoleConstants.ADMIN)
|
||||
public UserRoleDTO getUserRole(@PathVariable("userId") String userId) {
|
||||
return userService.getUserRole(userId);
|
||||
}
|
||||
|
||||
@GetMapping("/special/delete/{userId}")
|
||||
@RequiresRoles(RoleConstants.ADMIN)
|
||||
public void deleteUser(@PathVariable(value = "userId") String userId) {
|
||||
|
|
|
@ -0,0 +1,18 @@
|
|||
package io.metersphere.dto;
|
||||
|
||||
import io.metersphere.base.domain.Role;
|
||||
import io.metersphere.base.domain.UserRole;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import java.util.List;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
public class UserRoleDTO {
|
||||
|
||||
private String userId;
|
||||
private List<Role> roles;
|
||||
private List<UserRole> userRoles;
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
}
|
|
@ -17,13 +17,13 @@ import io.metersphere.controller.request.member.SetAdminRequest;
|
|||
import io.metersphere.controller.request.organization.AddOrgMemberRequest;
|
||||
import io.metersphere.controller.request.organization.QueryOrgMemberRequest;
|
||||
import io.metersphere.dto.UserDTO;
|
||||
import io.metersphere.dto.UserRoleDTO;
|
||||
import io.metersphere.i18n.Translator;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
@ -100,16 +100,24 @@ public class UserService {
|
|||
}
|
||||
UserDTO userDTO = new UserDTO();
|
||||
BeanUtils.copyProperties(user, userDTO);
|
||||
UserRoleDTO userRole = getUserRole(userId);
|
||||
userDTO.setUserRoles(userRole.getUserRoles());
|
||||
userDTO.setRoles(userRole.getRoles());
|
||||
return userDTO;
|
||||
}
|
||||
|
||||
public UserRoleDTO getUserRole(String userId) {
|
||||
UserRoleDTO userRoleDTO = new UserRoleDTO();
|
||||
//
|
||||
UserRoleExample userRoleExample = new UserRoleExample();
|
||||
userRoleExample.createCriteria().andUserIdEqualTo(userId);
|
||||
List<UserRole> userRoleList = userRoleMapper.selectByExample(userRoleExample);
|
||||
|
||||
if (CollectionUtils.isEmpty(userRoleList)) {
|
||||
return userDTO;
|
||||
return userRoleDTO;
|
||||
}
|
||||
// 设置 user_role
|
||||
userDTO.setUserRoles(userRoleList);
|
||||
userRoleDTO.setUserRoles(userRoleList);
|
||||
|
||||
List<String> roleIds = userRoleList.stream().map(UserRole::getRoleId).collect(Collectors.toList());
|
||||
|
||||
|
@ -117,9 +125,9 @@ public class UserService {
|
|||
roleExample.createCriteria().andIdIn(roleIds);
|
||||
|
||||
List<Role> roleList = roleMapper.selectByExample(roleExample);
|
||||
userDTO.setRoles(roleList);
|
||||
userRoleDTO.setRoles(roleList);
|
||||
|
||||
return userDTO;
|
||||
return userRoleDTO;
|
||||
}
|
||||
|
||||
public List<User> getUserList() {
|
||||
|
|
|
@ -7,7 +7,11 @@
|
|||
:show-create="false"/>
|
||||
</template>
|
||||
<el-table :data="tableData" class="table-content">
|
||||
<el-table-column prop="name" :label="$t('commons.name')" width="200" show-overflow-tooltip/>
|
||||
<el-table-column :label="$t('commons.name')" width="200" show-overflow-tooltip>
|
||||
<template v-slot:default="scope">
|
||||
<el-link type="info" @click="handleView(scope.row)">{{ scope.row.name }}</el-link>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="testName" :label="$t('api_report.test_name')" width="200" show-overflow-tooltip/>
|
||||
<el-table-column width="250" :label="$t('commons.create_time')">
|
||||
<template v-slot:default="scope">
|
||||
|
|
|
@ -7,7 +7,10 @@
|
|||
@create="create" :createTip="$t('load_test.create')"/>
|
||||
</template>
|
||||
<el-table :data="tableData" class="table-content">
|
||||
<el-table-column prop="name" :label="$t('commons.name')" width="150" show-overflow-tooltip>
|
||||
<el-table-column :label="$t('commons.name')" width="150" show-overflow-tooltip>
|
||||
<template v-slot:default="scope">
|
||||
<el-link type="info" @click="handleEdit(scope.row)">{{ scope.row.name }}</el-link>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="projectName" :label="$t('load_test.project_name')" width="150" show-overflow-tooltip>
|
||||
</el-table-column>
|
||||
|
|
|
@ -9,7 +9,12 @@
|
|||
|
||||
<el-table :data="tableData" style="width: 100%">
|
||||
<el-table-column prop="id" label="ID"/>
|
||||
<el-table-column prop="name" :label="$t('commons.username')"/>
|
||||
<el-table-column prop="name" :label="$t('commons.username')" width="200"/>
|
||||
<el-table-column :label="$t('commons.role')" width="120">
|
||||
<template v-slot:default="scope">
|
||||
<ms-roles-tag :roles="scope.row.roles"/>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="email" :label="$t('commons.email')"/>
|
||||
<el-table-column prop="status" :label="$t('commons.status')">
|
||||
<template v-slot:default="scope">
|
||||
|
@ -22,7 +27,7 @@
|
|||
/>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="createTime" :label="$t('commons.create_time')" width="180">
|
||||
<el-table-column prop="createTime" :label="$t('commons.create_time')">
|
||||
<template v-slot:default="scope">
|
||||
<span>{{ scope.row.createTime | timestampFormatDate }}</span>
|
||||
</template>
|
||||
|
@ -43,21 +48,6 @@
|
|||
:total="total"/>
|
||||
</el-card>
|
||||
|
||||
<el-dialog :title="$t('commons.verification')" :visible.sync="checkPasswordVisible" width="30%"
|
||||
@close="closeCheckPassword" :destroy-on-close="true">
|
||||
<el-form :model="checkPasswordForm" label-position="right" label-width="100px" size="small" :rules="rule"
|
||||
ref="checkPasswordForm">
|
||||
<el-form-item :label="$t('commons.password')" prop="password">
|
||||
<el-input type="password" v-model="checkPasswordForm.password" autocomplete="off" show-password></el-input>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<template v-slot:footer>
|
||||
<ms-dialog-footer
|
||||
@cancel="checkPasswordVisible = false"
|
||||
@confirm="setAdmin('checkPasswordForm')"/>
|
||||
</template>
|
||||
</el-dialog>
|
||||
|
||||
<!--Create user-->
|
||||
<el-dialog :title="$t('user.create')" :visible.sync="createVisible" width="30%" @closed="handleClose"
|
||||
:destroy-on-close="true">
|
||||
|
@ -137,10 +127,19 @@
|
|||
import MsDialogFooter from "../../common/components/MsDialogFooter";
|
||||
import MsTableOperatorButton from "../../common/components/MsTableOperatorButton";
|
||||
import {getCurrentUser} from "../../../../common/js/utils";
|
||||
import MsRolesTag from "../../common/components/MsRolesTag";
|
||||
|
||||
export default {
|
||||
name: "MsUser",
|
||||
components: {MsCreateBox, MsTablePagination, MsTableHeader, MsTableOperator, MsDialogFooter, MsTableOperatorButton},
|
||||
components: {
|
||||
MsCreateBox,
|
||||
MsTablePagination,
|
||||
MsTableHeader,
|
||||
MsTableOperator,
|
||||
MsDialogFooter,
|
||||
MsTableOperatorButton,
|
||||
MsRolesTag
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
queryPath: '/user/special/list',
|
||||
|
@ -152,7 +151,6 @@
|
|||
createVisible: false,
|
||||
updateVisible: false,
|
||||
editPasswordVisible: false,
|
||||
checkPasswordVisible: false,
|
||||
multipleSelection: [],
|
||||
currentPage: 1,
|
||||
pageSize: 5,
|
||||
|
@ -271,9 +269,9 @@
|
|||
}
|
||||
})
|
||||
},
|
||||
editUserPassword(editPasswordForm){
|
||||
this.$refs[editPasswordForm].validate(valid=>{
|
||||
if(valid){
|
||||
editUserPassword(editPasswordForm) {
|
||||
this.$refs[editPasswordForm].validate(valid => {
|
||||
if (valid) {
|
||||
this.result = this.$post(this.editPasswordPath, this.ruleForm, response => {
|
||||
this.$success(this.$t('commons.modify_success'));
|
||||
this.editPasswordVisible = false;
|
||||
|
@ -290,6 +288,15 @@
|
|||
let data = response.data;
|
||||
this.total = data.itemCount;
|
||||
this.tableData = data.listObject;
|
||||
let url = "/user/special/user/role";
|
||||
for (let i = 0; i < this.tableData.length; i++) {
|
||||
this.$get(url + '/' + this.tableData[i].id, result => {
|
||||
let data = result.data;
|
||||
let roles = data.roles;
|
||||
// let userRoles = result.userRoles;
|
||||
this.$set(this.tableData[i], "roles", roles);
|
||||
})
|
||||
}
|
||||
})
|
||||
},
|
||||
handleClose() {
|
||||
|
@ -305,24 +312,6 @@
|
|||
},
|
||||
handleSelectionChange(val) {
|
||||
this.multipleSelection = val;
|
||||
},
|
||||
closeCheckPassword() {
|
||||
this.checkPasswordForm = {};
|
||||
},
|
||||
setAdmin(checkPasswordForm) {
|
||||
let user = getCurrentUser();
|
||||
this.$set(this.setAdminParam, 'adminId', user.id);
|
||||
this.$set(this.setAdminParam, 'password', this.checkPasswordForm.password);
|
||||
this.$refs[checkPasswordForm].validate(valid => {
|
||||
if (valid) {
|
||||
this.$post("/user/set/admin", this.setAdminParam, () => {
|
||||
this.$success(this.$t('commons.modify_success'));
|
||||
this.checkPasswordVisible = false;
|
||||
})
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue