mirror of
https://github.com/didi/KnowStreaming.git
synced 2026-01-04 11:52:07 +08:00
@@ -104,5 +104,10 @@
|
|||||||
<groupId>javax.servlet</groupId>
|
<groupId>javax.servlet</groupId>
|
||||||
<artifactId>javax.servlet-api</artifactId>
|
<artifactId>javax.servlet-api</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>junit</groupId>
|
||||||
|
<artifactId>junit</artifactId>
|
||||||
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
</project>
|
</project>
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
package com.xiaojukeji.kafka.manager.common.utils;
|
||||||
|
|
||||||
|
import org.junit.Assert;
|
||||||
|
import org.junit.Test;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
public class JsonUtilsTest {
|
||||||
|
@Test
|
||||||
|
public void testMapToJsonString() {
|
||||||
|
Map<String, Object> map = new HashMap<>();
|
||||||
|
map.put("key", "value");
|
||||||
|
map.put("int", 1);
|
||||||
|
String expectRes = "{\"key\":\"value\",\"int\":1}";
|
||||||
|
Assert.assertEquals(expectRes, JsonUtils.toJSONString(map));
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,6 +1,8 @@
|
|||||||
package com.xiaojukeji.kafka.manager.service.service.impl;
|
package com.xiaojukeji.kafka.manager.service.service.impl;
|
||||||
|
|
||||||
import com.xiaojukeji.kafka.manager.common.bizenum.KafkaClientEnum;
|
import com.xiaojukeji.kafka.manager.common.bizenum.KafkaClientEnum;
|
||||||
|
import com.xiaojukeji.kafka.manager.common.bizenum.ModuleEnum;
|
||||||
|
import com.xiaojukeji.kafka.manager.common.bizenum.OperateEnum;
|
||||||
import com.xiaojukeji.kafka.manager.common.bizenum.TopicAuthorityEnum;
|
import com.xiaojukeji.kafka.manager.common.bizenum.TopicAuthorityEnum;
|
||||||
import com.xiaojukeji.kafka.manager.common.constant.KafkaConstant;
|
import com.xiaojukeji.kafka.manager.common.constant.KafkaConstant;
|
||||||
import com.xiaojukeji.kafka.manager.common.constant.KafkaMetricsCollections;
|
import com.xiaojukeji.kafka.manager.common.constant.KafkaMetricsCollections;
|
||||||
@@ -81,6 +83,9 @@ public class TopicManagerServiceImpl implements TopicManagerService {
|
|||||||
@Autowired
|
@Autowired
|
||||||
private RegionService regionService;
|
private RegionService regionService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private OperateRecordService operateRecordService;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<TopicDO> listAll() {
|
public List<TopicDO> listAll() {
|
||||||
try {
|
try {
|
||||||
@@ -341,6 +346,12 @@ public class TopicManagerServiceImpl implements TopicManagerService {
|
|||||||
if (ValidateUtils.isNull(topicDO)) {
|
if (ValidateUtils.isNull(topicDO)) {
|
||||||
return ResultStatus.TOPIC_NOT_EXIST;
|
return ResultStatus.TOPIC_NOT_EXIST;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Map<String, Object> content = new HashMap<>(2);
|
||||||
|
content.put("clusterId", clusterId);
|
||||||
|
content.put("topicName", topicName);
|
||||||
|
recordOperation(content, topicName, operator);
|
||||||
|
|
||||||
topicDO.setDescription(description);
|
topicDO.setDescription(description);
|
||||||
if (topicDao.updateByName(topicDO) > 0) {
|
if (topicDao.updateByName(topicDO) > 0) {
|
||||||
return ResultStatus.SUCCESS;
|
return ResultStatus.SUCCESS;
|
||||||
@@ -364,6 +375,12 @@ public class TopicManagerServiceImpl implements TopicManagerService {
|
|||||||
return ResultStatus.APP_NOT_EXIST;
|
return ResultStatus.APP_NOT_EXIST;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Map<String, Object> content = new HashMap<>(4);
|
||||||
|
content.put("clusterId", clusterId);
|
||||||
|
content.put("topicName", topicName);
|
||||||
|
content.put("appId", appId);
|
||||||
|
recordOperation(content, topicName, operator);
|
||||||
|
|
||||||
TopicDO topicDO = topicDao.getByTopicName(clusterId, topicName);
|
TopicDO topicDO = topicDao.getByTopicName(clusterId, topicName);
|
||||||
if (ValidateUtils.isNull(topicDO)) {
|
if (ValidateUtils.isNull(topicDO)) {
|
||||||
// 不存在, 则需要插入
|
// 不存在, 则需要插入
|
||||||
@@ -394,6 +411,16 @@ public class TopicManagerServiceImpl implements TopicManagerService {
|
|||||||
return ResultStatus.MYSQL_ERROR;
|
return ResultStatus.MYSQL_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void recordOperation(Map<String, Object> content, String topicName, String operator) {
|
||||||
|
OperateRecordDO operateRecordDO = new OperateRecordDO();
|
||||||
|
operateRecordDO.setModuleId(ModuleEnum.TOPIC.getCode());
|
||||||
|
operateRecordDO.setOperateId(OperateEnum.EDIT.getCode());
|
||||||
|
operateRecordDO.setResource(topicName);
|
||||||
|
operateRecordDO.setContent(JsonUtils.toJSONString(content));
|
||||||
|
operateRecordDO.setOperator(operator);
|
||||||
|
operateRecordService.insert(operateRecordDO);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int deleteByTopicName(Long clusterId, String topicName) {
|
public int deleteByTopicName(Long clusterId, String topicName) {
|
||||||
try {
|
try {
|
||||||
|
|||||||
Reference in New Issue
Block a user