增加插件模块
This commit is contained in:
@@ -3,12 +3,16 @@ package com.jsh.erp.controller;
|
||||
import com.gitee.starblues.integration.application.PluginApplication;
|
||||
import com.gitee.starblues.integration.operator.PluginOperator;
|
||||
import com.gitee.starblues.integration.operator.module.PluginInfo;
|
||||
import com.jsh.erp.utils.BaseResponseInfo;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.nio.file.Paths;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
@@ -31,9 +35,24 @@ public class PluginController {
|
||||
* 获取插件信息
|
||||
* @return 返回插件信息
|
||||
*/
|
||||
@GetMapping
|
||||
public List<PluginInfo> getPluginInfo(){
|
||||
return pluginOperator.getPluginInfo();
|
||||
@GetMapping(value = "/list")
|
||||
public BaseResponseInfo getPluginInfo(@RequestParam("currentPage") Integer currentPage,
|
||||
@RequestParam("pageSize") Integer pageSize,
|
||||
HttpServletRequest request) throws Exception{
|
||||
BaseResponseInfo res = new BaseResponseInfo();
|
||||
Map<String, Object> map = new HashMap<String, Object>();
|
||||
try {
|
||||
List<PluginInfo> list = pluginOperator.getPluginInfo();
|
||||
map.put("rows", list);
|
||||
map.put("total", list.size());
|
||||
res.code = 200;
|
||||
res.data = map;
|
||||
} catch(Exception e){
|
||||
e.printStackTrace();
|
||||
res.code = 500;
|
||||
res.data = "获取数据失败";
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -57,17 +76,26 @@ public class PluginController {
|
||||
* @return 返回操作结果
|
||||
*/
|
||||
@PostMapping("/stop/{id}")
|
||||
public String stop(@PathVariable("id") String id){
|
||||
public BaseResponseInfo stop(@PathVariable("id") String id){
|
||||
BaseResponseInfo res = new BaseResponseInfo();
|
||||
Map<String, Object> map = new HashMap<String, Object>();
|
||||
String message = "";
|
||||
try {
|
||||
if(pluginOperator.stop(id)){
|
||||
return "plugin '" + id +"' stop success";
|
||||
message = "plugin '" + id +"' stop success";
|
||||
} else {
|
||||
return "plugin '" + id +"' stop failure";
|
||||
message = "plugin '" + id +"' stop failure";
|
||||
}
|
||||
map.put("message", message);
|
||||
res.code = 200;
|
||||
res.data = map;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return "plugin '" + id +"' stop failure. " + e.getMessage();
|
||||
map.put("message", "plugin '" + id +"' stop failure. " + e.getMessage());
|
||||
res.code = 500;
|
||||
res.data = map;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -76,17 +104,26 @@ public class PluginController {
|
||||
* @return 返回操作结果
|
||||
*/
|
||||
@PostMapping("/start/{id}")
|
||||
public String start(@PathVariable("id") String id){
|
||||
public BaseResponseInfo start(@PathVariable("id") String id){
|
||||
BaseResponseInfo res = new BaseResponseInfo();
|
||||
Map<String, Object> map = new HashMap<String, Object>();
|
||||
String message = "";
|
||||
try {
|
||||
if(pluginOperator.start(id)){
|
||||
return "plugin '" + id +"' start success";
|
||||
message = "plugin '" + id +"' start success";
|
||||
} else {
|
||||
return "plugin '" + id +"' start failure";
|
||||
message = "plugin '" + id +"' start failure";
|
||||
}
|
||||
map.put("message", message);
|
||||
res.code = 200;
|
||||
res.data = map;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return "plugin '" + id +"' start failure. " + e.getMessage();
|
||||
map.put("message", "plugin '" + id +"' start failure. " + e.getMessage());
|
||||
res.code = 500;
|
||||
res.data = map;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user