Browse Source

增加校验

master
liuchen 10 months ago
parent
commit
f13591f325
  1. 28
      src/main/java/org/apache/rocketmq/dashboard/controller/ConfigController.java
  2. 2
      src/main/java/org/apache/rocketmq/dashboard/service/ConfigService.java
  3. 2
      src/main/java/org/apache/rocketmq/dashboard/service/impl/ConfigServiceImpl.java

28
src/main/java/org/apache/rocketmq/dashboard/controller/ConfigController.java

@ -16,12 +16,13 @@
*/ */
package org.apache.rocketmq.dashboard.controller; package org.apache.rocketmq.dashboard.controller;
import org.apache.rocketmq.dashboard.permisssion.Permission;
import org.apache.rocketmq.dashboard.service.ConfigService; import org.apache.rocketmq.dashboard.service.ConfigService;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Controller; import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.util.Map; import java.util.Map;
@ -43,20 +44,35 @@ public class ConfigController {
@RequestMapping(value = "/config.create") @RequestMapping(value = "/config.create")
@ResponseBody @ResponseBody
public boolean create(String name, String value) { public boolean create(@RequestParam String name, @RequestParam String value) {
if(name == null || name.isEmpty()) {
throw new RuntimeException("name is empty!");
}
if(value == null || value.isEmpty()) {
throw new RuntimeException("value is empty!");
}
return configService.createConfig(name, value); return configService.createConfig(name, value);
} }
@RequestMapping(value = "/config.update") @RequestMapping(value = "/config.update")
@ResponseBody @ResponseBody
public boolean update(String name, String value) { public boolean update(@RequestParam String name, @RequestParam String value) {
if(name == null || name.isEmpty()) {
throw new RuntimeException("name is empty!");
}
if(value == null || value.isEmpty()) {
throw new RuntimeException("value is empty!");
}
return configService.updateConfig(name, value); return configService.updateConfig(name, value);
} }
@RequestMapping(value = "/config.delete") @RequestMapping(value = "/config.delete")
@ResponseBody @ResponseBody
public boolean delete(String name, String value) { public boolean delete(@RequestParam String name) {
return configService.deleteConfig(name, value); if(name == null || name.isEmpty()) {
throw new RuntimeException("name is empty!");
}
return configService.deleteConfig(name);
} }
} }

2
src/main/java/org/apache/rocketmq/dashboard/service/ConfigService.java

@ -27,6 +27,6 @@ public interface ConfigService {
boolean updateConfig(String name, String value); boolean updateConfig(String name, String value);
boolean deleteConfig(String name, String value); boolean deleteConfig(String name);
} }

2
src/main/java/org/apache/rocketmq/dashboard/service/impl/ConfigServiceImpl.java

@ -102,7 +102,7 @@ public class ConfigServiceImpl extends AbstractCommonService implements ConfigSe
} }
@Override @Override
public boolean deleteConfig(String name, String value) { public boolean deleteConfig(String name) {
String fileName = rmqConfigure.getRocketMqDashboardDataPath() + File.separator + name + ".txt"; String fileName = rmqConfigure.getRocketMqDashboardDataPath() + File.separator + name + ".txt";
File file = new File(fileName); File file = new File(fileName);
if(!file.exists()) { if(!file.exists()) {

Loading…
Cancel
Save