From 796b44ea813a1133beae4f3a67f1c0263510c0c7 Mon Sep 17 00:00:00 2001 From: 13693261870 <252740454@qq.com> Date: 星期日, 17 十一月 2024 09:45:07 +0800 Subject: [PATCH] 1 --- src/main/java/com/moon/server/service/all/UploadAttachService.java | 76 ------------------------------------- 1 files changed, 1 insertions(+), 75 deletions(-) diff --git a/src/main/java/com/moon/server/service/all/UploadAttachService.java b/src/main/java/com/moon/server/service/all/UploadAttachService.java index 0780ff3..1c65162 100644 --- a/src/main/java/com/moon/server/service/all/UploadAttachService.java +++ b/src/main/java/com/moon/server/service/all/UploadAttachService.java @@ -28,11 +28,8 @@ import java.lang.reflect.Field; import java.util.*; -/** - * 涓婁紶闄勪欢鏈嶅姟绫� - * @author WWW - */ @Service +@SuppressWarnings("ALL") public class UploadAttachService { @Autowired PathHelper pathHelper; @@ -49,16 +46,10 @@ private final static Log log = LogFactory.getLog(UploadAttachService.class); - /** - * 鑾峰彇琛ㄥ悕 - */ public static String getTabs() { return tabs; } - /** - * 鍒濆鍖栭檮浠惰〃 - */ public static void init(String cfg) { if (StringHelper.isEmpty(cfg)) { return; @@ -81,9 +72,6 @@ tabs = StringHelper.join(keys, ","); } - /** - * 涓婁紶鏂囦欢 - */ public ResponseMsg<String> upload(UserEntity ue, String tab, MultipartFile file, BaseController ctrl) { try { if (file == null && file.isEmpty()) { @@ -93,14 +81,12 @@ return ctrl.fail(String.format("鏂囦欢澶т簬 %d MB", SettingData.MAX_FILE_SIZE / 1024 / 1024), null); } - // 浼犺緭鏂囦欢 String oldName = file.getOriginalFilename(); String filePath = pathHelper.getTempPath() + File.separator + oldName; File newFile = new File(filePath); file.transferTo(newFile); double sizes = FileHelper.sizeToMb(file.getSize()); - // 鑾峰彇MD5 String md5 = FileHelper.getFileMd5(filePath); AttachEntity entity = attachService.selectByGuid(md5); if (entity != null) { @@ -120,9 +106,6 @@ } } - /** - * 鑾峰彇闄勪欢瀹炰綋绫� - */ protected AttachEntity getAttachEntity(UserEntity ue, String tab, String oldName, String md5, double sizes) { AttachEntity entity = new AttachEntity(); entity.setName(oldName); @@ -138,16 +121,10 @@ return entity; } - /** - * 涓嬭浇鏂囦欢 - */ public void download(String guid, HttpServletResponse res) { download(guid, false, res); } - /** - * 涓嬭浇鏂囦欢 - */ public void download(String guid, boolean inline, HttpServletResponse res) { try { if (StringHelper.isEmpty(guid)) { @@ -174,9 +151,6 @@ } } - /** - * 涓婁紶Excel闄勪欢 - */ public List<KeyValueEntity> uploadXlsAnnex(UserEntity ue, List<MetaEntity> ms, List<MetaFileEntity> list, String path) { List<String> files = getAttachFiles(list, path); if (files.size() == 0) { @@ -192,9 +166,6 @@ return rs; } - /** - * 鑾峰彇闄勪欢鏂囦欢 - */ private List<String> getAttachFiles(List<MetaFileEntity> list, String path) { List<String> files = new ArrayList<>(); @@ -213,9 +184,6 @@ return files; } - /** - * 鑾峰彇zip涓殑鏂囦欢 - */ private List<String> getZipFiles(MetaFileEntity mf, String path) { File file = new File(mf.getPath()); if (!file.exists() || file.isDirectory()) { @@ -236,9 +204,6 @@ return files; } - /** - * 鏍规嵁璺緞鑾峰彇鏂囦欢 - */ private void getFilesByPath(List<String> list, String path) { File file = new File(path); if (!file.isDirectory()) { @@ -260,9 +225,6 @@ } } - /** - * 涓婁紶Excel闄勪欢 - */ private int uploadXlsAnnex(UserEntity ue, MetaEntity meta, List<String> files) { List<?> list = queryXlsData(meta); if (null == list || list.size() == 0) { @@ -292,9 +254,6 @@ return rows; } - /** - * 鑾峰彇鍚嶇О - */ public static String[] getNames(String str) { if (StringHelper.isEmpty(str)) { return null; @@ -303,9 +262,6 @@ return str.replace("锛�", ",").replace("锛�", ",").split(","); } - /** - * 鏌ヨExcel鏁版嵁 - */ private List<?> queryXlsData(MetaEntity meta) { String entity = meta.getTab().substring(meta.getTab().indexOf(".") + 1).replace("_", "").toLowerCase(); BasicMapper basicMapper = ClassHelper.getBasicMapper(entity); @@ -327,9 +283,6 @@ return list; } - /** - * 鑾峰彇闄勪欢瀛楁 - */ public static Field getAnnexField(Object obj, String tab) { try { String str = ATTACH_TABS.get(tab); @@ -343,9 +296,6 @@ } } - /** - * 鑾峰彇闄勪欢鍚嶇О - */ public static String getAnnexName(Object obj, Field field) { try { Object val = field.get(obj); @@ -356,9 +306,6 @@ } } - /** - * 鏌ユ壘闄勪欢鏂囦欢 - */ private String findAnnexFile(String name, String folder, List<String> files) { name = File.separator + name.split("\\.")[0].trim().toLowerCase(); for (String file : files) { @@ -375,9 +322,6 @@ return null; } - /** - * 鎻掑叆Excel闄勪欢 - */ private int insertXlsAnnex(UserEntity ue, MetaEntity meta, BaseEntity be, String file) { File f = new File(file); if (!f.exists() || f.isDirectory()) { @@ -405,9 +349,6 @@ return attachService.insert(ae); } - /** - * 鑾峰彇闄勪欢瀹炰綋绫� - */ protected AttachEntity getAttachEntity(UserEntity ue, String tabName, String eventid, String fileName, String md5, double sizes) { AttachEntity entity = new AttachEntity(); entity.setTab(tabName); @@ -424,27 +365,18 @@ return entity; } - /** - * 璇锋眰涓嬭浇 - */ public String downloadReqForGuids(UserEntity ue, List<String> guids) { List<AttachEntity> list = attachService.selectByGuids(guids); return downloadReq(ue, list); } - /** - * 璇锋眰涓嬭浇 - */ public String downloadReqForTabGuids(UserEntity ue, String tab, List<String> guids) { List<AttachEntity> list = attachService.selectByTabGuids(tab, guids); return downloadReq(ue, list); } - /** - * 璇锋眰涓嬭浇 - */ protected String downloadReq(UserEntity ue, List<AttachEntity> list) { if (null == list || list.isEmpty()) { return null; @@ -463,9 +395,6 @@ return rows > 0 ? downloadEntity.getGuid() : null; } - /** - * 娣诲姞Zip鏂囦欢 - */ private void addZipFiles(ZipFile zip, ZipParameters params, List<AttachEntity> list) { int i = 1; String uploadPath = pathHelper.getConfig().getUploadPath(); @@ -489,9 +418,6 @@ } } - /** - * 鑾峰彇涓嬭浇瀹炰綋绫� - */ private DownloadEntity getDownloadEntity(UserEntity ue, String file, String pwd) { DownloadEntity de = new DownloadEntity(); de.setName(FileHelper.getFileName(file)); -- Gitblit v1.9.3