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 | 102 +++++++++++++++++++++++++++++++++++++++++---------- 1 files changed, 82 insertions(+), 20 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 6dc1153..9234cfa 100644 --- a/src/main/java/com/lf/server/controller/data/StyleController.java +++ b/src/main/java/com/lf/server/controller/data/StyleController.java @@ -1,12 +1,18 @@ package com.lf.server.controller.data; -import com.lf.server.aspect.SysLog; +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.service.data.UploaderService; +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; @@ -27,7 +33,7 @@ */ @Api(tags = "鏁版嵁绠$悊\\鏍峰紡绠$悊") @RestController -@RequestMapping("/Style") +@RequestMapping("/style") public class StyleController extends BaseController { @Autowired StyleService styleService; @@ -36,9 +42,15 @@ TokenService tokenService; @Autowired - UploaderService uploaderService; + DownloadService downloadService; - private final static String TAB_NAME = "sys_style"; + @Autowired + DownlogService downlogService; + + @Autowired + UploadAttachService uploadAttachService; + + 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); } } @@ -244,7 +256,7 @@ public ResponseMsg<String> upload(@RequestParam("file") MultipartFile file, HttpServletRequest req) { UserEntity ue = tokenService.getCurrentUser(req); - return uploaderService.upload(ue, TAB_NAME, file, this); + return uploadAttachService.upload(ue, TAB_NAME, file, this); } @SysLog() @@ -253,7 +265,57 @@ @ApiImplicitParam(name = "guid", value = "闄勪欢Guid", dataType = "String", paramType = "body") }) @GetMapping(value = "/download") - public void download(String guid, HttpServletRequest req, HttpServletResponse res) { - uploaderService.download(guid, req, res, this); + 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