|
|
@@ -1,5 +1,8 @@
|
|
|
package com.izouma.nineth.web;
|
|
|
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
+import com.izouma.nineth.config.EventNames;
|
|
|
+import com.izouma.nineth.config.GeneralProperties;
|
|
|
import com.izouma.nineth.domain.SysConfig;
|
|
|
import com.izouma.nineth.dto.PageQuery;
|
|
|
import com.izouma.nineth.exception.BusinessException;
|
|
|
@@ -7,6 +10,7 @@ import com.izouma.nineth.repo.SysConfigRepo;
|
|
|
import com.izouma.nineth.service.SysConfigService;
|
|
|
import com.izouma.nineth.utils.excel.ExcelUtils;
|
|
|
import lombok.AllArgsConstructor;
|
|
|
+import org.apache.rocketmq.spring.core.RocketMQTemplate;
|
|
|
import org.springframework.cache.annotation.CacheEvict;
|
|
|
import org.springframework.data.domain.Page;
|
|
|
import org.springframework.security.access.prepost.PreAuthorize;
|
|
|
@@ -21,14 +25,26 @@ import java.util.List;
|
|
|
@RequestMapping("/sysConfig")
|
|
|
@AllArgsConstructor
|
|
|
public class SysConfigController extends BaseController {
|
|
|
- private SysConfigService sysConfigService;
|
|
|
- private SysConfigRepo sysConfigRepo;
|
|
|
+ private SysConfigService sysConfigService;
|
|
|
+ private SysConfigRepo sysConfigRepo;
|
|
|
+ private RocketMQTemplate rocketMQTemplate;
|
|
|
+ private GeneralProperties generalProperties;
|
|
|
|
|
|
@PreAuthorize("hasRole('ADMIN')")
|
|
|
@PostMapping("/save")
|
|
|
@CacheEvict(value = {"SysConfigServiceGetBigDecimal", "SysConfigServiceGetTime", "SysConfigServiceGetBoolean", "SysConfigServiceGetInt"}, allEntries = true)
|
|
|
public SysConfig save(@RequestBody SysConfig record) {
|
|
|
- return sysConfigRepo.save(record);
|
|
|
+ record = sysConfigRepo.save(record);
|
|
|
+
|
|
|
+ JSONObject jsonObject = new JSONObject();
|
|
|
+ jsonObject.put("name", EventNames.CONFIG_CHANGE);
|
|
|
+ JSONObject data = new JSONObject();
|
|
|
+ data.put("name", record.getName());
|
|
|
+ data.put("value", record.getValue());
|
|
|
+ jsonObject.put("data", data);
|
|
|
+ rocketMQTemplate.convertAndSend(generalProperties.getBroadcastEventTopic(), jsonObject);
|
|
|
+
|
|
|
+ return record;
|
|
|
}
|
|
|
|
|
|
|