| | |
| | | package com.stylefeng.guns.modular.system.controller.system; |
| | | |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import javax.servlet.http.HttpServletResponse; |
| | | |
| | | import com.stylefeng.guns.modular.system.util.OssUploadUtil ; |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.stylefeng.guns.config.properties.GunsProperties; |
| | | import com.stylefeng.guns.core.util.ToolUtil; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Controller; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.ResponseBody; |
| | | import org.springframework.web.multipart.MultipartFile; |
| | | import org.springframework.web.multipart.MultipartHttpServletRequest; |
| | | |
| | | import com.alibaba.fastjson.JSON; |
| | | |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import java.io.File; |
| | | import java.util.UUID; |
| | | |
| | | @Controller |
| | | public class UediterController { |
| | | /*@RequestMapping("/config") |
| | | public String getConfigInfo(HttpServletRequest request,HttpServletResponse response){ |
| | | return "redirect:/static/js/ueditor/jsp/jsp/config.json"; |
| | | }*/ |
| | | |
| | | /*@RequestMapping("/config") |
| | | public String getConfigInfo(HttpServletRequest request,HttpServletResponse response){ |
| | | return "redirect:/static/js/ueditor/jsp/jsp/config.json"; |
| | | }*/ |
| | | public final static String UEDITOR_CONFIG = "{\n" + |
| | | " \"imageActionName\": \"uploadimage\",\n" + |
| | | " \"imageFieldName\": \"upfile\",\n" + |
| | |
| | | " ] \n" + |
| | | "\n" + |
| | | "}"; |
| | | @Autowired |
| | | private GunsProperties gunsProperties; |
| | | |
| | | @RequestMapping(value = "/config") |
| | | @ResponseBody |
| | | public JSON config(String action, HttpServletRequest request, HttpServletResponse response) { |
| | |
| | | String callback = request.getParameter("callback"); |
| | | String pictureName = ""; |
| | | try { |
| | | //文件上传,具体根据实际替换 |
| | | pictureName = OssUploadUtil.ossUpload(request, picture); |
| | | |
| | | |
| | | String fileName = UUID.randomUUID().toString() + "." + ToolUtil.getFileSuffix(picture.getOriginalFilename()); |
| | | try { |
| | | String fileSavePath = gunsProperties.getFileUploadPath() + "img\\"; |
| | | picture.transferTo(new File(fileSavePath + fileName)); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | pictureName = gunsProperties.getPictureServerAddress() + "img/" + fileName; |
| | | |
| | | |
| | | //文件上传,具体根据实际替换 |
| | | // pictureName = OssUploadUtil.ossUpload(request, picture); |
| | | |
| | | String result = "{'original': '" + picture.getOriginalFilename() + "', 'state': 'SUCCESS', 'url': '" + pictureName + "'}"; |
| | | if (callback == null) { |
| | | return JSON.parseObject(result); |