ConfigController.java 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. package com.ruoyi.sim.controller;
  2. import com.ruoyi.common.core.domain.AjaxResult;
  3. import com.ruoyi.sim.config.SimDebugConfig;
  4. import io.swagger.annotations.Api;
  5. import io.swagger.annotations.ApiOperation;
  6. import org.springframework.web.bind.annotation.*;
  7. @RestController
  8. @RequestMapping("/sim/config")
  9. @Api("ConfigController")
  10. public class ConfigController {
  11. /**
  12. * http://192.168.1.151:8080/sim/config/set?key=CHECK_REPLACE_EMPTY&value=false
  13. * http://192.168.1.60:8080/sim/config/set?key=CHECK_REPLACE_EMPTY&value=false
  14. * http://192.168.1.60:8080/sim/config/set?key=SCHEDULED_CONNECT&value=false
  15. *
  16. * @param key
  17. * @param value
  18. * @return
  19. */
  20. @GetMapping(value = "/set")
  21. @ApiOperation("set config")
  22. public AjaxResult set(@RequestParam final String key, @RequestParam final String value) {
  23. if (SimDebugConfig.KEY_CHECK_REPLACE_EMPTY.equals(key.toUpperCase())) {
  24. SimDebugConfig.CHECK_REPLACE_EMPTY = Boolean.valueOf(value);
  25. return AjaxResult.success(SimDebugConfig.CHECK_REPLACE_EMPTY);
  26. }
  27. // 不允许关闭定时循环。
  28. // if (SimDebugConfig.KEY_SCHEDULED_CONNECT.equals(key.toUpperCase())) {
  29. // SimDebugConfig.SCHEDULED_CONNECT = Boolean.valueOf(value);
  30. // return AjaxResult.success(SimDebugConfig.SCHEDULED_CONNECT);
  31. // }
  32. return AjaxResult.error("no match key.");
  33. }
  34. /**
  35. * http://192.168.1.110:8080/sim/config/get?key=CHECK_REPLACE_EMPTY
  36. * http://192.168.1.60:8080/sim/config/get?key=SCHEDULED_CONNECT
  37. * @param key
  38. * @return
  39. */
  40. @GetMapping(value = "/get")
  41. @ApiOperation("get config")
  42. public AjaxResult get(@RequestParam final String key) {
  43. if (SimDebugConfig.KEY_CHECK_REPLACE_EMPTY.equals(key.toUpperCase())) {
  44. return AjaxResult.success(SimDebugConfig.CHECK_REPLACE_EMPTY);
  45. }
  46. if (SimDebugConfig.KEY_SCHEDULED_CONNECT.equals(key.toUpperCase())) {
  47. return AjaxResult.success(SimDebugConfig.SCHEDULED_CONNECT);
  48. }
  49. return AjaxResult.error("no match key.");
  50. }
  51. }