From ed8c7a5effd0d423ce1118b680ecdca6fe732609 Mon Sep 17 00:00:00 2001
From: 13693261870 <252740454@qq.com>
Date: 星期三, 02 七月 2025 16:43:13 +0800
Subject: [PATCH] Merge branch 'master' of http://192.168.11.205:9000/r/P2022036_Service

---
 src/main/java/com/lf/server/controller/data/StyleController.java |   88 +++++++++++++++++++++++++++++++++++++------
 1 files changed, 75 insertions(+), 13 deletions(-)

diff --git a/src/main/java/com/lf/server/controller/data/StyleController.java b/src/main/java/com/lf/server/controller/data/StyleController.java
index d9dfb35..9234cfa 100644
--- a/src/main/java/com/lf/server/controller/data/StyleController.java
+++ b/src/main/java/com/lf/server/controller/data/StyleController.java
@@ -2,11 +2,17 @@
 
 import com.lf.server.annotation.SysLog;
 import com.lf.server.controller.all.BaseController;
+import com.lf.server.entity.all.HttpStatus;
 import com.lf.server.entity.all.ResponseMsg;
+import com.lf.server.entity.ctrl.DownloadReqEntity;
+import com.lf.server.entity.data.DownloadEntity;
 import com.lf.server.entity.data.StyleEntity;
 import com.lf.server.entity.sys.UserEntity;
+import com.lf.server.helper.WebHelper;
 import com.lf.server.service.all.UploadAttachService;
+import com.lf.server.service.data.DownloadService;
 import com.lf.server.service.data.StyleService;
+import com.lf.server.service.sys.DownlogService;
 import com.lf.server.service.sys.TokenService;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiImplicitParam;
@@ -36,9 +42,15 @@
     TokenService tokenService;
 
     @Autowired
+    DownloadService downloadService;
+
+    @Autowired
+    DownlogService downlogService;
+
+    @Autowired
     UploadAttachService uploadAttachService;
 
-    private final static String TAB_NAME = "sys_style";
+    private final static String TAB_NAME = "lf.sys_style";
 
     @SysLog()
     @ApiOperation(value = "鏌ヨ璁板綍鏁�")
@@ -52,7 +64,7 @@
 
             return success(count);
         } catch (Exception ex) {
-            return fail(ex.getMessage(), -1);
+            return fail(ex, -1);
         }
     }
 
@@ -74,7 +86,7 @@
 
             return success(rs);
         } catch (Exception ex) {
-            return fail(ex.getMessage(), null);
+            return fail(ex, null);
         }
 
     }
@@ -102,14 +114,14 @@
 
             return success(count, rs);
         } catch (Exception ex) {
-            return fail(ex.getMessage(), null);
+            return fail(ex, null);
         }
     }
 
     @SysLog()
     @ApiOperation(value = "鎻掑叆涓�鏉�")
     @ApiImplicitParams({
-            @ApiImplicitParam(name = "entity", value = "瀹炰綋绫�", dataType = "com.lf.server.entity.data.StyleEntity", paramType = "body", example = "")
+            @ApiImplicitParam(name = "entity", value = "瀹炰綋绫�", dataType = "StyleEntity", paramType = "body", example = "")
     })
     @PostMapping(value = "/insertStyle", produces = "application/json; charset=UTF-8")
     public ResponseMsg<Integer> insertStyle(@RequestBody StyleEntity entity, HttpServletRequest req) {
@@ -123,14 +135,14 @@
 
             return success(count);
         } catch (Exception ex) {
-            return fail(ex.getMessage(), -1);
+            return fail(ex, -1);
         }
     }
 
     @SysLog()
     @ApiOperation(value = "鎻掑叆澶氭潯")
     @ApiImplicitParams({
-            @ApiImplicitParam(name = "list", value = "瀹炰綋绫婚泦鍚�", dataType = "com.lf.server.entity.data.StyleEntity", paramType = "body", example = "")
+            @ApiImplicitParam(name = "list", value = "瀹炰綋绫婚泦鍚�", dataType = "StyleEntity", paramType = "body", example = "")
     })
     @PostMapping(value = "/insertStyles", produces = "application/json; charset=UTF-8")
     public ResponseMsg<Integer> insertStyles(@RequestBody List<StyleEntity> list, HttpServletRequest req) {
@@ -146,7 +158,7 @@
 
             return success(count);
         } catch (Exception ex) {
-            return fail(ex.getMessage(), -1);
+            return fail(ex, -1);
         }
     }
 
