提交 1fdb8523 编写于 作者: 1 17hao

Record editting topic

上级 44b7dd18
package com.xiaojukeji.kafka.manager.service.service.impl;
import com.alibaba.fastjson.JSONObject;
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 +84,9 @@ public class TopicManagerServiceImpl implements TopicManagerService {
@Autowired
private RegionService regionService;
@Autowired
private OperateRecordService operateRecordService;
@Override
public List<TopicDO> listAll() {
try {
......@@ -341,6 +347,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 +376,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 +412,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(JSONObject.toJSONString(content));
operateRecordDO.setOperator(operator);
operateRecordService.insert(operateRecordDO);
}
@Override
public int deleteByTopicName(Long clusterId, String topicName) {
try {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册