From 475f27a23420f0c2b93603e2ee5a26f58604cc72 Mon Sep 17 00:00:00 2001 From: megagao Date: Thu, 6 Oct 2016 21:53:10 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E4=BA=86=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/PictureController.java | 50 +++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 src/main/java/org/hqu/production_ms/controller/PictureController.java diff --git a/src/main/java/org/hqu/production_ms/controller/PictureController.java b/src/main/java/org/hqu/production_ms/controller/PictureController.java new file mode 100644 index 0000000..d45b4af --- /dev/null +++ b/src/main/java/org/hqu/production_ms/controller/PictureController.java @@ -0,0 +1,50 @@ +package org.hqu.production_ms.controller; + +import java.util.HashMap; +import java.util.Map; +import org.hqu.production_ms.service.PictureService; +import org.hqu.production_ms.util.JsonUtils; +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.RequestParam; +import org.springframework.web.bind.annotation.ResponseBody; +import org.springframework.web.multipart.MultipartFile; + +/** + * + * created on 2016年9月27日 + * + * 上传图片处理 + * + * @author megagao + * @version 0.0.1 + */ +@Controller +public class PictureController { + + @Autowired + private PictureService pictureService; + + @RequestMapping("/pic/upload") + @ResponseBody + public String pictureUpload(MultipartFile uploadFile) { + @SuppressWarnings("unchecked") + Map result = pictureService.uploadPicture(uploadFile); + //为了保证功能的兼容性,需要把Result转换成json格式的字符串。 + String json = JsonUtils.objectToJson(result); + return json; + } + + @RequestMapping("/pic/delete") + @ResponseBody + public String pictureDelete(@RequestParam String picName) { + + pictureService.deleteFile(picName); + Map result = new HashMap(); + result.put("data", "success"); + String json = JsonUtils.objectToJson(result); + return json; + + } +} -- GitLab