mirror of
https://github.com/didi/KnowStreaming.git
synced 2025-12-24 11:52:08 +08:00
@@ -104,5 +104,10 @@
|
||||
<groupId>javax.servlet</groupId>
|
||||
<artifactId>javax.servlet-api</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</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;
|
||||
|
||||
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.constant.KafkaConstant;
|
||||
import com.xiaojukeji.kafka.manager.common.constant.KafkaMetricsCollections;
|
||||
@@ -81,6 +83,9 @@ public class TopicManagerServiceImpl implements TopicManagerService {
|
||||
@Autowired
|
||||
private RegionService regionService;
|
||||
|
||||
@Autowired
|
||||
private OperateRecordService operateRecordService;
|
||||
|
||||
@Override
|
||||
public List<TopicDO> listAll() {
|
||||
try {
|
||||
@@ -341,6 +346,12 @@ public class TopicManagerServiceImpl implements TopicManagerService {
|
||||
if (ValidateUtils.isNull(topicDO)) {
|
||||
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);
|
||||
if (topicDao.updateByName(topicDO) > 0) {
|
||||
return ResultStatus.SUCCESS;
|
||||
@@ -364,6 +375,12 @@ public class TopicManagerServiceImpl implements TopicManagerService {
|
||||
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);
|
||||
if (ValidateUtils.isNull(topicDO)) {
|
||||
// 不存在, 则需要插入
|
||||
@@ -394,6 +411,16 @@ public class TopicManagerServiceImpl implements TopicManagerService {
|
||||
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
|
||||
public int deleteByTopicName(Long clusterId, String topicName) {
|
||||
try {
|
||||
|
||||
Reference in New Issue
Block a user