@@ -162,7 +174,7 @@
 
             return success(count);
         } catch (Exception ex) {
-            return fail(ex.getMessage(), -1);
+            return fail(ex, -1);
         }
     }
 
@@ -182,7 +194,7 @@
 
             return success(count);
         } catch (Exception ex) {
-            return fail(ex.getMessage(), -1);
+            return fail(ex, -1);
         }
     }
 
@@ -204,7 +216,7 @@
 
             return success(count);
         } catch (Exception ex) {
-            return fail(ex.getMessage(), -1);
+            return fail(ex, -1);
         }
     }
 
@@ -220,7 +232,7 @@
 
             return success(styleEntity);
         } catch (Exception ex) {
-            return fail(ex.getMessage(), null);
+            return fail(ex, null);
         }
     }
 
@@ -233,7 +245,7 @@
             List<StyleEntity> list = styleService.selectStyleAll();
             return success(list);
         } catch (Exception ex) {
-            return fail(ex.getMessage(), null);
+            return fail(ex, null);
         }
     }
 
@@ -256,4 +268,54 @@
     public void download(String guid, HttpServletResponse res) {
         uploadAttachService.download(guid, res);
     }
+
+    @SysLog()
+    @ApiOperation(value = "涓嬭浇鏂囦欢")
+    @ApiImplicitParams({
+            @ApiImplicitParam(name = "guid", value = "鏂囦欢GUID", dataType = "String", paramType = "query")
+    })
+    @RequestMapping(value = "/downloadFile", method = RequestMethod.GET)
+    public void downloadFile(String guid, HttpServletRequest req, HttpServletResponse res) {
+        try {
+            UserEntity ue = tokenService.getCurrentUser(req);
+            if (ue == null) {
+                WebHelper.writeStr2Page(res, WebHelper.getErrJson(HttpStatus.UNAUTHORIZED, "鐢ㄦ埛鏈櫥褰�"));
+            }
+
+            DownloadEntity de = downloadService.selectByGuid(guid);
+            if (de == null) {
+                WebHelper.writeStr2Page(res, WebHelper.getErrJson(HttpStatus.NOT_FOUND, "鏂囦欢涓嶅瓨鍦�"));
+            }
+
+            downlogService.updateInfos(ue, de, req);
+
+            String filePath = downloadService.getDownloadFilePath(de);
+            WebHelper.download(filePath, de.getName(), res);
+        } catch (Exception ex) {
+            WebHelper.writeStr2Page(res, WebHelper.getErrJson(HttpStatus.UNAUTHORIZED, ex.getMessage()));
+            log.error(ex.getMessage(), ex);
+        }
+    }
+
+    @SysLog()
+    @ApiOperation(value = "璇锋眰涓嬭浇")
+    @ApiImplicitParams({
+            @ApiImplicitParam(name = "guids", value = "闄勪欢Guid鏁扮粍", dataType = "String", paramType = "body", allowMultiple = true, example = "e5b6ae0889b88111f13a4b6e048348db,fa4f299e901a0c46e634f8fcc8185c0c")
+    })
+    @ResponseBody
+    @PostMapping(value = "/downloadReqForGuids")
+    public ResponseMsg<Object> downloadReqForGuids(@RequestBody DownloadReqEntity dre, HttpServletRequest req, HttpServletResponse res) {
+        try {
+            if (null == dre || null == dre.getGuids() || dre.getGuids().isEmpty()) {
+                return fail("Guid鏁扮粍涓虹┖");
+            }
+
+            UserEntity ue = tokenService.getCurrentUser(req);
+            String guid = uploadAttachService.downloadReqForGuids(ue, dre.getGuids());
+
+            return success(guid);
+        } catch (Exception ex) {
+            return fail(ex, null);
+        }
+    }
 }

--
Gitblit v1.9.3