@ResponseBody @RequestMapping(value = "/upload", method = RequestMethod.POST) public ImmutableMap<String, String> linkImgUpload( MultipartFile file, HttpServletRequest request) { if (file.isEmpty()) { return ImmutableMap.of("status", "0", "message", getMessage("global.uploadempty.message")); } Site site = (Site) (SystemUtils.getSessionSite()); String linkPath = PathFormat.parseSiteId(SystemConstant.LINK_RES_PATH, site.getSiteId() + ""); String realPath = HttpUtils.getRealPath(request, linkPath); SystemUtils.isNotExistCreate(realPath); String timeFileName = SystemUtils.timeFileName(file.getOriginalFilename()); try { file.transferTo(new File(realPath + "/" + timeFileName)); } catch (IOException e) { LOGGER.error("链接图片添加失败,错误:{}", e.getMessage()); return ImmutableMap.of("status", "0", "message", getMessage("link.uploaderror.message")); } return ImmutableMap.of( "status", "1", "message", getMessage("link.uploadsuccess.message"), "filePath", (linkPath + "/" + timeFileName), "contentPath", HttpUtils.getBasePath(request)); }
@RequestMapping(value = "/{contentId}.htm") public String contentInfo( @PathVariable Long contentId, ModelMap modelMap, HttpServletRequest request) { Site site = (Site) request.getSession().getAttribute(SystemConstant.FRONT_SITE_SESSION_KEY); Content content = contentService.findOne(contentId); modelMap.addAttribute("content", content); String contpl = FilenameUtils.removeExtension( SystemUtils.formatUri(content.getColumn().getColumnType().getContenttpl())); return site.getThemeName() + "/" + contpl; }