增加字段和模型本地缓存
This commit is contained in:
@@ -21,6 +21,7 @@ import org.jpmml.evaluator.Evaluator;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
import org.springframework.web.multipart.MultipartHttpServletRequest;
|
||||
@@ -50,6 +51,13 @@ public class ModelsController {
|
||||
@Autowired
|
||||
private MachineLearningModelsMapper machineLearningModelsMapper;
|
||||
|
||||
@Value("${model.uploadDir}")
|
||||
private String modelUploadDir;
|
||||
|
||||
private static final String SLASH = "/";
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 获取模型列表信息
|
||||
* @return
|
||||
@@ -110,13 +118,16 @@ public class ModelsController {
|
||||
while (iter.hasNext()) {
|
||||
MultipartFile file = multiRequest.getFile(iter.next().toString());
|
||||
if (file != null) {
|
||||
String uploadDir = request.getSession().getServletContext().getRealPath("/") + "upload/models/fieldUpload/";
|
||||
// String uploadDir = request.getSession().getServletContext().getRealPath("/") + "upload/models/fieldUpload/";
|
||||
final String uploadDir = modelUploadDir;
|
||||
logger.info("modelUploadDir="+modelUploadDir);
|
||||
if (!new File(uploadDir).exists()) {
|
||||
File dir = new File(uploadDir);
|
||||
dir.mkdirs();
|
||||
}
|
||||
fileName = System.currentTimeMillis() + "_" + file.getOriginalFilename();
|
||||
String path = uploadDir + fileName;
|
||||
final String path = buildPath(uploadDir,fileName);
|
||||
logger.info("modelFilePath"+path);
|
||||
//上传
|
||||
file.transferTo(new File(path));
|
||||
accessUrl = path;
|
||||
@@ -138,6 +149,18 @@ public class ModelsController {
|
||||
}
|
||||
}
|
||||
|
||||
@RequestMapping(value = "getModelUploadDir")
|
||||
public String getModelUploadDir(){
|
||||
return modelUploadDir;
|
||||
}
|
||||
|
||||
private String buildPath(String dir,String fileName){
|
||||
if(dir.endsWith(SLASH)){
|
||||
return dir + fileName;
|
||||
}
|
||||
return dir + SLASH + fileName;
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加模型
|
||||
* @param models
|
||||
|
||||
Reference in New Issue
Block a user