Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
DiDi
kafka-manager
提交
7218aaf5
K
kafka-manager
项目概览
DiDi
/
kafka-manager
12 个月 前同步成功
通知
59
Star
6372
Fork
1229
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
K
kafka-manager
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
7218aaf5
编写于
5月 13, 2021
作者:
T
tangcongfa_v@didichuxing.com
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
权限调整
上级
eb8fe775
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
99 addition
and
0 deletion
+99
-0
kafka-manager-extends/kafka-manager-openapi/src/main/java/com/xiaojukeji/kafka/manager/openapi/common/dto/TopicAuthorityDTO.java
...i/kafka/manager/openapi/common/dto/TopicAuthorityDTO.java
+43
-0
kafka-manager-web/src/main/java/com/xiaojukeji/kafka/manager/web/api/versionone/thirdpart/ThirdPartTopicController.java
...eb/api/versionone/thirdpart/ThirdPartTopicController.java
+56
-0
未找到文件。
kafka-manager-extends/kafka-manager-openapi/src/main/java/com/xiaojukeji/kafka/manager/openapi/common/dto/TopicAuthorityDTO.java
0 → 100644
浏览文件 @
7218aaf5
package
com.xiaojukeji.kafka.manager.openapi.common.dto
;
import
com.xiaojukeji.kafka.manager.common.entity.dto.ClusterTopicDTO
;
import
com.xiaojukeji.kafka.manager.common.utils.ValidateUtils
;
import
io.swagger.annotations.ApiModel
;
import
io.swagger.annotations.ApiModelProperty
;
@ApiModel
(
description
=
"权限调整"
)
public
class
TopicAuthorityDTO
extends
ClusterTopicDTO
{
@ApiModelProperty
(
value
=
"appId"
)
private
String
appId
;
@ApiModelProperty
(
value
=
"0:无权限, 1:读, 2:写, 3:读写"
)
private
Integer
access
;
public
String
getAppId
()
{
return
appId
;
}
public
void
setAppId
(
String
appId
)
{
this
.
appId
=
appId
;
}
public
Integer
getAccess
()
{
return
access
;
}
public
void
setAccess
(
Integer
access
)
{
this
.
access
=
access
;
}
@Override
public
boolean
paramLegal
()
{
if
(
ValidateUtils
.
isNull
(
clusterId
)
||
ValidateUtils
.
isNull
(
topicName
)
||
ValidateUtils
.
isNull
(
appId
)
||
ValidateUtils
.
isNull
(
access
))
{
return
false
;
}
return
true
;
}
}
kafka-manager-web/src/main/java/com/xiaojukeji/kafka/manager/web/api/versionone/thirdpart/ThirdPartTopicController.java
浏览文件 @
7218aaf5
...
...
@@ -8,13 +8,17 @@ import com.xiaojukeji.kafka.manager.common.entity.ResultStatus;
import
com.xiaojukeji.kafka.manager.common.entity.ao.gateway.TopicQuota
;
import
com.xiaojukeji.kafka.manager.common.entity.dto.normal.TopicQuotaDTO
;
import
com.xiaojukeji.kafka.manager.common.entity.metrics.BaseMetrics
;
import
com.xiaojukeji.kafka.manager.common.entity.pojo.TopicDO
;
import
com.xiaojukeji.kafka.manager.common.entity.pojo.gateway.AppDO
;
import
com.xiaojukeji.kafka.manager.common.entity.pojo.gateway.AuthorityDO
;
import
com.xiaojukeji.kafka.manager.common.entity.vo.common.RealTimeMetricsVO
;
import
com.xiaojukeji.kafka.manager.common.entity.vo.normal.cluster.TopicMetadataVO
;
import
com.xiaojukeji.kafka.manager.common.entity.vo.normal.consumer.ConsumerGroupVO
;
import
com.xiaojukeji.kafka.manager.common.entity.vo.normal.topic.TopicAuthorizedAppVO
;
import
com.xiaojukeji.kafka.manager.common.entity.vo.normal.topic.TopicRequestTimeDetailVO
;
import
com.xiaojukeji.kafka.manager.common.utils.SpringTool
;
import
com.xiaojukeji.kafka.manager.common.zookeeper.znode.brokers.TopicMetadata
;
import
com.xiaojukeji.kafka.manager.openapi.common.dto.TopicAuthorityDTO
;
import
com.xiaojukeji.kafka.manager.openapi.common.vo.TopicOffsetChangedVO
;
import
com.xiaojukeji.kafka.manager.common.utils.ValidateUtils
;
import
com.xiaojukeji.kafka.manager.common.entity.pojo.ClusterDO
;
...
...
@@ -22,6 +26,7 @@ import com.xiaojukeji.kafka.manager.service.cache.LogicalClusterMetadataManager;
import
com.xiaojukeji.kafka.manager.service.cache.PhysicalClusterMetadataManager
;
import
com.xiaojukeji.kafka.manager.service.service.*
;
import
com.xiaojukeji.kafka.manager.common.constant.ApiPrefix
;
import
com.xiaojukeji.kafka.manager.service.service.gateway.AppService
;
import
com.xiaojukeji.kafka.manager.service.service.gateway.AuthorityService
;
import
com.xiaojukeji.kafka.manager.service.service.gateway.QuotaService
;
import
com.xiaojukeji.kafka.manager.web.converters.CommonModelConverter
;
...
...
@@ -35,6 +40,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import
org.springframework.web.bind.annotation.*
;
import
java.util.List
;
import
java.util.stream.Collectors
;
/**
* @author zengqiao
...
...
@@ -67,6 +73,9 @@ public class ThirdPartTopicController {
@Autowired
private
LogicalClusterMetadataManager
logicalClusterMetadataManager
;
@Autowired
private
AppService
appService
;
@ApiOperation
(
value
=
"Topic元信息"
,
notes
=
"LogX调用"
)
@RequestMapping
(
value
=
"clusters/{clusterId}/topics/{topicName}/metadata"
,
method
=
RequestMethod
.
GET
)
@ResponseBody
...
...
@@ -189,4 +198,51 @@ public class ThirdPartTopicController {
return
Result
.
buildFrom
(
ResultStatus
.
MYSQL_ERROR
);
}
@ApiOperation
(
value
=
"权限调整"
,
notes
=
"权限调整"
)
@RequestMapping
(
value
=
"{topics/authority/add}"
,
method
=
RequestMethod
.
POST
)
@ResponseBody
public
Result
addAuthority
(
@RequestBody
TopicAuthorityDTO
dto
)
{
//非空校验
if
(
ValidateUtils
.
isNull
(
dto
)
||
!
dto
.
paramLegal
())
{
return
Result
.
buildFrom
(
ResultStatus
.
PARAM_ILLEGAL
);
}
//查询该用户拥有的应用
List
<
AppDO
>
appDOs
=
appService
.
getByPrincipal
(
SpringTool
.
getUserName
());
if
(
ValidateUtils
.
isEmptyList
(
appDOs
))
{
//该用户无应用,需要先申请应用
return
Result
.
buildFrom
(
ResultStatus
.
APP_NOT_EXIST
);
}
List
<
Long
>
appIds
=
appDOs
.
stream
().
map
(
AppDO:
:
getId
).
collect
(
Collectors
.
toList
());
if
(!
appIds
.
contains
(
dto
.
getAccess
()))
{
//入参中的appId,该用户未拥有
return
Result
.
buildFrom
(
ResultStatus
.
PARAM_ILLEGAL
);
}
//获取物理集群id
Long
physicalClusterId
=
logicalClusterMetadataManager
.
getPhysicalClusterId
(
dto
.
getClusterId
());
if
(
ValidateUtils
.
isNull
(
physicalClusterId
))
{
//集群不存在
return
Result
.
buildFrom
(
ResultStatus
.
CLUSTER_NOT_EXIST
);
}
//获取集群信息
ClusterDO
clusterDO
=
clusterService
.
getById
(
physicalClusterId
);
if
(
ValidateUtils
.
isNull
(
clusterDO
))
{
//集群不存在
return
Result
.
buildFrom
(
ResultStatus
.
CLUSTER_NOT_EXIST
);
}
TopicDO
topic
=
topicManagerService
.
getByTopicName
(
physicalClusterId
,
dto
.
getTopicName
());
if
(
ValidateUtils
.
isNull
(
topic
))
{
//topic不存在
return
Result
.
buildFrom
(
ResultStatus
.
TOPIC_NOT_EXIST
);
}
//构建authorityDo
AuthorityDO
authorityDO
=
new
AuthorityDO
();
authorityDO
.
setClusterId
(
physicalClusterId
);
authorityDO
.
setAppId
(
dto
.
getAppId
());
authorityDO
.
setTopicName
(
dto
.
getTopicName
());
authorityDO
.
setAccess
(
dto
.
getAccess
());
if
(
authorityService
.
addAuthority
(
authorityDO
)
>
0
)
{
return
Result
.
buildFrom
(
ResultStatus
.
SUCCESS
);
}
return
Result
.
buildFrom
(
ResultStatus
.
MYSQL_ERROR
);
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录