-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #297 from didi/dev
split op util controller to topic controller and leader controller, and add authority controller, quota controller
- Loading branch information
Showing
15 changed files
with
344 additions
and
98 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
47 changes: 47 additions & 0 deletions
47
...n/src/main/java/com/xiaojukeji/kafka/manager/common/entity/dto/gateway/TopicQuotaDTO.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
package com.xiaojukeji.kafka.manager.common.entity.dto.gateway; | ||
|
||
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 TopicQuotaDTO extends ClusterTopicDTO { | ||
@ApiModelProperty(value = "appId") | ||
private String appId; | ||
|
||
@ApiModelProperty(value = "发送数据速率B/s") | ||
private Long produceQuota; | ||
|
||
@ApiModelProperty(value = "消费数据速率B/s") | ||
private Long consumeQuota; | ||
|
||
public String getAppId() { | ||
return appId; | ||
} | ||
|
||
public void setAppId(String appId) { | ||
this.appId = appId; | ||
} | ||
|
||
public Long getProduceQuota() { | ||
return produceQuota; | ||
} | ||
|
||
public void setProduceQuota(Long produceQuota) { | ||
this.produceQuota = produceQuota; | ||
} | ||
|
||
public Long getConsumeQuota() { | ||
return consumeQuota; | ||
} | ||
|
||
public void setConsumeQuota(Long consumeQuota) { | ||
this.consumeQuota = consumeQuota; | ||
} | ||
|
||
@Override | ||
public boolean paramLegal() { | ||
return !ValidateUtils.isNullOrLessThanZero(clusterId) && !ValidateUtils.isBlank(topicName) && !ValidateUtils.isBlank(appId); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
...napi/src/main/java/com/xiaojukeji/kafka/manager/openapi/common/dto/TopicAuthorityDTO.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
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:读写, 4:可管理") | ||
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() { | ||
return !ValidateUtils.isNullOrLessThanZero(clusterId) | ||
&& !ValidateUtils.isBlank(topicName) | ||
&& !ValidateUtils.isBlank(appId) | ||
&& !ValidateUtils.isNullOrLessThanZero(access); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 35 additions & 0 deletions
35
...c/main/java/com/xiaojukeji/kafka/manager/web/api/versionone/op/OpAuthorityController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package com.xiaojukeji.kafka.manager.web.api.versionone.op; | ||
|
||
import com.xiaojukeji.kafka.manager.common.entity.Result; | ||
import com.xiaojukeji.kafka.manager.common.entity.ResultStatus; | ||
import com.xiaojukeji.kafka.manager.common.utils.ValidateUtils; | ||
import com.xiaojukeji.kafka.manager.openapi.common.dto.TopicAuthorityDTO; | ||
import com.xiaojukeji.kafka.manager.service.service.TopicManagerService; | ||
import com.xiaojukeji.kafka.manager.web.converters.AuthorityConverter; | ||
import io.swagger.annotations.Api; | ||
import io.swagger.annotations.ApiOperation; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.web.bind.annotation.*; | ||
|
||
/** | ||
* Authority操作相关接口 | ||
* @author zengqiao | ||
* @date 21/5/18 | ||
*/ | ||
@Api(tags = "OP-Authority操作相关接口(REST)") | ||
@RestController | ||
public class OpAuthorityController { | ||
@Autowired | ||
private TopicManagerService topicManagerService; | ||
|
||
@ApiOperation(value = "权限调整",notes = "权限调整") | ||
@PostMapping(value = "topic-authorities") | ||
@ResponseBody | ||
public Result addAuthority(@RequestBody TopicAuthorityDTO dto) { | ||
//非空校验 | ||
if (ValidateUtils.isNull(dto) || !dto.paramLegal()) { | ||
return Result.buildFrom(ResultStatus.PARAM_ILLEGAL); | ||
} | ||
return Result.buildFrom(topicManagerService.addAuthority(AuthorityConverter.convert2AuthorityDO(dto))); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.