pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/daoFi/WebFileMapper.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/voFi/VoPhoto.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
pipIrr-platform/pipIrr-web/pipIrr-web-file/src/main/java/com/dy/pipIrrWebFile/get/GetFileCtrl.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
pipIrr-platform/pipIrr-web/pipIrr-web-file/src/main/java/com/dy/pipIrrWebFile/get/GetFileSv.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 |
pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/daoFi/WebFileMapper.java
@@ -18,4 +18,5 @@ int updateByPrimaryKey(WebFile record); } pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/voFi/VoPhoto.java
New file @@ -0,0 +1,32 @@ package com.dy.pipIrrGlobal.voFi; import com.fasterxml.jackson.annotation.JsonPropertyOrder; import lombok.Data; /** * @author ZhuBaoMin * @date 2024-10-22 15:41 * @LastEditTime 2024-10-22 15:41 * @Description web图片视图对象 */ @Data @JsonPropertyOrder({ "downloadPath", "webPath", "webPathZip"}) public class VoPhoto { private static final long serialVersionUID = 202410221542001L; /** * 文件下载路径 */ private String downloadPath; /** * web路径 */ private String webPath; /** * web路径(缩略图) */ private String webPathZip; } pipIrr-platform/pipIrr-web/pipIrr-web-file/src/main/java/com/dy/pipIrrWebFile/get/GetFileCtrl.java
New file @@ -0,0 +1,72 @@ package com.dy.pipIrrWebFile.get; import com.dy.common.aop.SsoAop; import com.dy.common.webUtil.BaseResponse; import com.dy.common.webUtil.BaseResponseUtils; import com.dy.pipIrrGlobal.dyFile.FileOperate; import com.dy.pipIrrGlobal.dyFile.FileRestVo; import com.dy.pipIrrGlobal.pojoFi.WebFile; import com.dy.pipIrrGlobal.voFi.VoPhoto; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController; /** * @author ZhuBaoMin * @date 2024-10-22 15:26 * @LastEditTime 2024-10-22 15:26 * @Description 获取文件控制类 */ @Slf4j @RestController @RequestMapping(path = "get") @RequiredArgsConstructor public class GetFileCtrl { private final GetFileSv getFileSv; @Autowired private FileOperate fileOp ; @Value("${dy.webFile.fmUrl}") private String fmUrl ; /** * 根据图片ID获取图片路径 * @param photoId * @return */ @GetMapping(path = "/getPhotoFile") @SsoAop() public BaseResponse<VoPhoto> getPhotoFile(@RequestParam("photoId") Long photoId) { try { // 根据图片ID获取图片文件对象,从图片文件对象中获取文件路径、扩展名、缩略图文件路径 WebFile webFile = getFileSv.getWebFileById(photoId); if(webFile == null) { return BaseResponseUtils.buildErrorMsg("图标ID错误"); } String filePath = webFile.getFilePath(); String extName = webFile.getExtName(); String filePathZip = filePath.substring(0, filePath.indexOf('.')) + "_." + extName; FileRestVo frVo = fileOp.parseHashcode(fmUrl, webFile.hash); VoPhoto photo = new VoPhoto(); photo.setDownloadPath(frVo.fileWebDownloadPath + photoId); photo.setWebPath(frVo.fileWebUrl + filePath); photo.setWebPathZip(frVo.fileWebUrl + filePathZip); return BaseResponseUtils.buildSuccess(photo); } catch (Exception e) { log.error("获取图片文件异常", e); return BaseResponseUtils.buildException(e.getMessage()); } } } pipIrr-platform/pipIrr-web/pipIrr-web-file/src/main/java/com/dy/pipIrrWebFile/get/GetFileSv.java
New file @@ -0,0 +1,30 @@ package com.dy.pipIrrWebFile.get; import com.dy.pipIrrGlobal.daoFi.WebFileMapper; import com.dy.pipIrrGlobal.pojoFi.WebFile; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; /** * @author ZhuBaoMin * @date 2024-10-22 15:27 * @LastEditTime 2024-10-22 15:27 * @Description */ @Slf4j @Service public class GetFileSv { @Autowired private WebFileMapper webFileMapper; /** * 根据ID获取文件对象 * @param fileId * @return */ public WebFile getWebFileById(Long fileId) { return webFileMapper.selectByPrimaryKey(fileId); } }