Commit 67a1ce83 authored by whlviolin's avatar whlviolin

增加算法分析接口

parent 0f04cd92
package cn.ac.iscas.server;
import org.apache.catalina.connector.Connector;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.web.embedded.tomcat.TomcatConnectorCustomizer;
import org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory;
import org.springframework.boot.web.servlet.server.ConfigurableServletWebServerFactory;
import org.springframework.cloud.netflix.eureka.EnableEurekaClient;
import org.springframework.context.annotation.Bean;
@SpringBootApplication
@EnableEurekaClient
......@@ -12,4 +17,15 @@ public class ServerApplication {
SpringApplication.run(ServerApplication.class, args);
}
@Bean
public ConfigurableServletWebServerFactory webServerFactory() {
TomcatServletWebServerFactory factory = new TomcatServletWebServerFactory();
factory.addConnectorCustomizers(new TomcatConnectorCustomizer() {
@Override
public void customize(Connector connector) {
connector.setProperty("relaxedQueryChars", "|{}[]");
}
});
return factory;
}
}
......@@ -11,29 +11,36 @@ import java.util.List;
@CrossOrigin
@RestController
@RequestMapping("/api/algo/")
@RequestMapping("/algo/")
public class AlgoController {
@Autowired
AlgorithmService algorithmService;
@RequestMapping(value = "/run", method = RequestMethod.GET)
public boolean insertFileList(
public Result insertFileList(
@RequestParam("name")String name,
@RequestParam("fId")String fId,
@RequestParam("algo")String algo,
@RequestParam("ar")String ar,
@RequestParam("name")List name
@RequestParam("ar")String ar
) throws Exception{
String data = algorithmService.run(fId, algo, ar, name);
return false;
String data = algorithmService.run(name, fId,algo, ar);
if (data != null) {
return new Result(200, "success", data);
} else {
return new Result(HttpStatus.INTERNAL_SERVER_ERROR.value(), "failed",null);
}
}
@RequestMapping(value = "/runDEA", method = RequestMethod.GET)
public ResponseEntity<List<FileList>> runDEA(
@RequestParam("name")String name,
@RequestParam("fId")String fId,
@RequestParam("args_x")String args_x,
@RequestParam("args_y")String args_y
) throws Exception{
List<FileList> data = null;
List data = algorithmService.runDEA(name, fId, args_x, args_y);
if (data != null) {
return ResponseEntity.ok(data);
} else {
......
......@@ -4,5 +4,7 @@ import java.util.List;
public interface AlgorithmService {
public String run(String name, String fId, String algo, List args)throws Exception;
public String run(String name, String fId, String algo, String args)throws Exception;
public List runDEA(String name, String fId, String algo, String args)throws Exception;
}
......@@ -15,7 +15,7 @@ public class AlgorithmServiceImpl implements AlgorithmService {
private String baseFile;
@Override
public String run(String name, String fId, String algo, List args) throws Exception{
public String run(String name, String fId, String algo, String args) throws Exception{
// 查找文件扩展名的位置
int dotIndex = name.lastIndexOf('.');
String fileType="";
......@@ -27,9 +27,15 @@ public class AlgorithmServiceImpl implements AlgorithmService {
CSVTableData csvTableData = new ReadFileUtil().read_csv(filePath, name);
List algoRes = csvTableData.getData();
for(Object arg : args) {
// for(Object arg : args) {
//
// }
return null;
}
}
public List runDEA(String name, String fId, String algo, String args) throws Exception{
Object result = new Object();
CSVTableData csvTableData = new ReadFileUtil().read_csv(baseFile + fId, name);
return null;
}
}
\ No newline at end of file
......@@ -68,4 +68,18 @@ public class ReadFileUtil {
return tableData;
}
public String getFullPath(String baseFile, String fId, String name){
// 查找文件扩展名的位置
int dotIndex = name.lastIndexOf('.');
String fileType="";
if (dotIndex != -1 && dotIndex < name.length() - 1) {
// 提取文件扩展名
fileType = name.substring(dotIndex + 1);
}
String filePath = baseFile + fId + fileType;
return filePath;
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment