提交 284c7260 作者: 925993793@qq.com

bug修改

上级 4dc0a14d
......@@ -21,9 +21,7 @@ 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;
import javax.servlet.http.HttpServletRequest;
import java.util.*;
/**
......@@ -102,9 +100,7 @@ public class EventManageController {
*/
@PostMapping(value = "/upload")
@ResponseBody
public Result<?> uploadKnowledge(HttpServletRequest request) {
MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request;
MultipartFile file = multipartRequest.getFile("file");// 获取上传文件对象
public Result<?> uploadKnowledge(MultipartFile file) {
String url = eventService.upload(file);
return Result.OK(url);
}
......
......@@ -186,11 +186,10 @@ public class EsStatisticsServiceImpl implements EsStatisticsService {
try {
SearchResponse response = client.search(searchRequest, RequestOptions.DEFAULT);
SearchHit[] hits = response.getHits().getHits();
if (hits.length == 0) {
return " There is nothing about this event in repeathold ";
if (hits.length > 0) {
SearchHit hit = hits[0];
title = hit.getSourceAsMap().get("title").toString();
}
SearchHit hit = hits[0];
title = hit.getSourceAsMap().get("title").toString();
} catch (Exception e) {
e.printStackTrace();
}
......
......@@ -230,7 +230,10 @@ public class EventServiceImpl extends ServiceImpl<EventMapper, Event> implements
public void updateMain(AddEventParam addEventParam) {
Event subject = new Event();
BeanUtils.copyProperties(addEventParam, subject);
subject.setEventIcon(subject.getEventIcon().replace(imgPreview,""));
String eventIcon = subject.getEventIcon();
if (StringUtils.isNotEmpty(eventIcon)) {
subject.setEventIcon(eventIcon.replace(imgPreview,""));
}
String eventId = subject.getId();
baseMapper.updateById(subject);
......@@ -271,7 +274,6 @@ public class EventServiceImpl extends ServiceImpl<EventMapper, Event> implements
log.info("文件上传成功:" + fileName + "---" + filePath);
} catch (Exception e) {
e.printStackTrace();
log.error(e.getMessage());
}
return filePath;
}
......@@ -336,7 +338,6 @@ public class EventServiceImpl extends ServiceImpl<EventMapper, Event> implements
Files.createDirectories(directory);
log.info("文件夹创建成功:" + filePath);
} catch (IOException e) {
log.error("文件夹创建失败:" + filePath);
e.printStackTrace();
}
}
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论