73 lines
1.9 KiB
Java
73 lines
1.9 KiB
Java
package com.sf.vertx.controller;
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.web.bind.annotation.DeleteMapping;
|
|
import org.springframework.web.bind.annotation.PostMapping;
|
|
import org.springframework.web.bind.annotation.RequestBody;
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
|
|
import com.alibaba.fastjson2.JSONObject;
|
|
import com.sf.vertx.api.pojo.AppConfig;
|
|
import com.sf.vertx.api.pojo.VertxConfig;
|
|
import com.sf.vertx.service.AppConfigService;
|
|
|
|
/***
|
|
* 测试redis
|
|
*
|
|
* @author xy
|
|
*
|
|
*/
|
|
@RestController
|
|
@RequestMapping("/vertx")
|
|
public class AppConfigController {
|
|
@Autowired
|
|
private AppConfigService appConfigService;
|
|
|
|
@PostMapping("/app/config")
|
|
public JSONObject addAppConfig(@RequestBody AppConfig appConfig) {
|
|
JSONObject json = new JSONObject();
|
|
try {
|
|
appConfigService.saveAppConfig(appConfig);
|
|
json.put("code", 200);
|
|
json.put("msg", "success");
|
|
} catch (Exception e) {
|
|
e.printStackTrace();
|
|
json.put("code", 500);
|
|
json.put("msg", e.getMessage());
|
|
}
|
|
return json;
|
|
}
|
|
|
|
@DeleteMapping("/app/config")
|
|
public JSONObject deleteAppConfig(@RequestBody AppConfig appConfig) {
|
|
JSONObject json = new JSONObject();
|
|
try {
|
|
appConfigService.deleteAppConfig(appConfig);
|
|
json.put("code", 200);
|
|
json.put("msg", "success");
|
|
} catch (Exception e) {
|
|
e.printStackTrace();
|
|
json.put("code", 500);
|
|
json.put("msg", e.getMessage());
|
|
}
|
|
return json;
|
|
}
|
|
|
|
@PostMapping("/vertx/config")
|
|
public JSONObject saveVertxConfig(@RequestBody VertxConfig vertxConfig) {
|
|
JSONObject json = new JSONObject();
|
|
try {
|
|
appConfigService.saveVertxConfig(vertxConfig);
|
|
json.put("code", 200);
|
|
json.put("msg", "success");
|
|
} catch (Exception e) {
|
|
e.printStackTrace();
|
|
json.put("code", 500);
|
|
json.put("msg", e.getMessage());
|
|
}
|
|
return json;
|
|
}
|
|
|
|
}
|