|  |  |  | 
|---|
|  |  |  | package com.dy.pipIrrGlobal.webCtrls; | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import com.dy.common.aop.SsoAop; | 
|---|
|  |  |  | import com.dy.common.webUtil.BaseResponse; | 
|---|
|  |  |  | import com.dy.common.webUtil.BaseResponseUtils; | 
|---|
|  |  |  | import com.dy.pipIrrGlobal.dyFile.FileConstant; | 
|---|
|  |  |  | 
|---|
|  |  |  | import org.springframework.web.multipart.MultipartFile; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import java.util.Date; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * web文件上传 | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | 
|---|
|  |  |  | @Value("${dy.webFile.supportedFileTypes}") | 
|---|
|  |  |  | private String supportedFileTypes ; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //视频的缩略图的扩展名 | 
|---|
|  |  |  | private static final String VideoZipPicFileType = "jpg"; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 上传照片图片文件 (当前只对png jpg格式图片支持缩略图) | 
|---|
|  |  |  | * @param file web端上传文件的post对象 | 
|---|
|  |  |  | * @return 返回结果 | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | @PostMapping("/upPhoto") | 
|---|
|  |  |  | @SsoAop() | 
|---|
|  |  |  | //参考:https://blog.zhengru.top/posts/33486.html#%E5%8D%95%E6%96%87%E4%BB%B6%E4%B8%8A%E4%BC%A0 | 
|---|
|  |  |  | public BaseResponse<?> upPhoto(MultipartFile file) { | 
|---|
|  |  |  | try { | 
|---|
|  |  |  | 
|---|
|  |  |  | frVo.fileNameHash, | 
|---|
|  |  |  | fileNameGrp[0], | 
|---|
|  |  |  | fileNameGrp[1], | 
|---|
|  |  |  | frVo.getFileWebPath(), | 
|---|
|  |  |  | (frVo.getFileWebUrl() + frVo.getFileWebPath()), | 
|---|
|  |  |  | fileOp.getImgFileZipPath(frVo.getFileWebUrl() + frVo.getFileWebPath()), | 
|---|
|  |  |  | fileOp.getFileZipPath(frVo.getFileWebUrl() + frVo.getFileWebPath()), | 
|---|
|  |  |  | frVo.fileWebDownloadPath + id) ; | 
|---|
|  |  |  | return  BaseResponseUtils.buildSuccess(fvo) ; | 
|---|
|  |  |  | }else { | 
|---|
|  |  |  | 
|---|
|  |  |  | * @return 返回结果 | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | @PostMapping("/upPhone") | 
|---|
|  |  |  | @SsoAop() | 
|---|
|  |  |  | public BaseResponse<?> upPhone(MultipartFile file) { | 
|---|
|  |  |  | try { | 
|---|
|  |  |  | if (file != null) { | 
|---|
|  |  |  | 
|---|
|  |  |  | frVo.fileNameHash, | 
|---|
|  |  |  | fileNameGrp[0], | 
|---|
|  |  |  | fileNameGrp[1], | 
|---|
|  |  |  | frVo.getFileWebPath(), | 
|---|
|  |  |  | frVo.getFileWebUrl() + frVo.getFileWebPath(), | 
|---|
|  |  |  | null, | 
|---|
|  |  |  | frVo.fileWebDownloadPath + id) ; | 
|---|
|  |  |  | 
|---|
|  |  |  | * @return 返回结果 | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | @PostMapping("/upVideo") | 
|---|
|  |  |  | @SsoAop() | 
|---|
|  |  |  | public BaseResponse<?> upVideo(MultipartFile file) { | 
|---|
|  |  |  | try { | 
|---|
|  |  |  | if (file != null) { | 
|---|
|  |  |  | 
|---|
|  |  |  | frVo.fileNameHash, | 
|---|
|  |  |  | fileNameGrp[0], | 
|---|
|  |  |  | fileNameGrp[1], | 
|---|
|  |  |  | frVo.getFileWebPath(), | 
|---|
|  |  |  | frVo.getFileWebUrl() + frVo.getFileWebPath(), | 
|---|
|  |  |  | null, | 
|---|
|  |  |  | fileOp.getFileZipPath(frVo.getFileWebUrl() + frVo.getFileWebPath(), VideoZipPicFileType), | 
|---|
|  |  |  | frVo.fileWebDownloadPath + id) ; | 
|---|
|  |  |  | return  BaseResponseUtils.buildSuccess(fvo) ; | 
|---|
|  |  |  | }else { | 
|---|
|  |  |  | 
|---|
|  |  |  | * @return 返回结果 | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | @PostMapping("/upDocument") | 
|---|
|  |  |  | @SsoAop() | 
|---|
|  |  |  | public BaseResponse<?> upDocument(MultipartFile file) { | 
|---|
|  |  |  | try { | 
|---|
|  |  |  | if (file != null) { | 
|---|
|  |  |  | 
|---|
|  |  |  | Long id = this.saveFileInfo(fileNameGrp[0], fileNameGrp[1], fileMainName, frVo.fileNameHash, frVo.fileWebPath); | 
|---|
|  |  |  | FileVo fvo = new FileVo(id, | 
|---|
|  |  |  | frVo.fileNameHash, | 
|---|
|  |  |  | fileNameGrp[0], fileNameGrp[1], | 
|---|
|  |  |  | fileNameGrp[0], | 
|---|
|  |  |  | fileNameGrp[1], | 
|---|
|  |  |  | frVo.getFileWebPath(), | 
|---|
|  |  |  | frVo.getFileWebUrl() + frVo.getFileWebPath(), | 
|---|
|  |  |  | null, | 
|---|
|  |  |  | frVo.fileWebDownloadPath + id) ; | 
|---|