Record editting topic

This commit is contained in:
17hao
2021-02-05 12:18:50 +08:00
parent 44b7dd1808
commit 1fdb85234c

View File

@@ -1,6 +1,9 @@
package com.xiaojukeji.kafka.manager.service.service.impl; 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.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 +84,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 +347,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 +376,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 +412,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(JSONObject.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 {