Browse Source

增加校验

master
liuchen 8 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;
import org.apache.rocketmq.dashboard.permisssion.Permission;
import org.apache.rocketmq.dashboard.service.ConfigService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
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 java.util.Map;
@ -43,20 +44,35 @@ public class ConfigController {
@RequestMapping(value = "/config.create")
@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);
}
@RequestMapping(value = "/config.update")
@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);
}
@RequestMapping(value = "/config.delete")
@ResponseBody
public boolean delete(String name, String value) {
return configService.deleteConfig(name, value);
public boolean delete(@RequestParam String name) {
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 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
public boolean deleteConfig(String name, String value) {
public boolean deleteConfig(String name) {
String fileName = rmqConfigure.getRocketMqDashboardDataPath() + File.separator + name + ".txt";
File file = new File(fileName);
if(!file.exists()) {

Loading…
Cancel
Save