| | |
| | | import com.java110.dto.file.FileDto; |
| | | import com.java110.intf.common.IFileInnerServiceSMO; |
| | | import com.java110.utils.cache.MappingCache; |
| | | import com.java110.utils.constant.MappingConstant; |
| | | import com.java110.utils.util.COSUtil; |
| | | import com.java110.utils.util.OSSUtil; |
| | | import com.java110.utils.util.StringUtil; |
| | |
| | | |
| | | @RestController |
| | | public class FileInnerServiceSMOImpl extends BaseServiceSMO implements IFileInnerServiceSMO { |
| | | |
| | | private static final String ROOT_PATH = "hc/"; |
| | | |
| | | @Autowired |
| | | private IFileServiceDao fileServiceDaoImpl; |
| | |
| | | |
| | | @Autowired |
| | | private OssUploadTemplate ossUploadTemplate; |
| | | |
| | | @Autowired |
| | | private CosUploadTemplate cosUploadTemplate; |
| | | |
| | |
| | | |
| | | //int saveFileFlag = fileServiceDaoImpl.saveFile(BeanConvertUtil.beanCovertMap(fileDto)); |
| | | String fileName = ""; |
| | | String ossSwitch = MappingCache.getValue(OSSUtil.DOMAIN, OSSUtil.OSS_SWITCH); |
| | | String ossSwitch = MappingCache.getValue(MappingConstant.FILE_DOMAIN, OSSUtil.OSS_SWITCH); |
| | | |
| | | if ( OSSUtil.OSS_SWITCH_OSS.equals(ossSwitch)) { |
| | | if (OSSUtil.OSS_SWITCH_OSS.equals(ossSwitch)) { |
| | | fileName = ossUploadTemplate.upload(fileDto.getContext(), java110Properties.getFtpServer(), |
| | | java110Properties.getFtpPort(), java110Properties.getFtpUserName(), |
| | | java110Properties.getFtpUserPassword(), java110Properties.getFtpPath()); |
| | | java110Properties.getFtpUserPassword(), ROOT_PATH); |
| | | } else if (COSUtil.COS_SWITCH_COS.equals(ossSwitch)) { |
| | | fileName = cosUploadTemplate.upload(fileDto.getContext(), java110Properties.getFtpServer(), |
| | | java110Properties.getFtpPort(), java110Properties.getFtpUserName(), |
| | | java110Properties.getFtpUserPassword(), java110Properties.getFtpPath()); |
| | | java110Properties.getFtpUserPassword(), ROOT_PATH); |
| | | } else { |
| | | String ftpServer = MappingCache.getValue(FtpUploadTemplate.FTP_DOMAIN, FtpUploadTemplate.FTP_SERVER); |
| | | int ftpPort = Integer.parseInt(MappingCache.getValue(FtpUploadTemplate.FTP_DOMAIN, FtpUploadTemplate.FTP_PORT)); |
| | | String ftpUserName = MappingCache.getValue(FtpUploadTemplate.FTP_DOMAIN, FtpUploadTemplate.FTP_USERNAME); |
| | | String ftpUserPassword = MappingCache.getValue(FtpUploadTemplate.FTP_DOMAIN, FtpUploadTemplate.FTP_USERPASSWORD); |
| | | String ftpPath = MappingCache.getValue(FtpUploadTemplate.FTP_DOMAIN, FtpUploadTemplate.FTP_PATH); |
| | | //String ftpPath = "hc/"; |
| | | |
| | | fileName = ftpUploadTemplate.upload(fileDto.getContext(), ftpServer, |
| | | ftpPort, ftpUserName, |
| | | ftpUserPassword, ftpPath); |
| | | ftpPort, ftpUserName, |
| | | ftpUserPassword, ROOT_PATH); |
| | | } |
| | | return fileName; |
| | | } |
| | |
| | | //return BeanConvertUtil.covertBeanList(fileServiceDaoImpl.getFiles(BeanConvertUtil.beanCovertMap(fileDto)), FileDto.class); |
| | | List<FileDto> fileDtos = new ArrayList<>(); |
| | | String fileName = fileDto.getFileSaveName(); |
| | | String ftpPath = java110Properties.getFtpPath(); |
| | | String ftpPath = "hc/"; |
| | | String suffix = fileName.substring(fileName.lastIndexOf(".") + 1); |
| | | if (fileName.contains("/")) { |
| | | ftpPath += fileName.substring(0, fileName.lastIndexOf("/") + 1); |
| | | fileName = fileName.substring(fileName.lastIndexOf("/") + 1, fileName.length()); |
| | | } |
| | | String context = ""; |
| | | String ossSwitch = MappingCache.getValue(OSSUtil.DOMAIN, OSSUtil.OSS_SWITCH); |
| | | String ossSwitch = MappingCache.getValue(MappingConstant.FILE_DOMAIN, OSSUtil.OSS_SWITCH); |
| | | if (OSSUtil.OSS_SWITCH_OSS.equals(ossSwitch)) { |
| | | context = ossUploadTemplate.download(ftpPath, fileName, java110Properties.getFtpServer(), |
| | | java110Properties.getFtpPort(), java110Properties.getFtpUserName(), |
| | | java110Properties.getFtpUserPassword()); |
| | | }else if (COSUtil.COS_SWITCH_COS.equals(ossSwitch)) { |
| | | } else if (COSUtil.COS_SWITCH_COS.equals(ossSwitch)) { |
| | | context = cosUploadTemplate.download(ftpPath, fileName, java110Properties.getFtpServer(), |
| | | java110Properties.getFtpPort(), java110Properties.getFtpUserName(), |
| | | java110Properties.getFtpUserPassword()); |