| | |
| | | import com.gkhy.common.config.ExpertConfig; |
| | | import com.gkhy.common.constant.Constants; |
| | | import com.gkhy.common.core.domain.AjaxResult; |
| | | import com.gkhy.common.exception.ServiceException; |
| | | import com.gkhy.common.utils.StringUtils; |
| | | import com.gkhy.common.utils.file.FileUploadUtils; |
| | | import com.gkhy.common.utils.file.FileUtils; |
| | |
| | | import org.slf4j.LoggerFactory; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.http.MediaType; |
| | | import org.springframework.web.bind.annotation.GetMapping; |
| | | import org.springframework.web.bind.annotation.PostMapping; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | import org.springframework.web.bind.annotation.*; |
| | | import org.springframework.web.multipart.MultipartFile; |
| | | |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import java.io.File; |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | |
| | |
| | | log.error("下载文件失败", e); |
| | | } |
| | | } |
| | | |
| | | |
| | | @ApiOperation(value = "删除附件") |
| | | @DeleteMapping("/removeFile") |
| | | public void removeFile(@RequestParam(required = true) String path){ |
| | | // 本地资源路径 |
| | | String localPath = ExpertConfig.getProfile(); |
| | | // 数据库资源地址 |
| | | String deletePath = localPath + path; |
| | | File dirFile=new File(deletePath); |
| | | if(!dirFile.exists()){ |
| | | throw new ServiceException("文件不存在"); |
| | | } |
| | | if(!dirFile.isFile()){ |
| | | throw new ServiceException("非文件,不能删除"); |
| | | } |
| | | dirFile.delete(); |
| | | } |
| | | } |