地质所 沉降监测网建设项目
chenhuan
2024-05-21 259f95deb2ea38287d488d12060d7600c36cd92a
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()
@@ -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());
        }
    }
}