From 259f95deb2ea38287d488d12060d7600c36cd92a Mon Sep 17 00:00:00 2001 From: chenhuan <czj123456> Date: 星期二, 21 五月 2024 17:00:47 +0800 Subject: [PATCH] Merge branch 'master' of http://117.78.1.188:8089/r/dkyChenJiang --- javaweb-plus/javaweb-cms/src/main/java/com/javaweb/geo/controller/ProjectPersonController.java | 43 +++++++++++++++++++++++++++++++++++++------ 1 files changed, 37 insertions(+), 6 deletions(-) diff --git a/javaweb-plus/javaweb-cms/src/main/java/com/javaweb/geo/controller/ProjectPersonController.java b/javaweb-plus/javaweb-cms/src/main/java/com/javaweb/geo/controller/ProjectPersonController.java index 143cb28..58e2edf 100644 --- a/javaweb-plus/javaweb-cms/src/main/java/com/javaweb/geo/controller/ProjectPersonController.java +++ b/javaweb-plus/javaweb-cms/src/main/java/com/javaweb/geo/controller/ProjectPersonController.java @@ -2,15 +2,15 @@ import java.util.List; +import com.javaweb.common.config.Global; +import com.javaweb.common.config.ServerConfig; +import com.javaweb.common.utils.IdGenerate; +import com.javaweb.common.utils.file.FileUploadUtils; import org.apache.shiro.authz.annotation.RequiresPermissions; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; import org.springframework.ui.ModelMap; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.ResponseBody; +import org.springframework.web.bind.annotation.*; import com.javaweb.common.annotation.Log; import com.javaweb.common.enums.BusinessType; import com.javaweb.geo.domain.ProjectPerson; @@ -19,6 +19,9 @@ import com.javaweb.common.core.domain.AjaxResult; import com.javaweb.common.utils.poi.ExcelUtil; import com.javaweb.common.core.page.TableDataInfo; +import org.springframework.web.multipart.MultipartFile; + +import javax.servlet.http.HttpServletRequest; /** * 椤圭洰浜哄憳Controller @@ -34,6 +37,9 @@ @Autowired private IProjectPersonService projectPersonService; + + @Autowired + private ServerConfig serverConfig; @RequiresPermissions("geo:projectPerson:view") @GetMapping() @@ -72,7 +78,7 @@ */ @GetMapping("/add") public String add(String projectId, ModelMap mmap) { - mmap.put("project_Id", projectId); + mmap.put("projectId", projectId); return prefix + "/add"; } @@ -84,6 +90,7 @@ @PostMapping("/add") @ResponseBody public AjaxResult addSave(ProjectPerson projectPerson) { + return toAjax(projectPersonService.insertProjectPerson(projectPerson)); } @@ -118,4 +125,28 @@ public AjaxResult remove(String ids) { return toAjax(projectPersonService.deleteProjectPersonByIds(ids)); } + + /** + * 涓婁紶鍥剧墖 + */ + @PostMapping("/uploadPersonFile") + @ResponseBody + public AjaxResult uploadPersonFile(MultipartFile file, HttpServletRequest request){ + try + { + // 涓婁紶鏂囦欢璺緞 + String filePath = Global.getUploadPath() +"/personfile"; + // 涓婁紶骞惰繑鍥炴柊鏂囦欢鍚嶇О + String fileName = FileUploadUtils.upload(filePath, file); + String url = serverConfig.getUrl() + fileName; + AjaxResult ajax = AjaxResult.success(); + ajax.put("fileName", fileName); + ajax.put("url", url); + return ajax; + } + catch (Exception e) + { + return AjaxResult.error(e.getMessage()); + } + } } -- Gitblit v1.9.1