Skip to content

Commit

Permalink
[Feature-288][datasophon-api] 集群能授权用户为管理员,同时也能解除授权 (#295)
Browse files Browse the repository at this point in the history
* fix datasophon-ui compile type error

* [Pull Request bug-288] 集群能授权用户为管理员,同时也能解除授权
  • Loading branch information
javaht authored Jun 28, 2023
1 parent d08929b commit 9a8a8b8
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

package com.datasophon.api.service.impl;

import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import com.datasophon.api.service.ClusterRoleUserService;
import com.datasophon.common.Constants;
import com.datasophon.common.utils.Result;
Expand All @@ -38,7 +39,7 @@
@Service("clusterRoleUserService")
public class ClusterRoleUserServiceImpl extends ServiceImpl<ClusterRoleUserMapper, ClusterRoleUserEntity>
implements
ClusterRoleUserService {
ClusterRoleUserService {

@Autowired
private ClusterRoleUserMapper clusterRoleUserMapper;
Expand All @@ -56,7 +57,12 @@ public boolean isClusterManager(Integer userId, String clusterId) {

@Override
public Result saveClusterManager(Integer clusterId, String userIds) {
// 首先删除原有管理员
this.remove(new QueryWrapper<ClusterRoleUserEntity>().eq(Constants.CLUSTER_ID, clusterId));
if (StringUtils.isEmpty(userIds)) {
// userIds 为空,表示取消授权
return Result.success();
}
ArrayList<ClusterRoleUserEntity> list = new ArrayList<>();
for (String userId : userIds.split(",")) {
Integer id = Integer.parseInt(userId);
Expand All @@ -74,4 +80,4 @@ public Result saveClusterManager(Integer clusterId, String userIds) {
public List<UserInfoEntity> getAllClusterManagerByClusterId(Integer clusterId) {
return clusterRoleUserMapper.getAllClusterManagerByClusterId(clusterId);
}
}
}
14 changes: 9 additions & 5 deletions datasophon-ui/src/pages/colonyManage/commponents/authCluster.vue
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
class="p0-32-10-32"
>
<a-form-item label="集群管理员">
<a-select mode="multiple" v-decorator="['userIds', { rules: [{ required: true, message: '集群管理员不能为空!' }]}]" placeholder="请选择集群管理员">
<a-select mode="multiple" v-decorator="['userIds', { rules: [{ required: false}]}]" placeholder="请选择集群管理员">
<a-select-option :value="item.id" v-for="(item,index) in userList" :key="index">{{item.username}}</a-select-option>
</a-select>
</a-form-item>
Expand Down Expand Up @@ -88,14 +88,18 @@ export default {
console.log(values);
if (!err) {
const params = {
"userIds": values.userIds
"userIds": values.userIds || ""
}
if (JSON.stringify(this.detail) !== '{}') params.clusterId = this.detail.id
this.loading = true;
this.$axiosPost(global.API.authCluster, params).then((res) => {
this.$axiosPost(global.API.authCluster, params).then((res) => {
this.loading = false;
if (res.code === 200) {
this.$message.success('授权成功', 2)
if (params.userIds.length > 0) {
this.$message.success('授权成功', 2)
}else{
this.$message.success('取消授权成功', 2)
}
this.$destroyAll();
_this.callBack();
}
Expand All @@ -117,4 +121,4 @@ export default {
};
</script>
<style lang="less" scoped>
</style>
</style>

0 comments on commit 9a8a8b8

Please sign in to comment.