From 05b7f36c1fdb1dae4fd2131f63e10f72f85ee42c Mon Sep 17 00:00:00 2001 From: 13693261870 <252740454@qq.com> Date: 星期一, 03 四月 2023 16:49:14 +0800 Subject: [PATCH] 1 --- src/main/java/com/lf/server/controller/data/MetaController.java | 120 ++++++++++++++++++++++++++++++++++++------------------------ 1 files changed, 72 insertions(+), 48 deletions(-) diff --git a/src/main/java/com/lf/server/controller/data/MetaController.java b/src/main/java/com/lf/server/controller/data/MetaController.java index 79d1831..813d753 100644 --- a/src/main/java/com/lf/server/controller/data/MetaController.java +++ b/src/main/java/com/lf/server/controller/data/MetaController.java @@ -38,10 +38,10 @@ import java.util.List; /** - * 婧愭暟鎹� + * 鍏冩暟鎹� * @author WWW */ -@Api(tags = "鏁版嵁绠$悊\\婧愭暟鎹鐞�") +@Api(tags = "鏁版嵁绠$悊\\淇℃伅绠$悊") @RestController @RequestMapping("/meta") public class MetaController extends BaseController { @@ -89,7 +89,38 @@ return success(count, rs); } catch (Exception ex) { - return fail(ex.getMessage(), null); + return fail(ex, null); + } + } + + @SysLog() + @ApiOperation(value = "鏍规嵁鐖禝D鍒嗛〉鏌ヨ骞惰繑鍥炶褰曟暟") + @ApiImplicitParams({ + @ApiImplicitParam(name = "metaid", value = "鐖禝D", dataType = "String", paramType = "query", example = "0"), + @ApiImplicitParam(name = "name", value = "鍚嶇О", dataType = "String", paramType = "query", example = ""), + @ApiImplicitParam(name = "pageSize", value = "姣忛〉鏉℃暟", dataType = "Integer", paramType = "query", example = "10"), + @ApiImplicitParam(name = "pageIndex", value = "鍒嗛〉鏁帮紙浠�1寮�濮嬶級", dataType = "Integer", paramType = "query", example = "1") + }) + @GetMapping(value = "/selectPageAndCountByPid") + public ResponseMsg<List<MetaEntity>> selectPageAndCountByPid(Integer metaid, String name, Integer pageSize, Integer pageIndex) { + try { + if (pageSize < 1 || pageIndex < 1) { + return fail("姣忛〉椤垫暟鎴栧垎椤垫暟灏忎簬1", null); + } + if (null == metaid || metaid < 1) { + return fail("鐖禝D涓嶈兘涓虹┖涓斿ぇ浜�1", null); + } + + int count = metaService.selectCountByPid(metaid, name); + if (count == 0) { + return success(0, null); + } + + List<MetaEntity> rs = metaService.selectPageByPid(metaid, name, pageSize, pageSize * (pageIndex - 1)); + + return success(count, rs); + } catch (Exception ex) { + return fail(ex, null); } } @@ -112,7 +143,7 @@ return success(list); } catch (Exception ex) { - return fail(ex.getMessage(), null); + return fail(ex, null); } } @@ -128,14 +159,14 @@ return success(entity); } catch (Exception ex) { - return fail(ex.getMessage(), null); + return fail(ex, null); } } @SysLog() @ApiOperation(value = "鏌ヨ琛ㄤ腑鏁版嵁") @ApiImplicitParams({ - @ApiImplicitParam(name = "id", value = "婧愭暟鎹甀D", dataType = "Integer", paramType = "query", example = "115"), + @ApiImplicitParam(name = "id", value = "鍏冩暟鎹甀D", dataType = "Integer", paramType = "query", example = "115"), @ApiImplicitParam(name = "pageIndex", value = "鍒嗛〉鏁帮紙浠�1寮�濮嬶級", dataType = "Integer", paramType = "query", example = "1"), @ApiImplicitParam(name = "pageSize", value = "姣忛〉鏉℃暟", dataType = "Integer", paramType = "query", example = "10") }) @@ -144,12 +175,12 @@ // noinspection AlibabaRemoveCommentedCode try { if (null == id || id < 0) { - return fail("婧愭暟鎹甀D涓嶈兘涓虹┖鎴栧皬浜�0", null); + return fail("鍏冩暟鎹甀D涓嶈兘涓虹┖鎴栧皬浜�0", null); } MetaEntity meta = metaService.selectById(id); if (null == meta || null == meta.getTab() || !meta.getTab().contains(StaticData.POINT)) { - return fail("鎵句笉鍒版簮鏁版嵁淇℃伅", null); + return fail("鎵句笉鍒板厓鏁版嵁淇℃伅", null); } String entity = meta.getTab().substring(meta.getTab().indexOf(".") + 1).replace("_", "").toLowerCase(); @@ -162,12 +193,12 @@ wrapper.eq("parentid", meta.getEventid()); Page<Object> page = new Page<>(pageIndex, pageSize); - page.addOrder(OrderItem.asc("gid")); + page.addOrder(OrderItem.desc("gid")); IPage<Object> paged = baseMapper.selectPage(page, wrapper); return success(paged.getTotal(), paged.getRecords()); } catch (Exception ex) { - return fail(ex.getMessage(), null); + return fail(ex, null); } } @@ -188,7 +219,7 @@ return success(list); } catch (Exception ex) { - return fail(ex.getMessage(), null); + return fail(ex, null); } } @@ -210,7 +241,7 @@ return success(count); } catch (Exception ex) { - return fail(ex.getMessage(), -1); + return fail(ex, -1); } } @@ -233,30 +264,14 @@ return success(count); } catch (Exception ex) { - return fail(ex.getMessage(), -1); - } - } - - @SysLog() - @ApiOperation(value = "鍒犻櫎涓�鏉�") - @ApiImplicitParams({ - @ApiImplicitParam(name = "id", value = "ID", dataType = "Integer", paramType = "query", example = "1") - }) - @GetMapping(value = "/delete") - public ResponseMsg<Integer> delete(int id) { - try { - int count = metaService.delete(id); - - return success(count); - } catch (Exception ex) { - return fail(ex.getMessage(), -1); + return fail(ex, -1); } } @SysLog() @ApiOperation(value = "鍒犻櫎澶氭潯") @ApiImplicitParams({ - @ApiImplicitParam(name = "ids", value = "ID鏁扮粍", dataType = "Integer", paramType = "query", example = "1,2") + @ApiImplicitParam(name = "ids", value = "ID鏁扮粍", dataType = "Integer", paramType = "query", allowMultiple = true, example = "1") }) @GetMapping(value = "/deletes") public ResponseMsg<Integer> deletes(@RequestParam List<Integer> ids) { @@ -269,7 +284,7 @@ return success(count); } catch (Exception ex) { - return fail(ex.getMessage(), -1); + return fail(ex, -1); } } @@ -291,7 +306,7 @@ return success(count); } catch (Exception ex) { - return fail(ex.getMessage(), -1); + return fail(ex, -1); } } @@ -315,7 +330,7 @@ return success(count); } catch (Exception ex) { - return fail(ex.getMessage(), -1); + return fail(ex, -1); } } @@ -338,52 +353,51 @@ return fail("鐢ㄦ埛鏈櫥褰�", null); } - int count = downloadService.selectCountForUser(ue.getCreateUser(), 3, name); + int count = downloadService.selectCountForUser(ue.getId(), 3, name); if (count == 0) { return success(0, null); } - List<DownloadEntity> rs = downloadService.selectByPageForUser(ue.getCreateUser(), 3, name, pageSize, pageSize * (pageIndex - 1)); + List<DownloadEntity> rs = downloadService.selectByPageForUser(ue.getId(), 3, name, pageSize, pageSize * (pageIndex - 1)); return success(count, rs); } catch (Exception ex) { - return fail(ex.getMessage(), null); + return fail(ex, null); } } @SysLog() @ApiOperation(value = "璇锋眰涓嬭浇") @ApiImplicitParams({ - @ApiImplicitParam(name = "pwd", value = "瀵嗙爜", dataType = "String", paramType = "body", example = ""), - @ApiImplicitParam(name = "ids", value = "ID鏁扮粍", dataType = "Integer", paramType = "body", example = "1,2") + @ApiImplicitParam(name = "dr", value = "璇锋眰涓嬭浇瀹炰綋绫�", dataType = "DownloadReqEntity", paramType = "body") }) @ResponseBody @PostMapping(value = "/downloadReq") - public ResponseMsg<Object> downloadReq(@RequestBody DownloadReqEntity reqEntity, HttpServletRequest req, HttpServletResponse res) { + public ResponseMsg<Object> downloadReq(@RequestBody DownloadReqEntity dr, HttpServletRequest req, HttpServletResponse res) { try { - if (null == reqEntity || StringHelper.isEmpty(reqEntity.getPwd())) { + if (null == dr || StringHelper.isEmpty(dr.getPwd())) { return fail("瀵嗙爜涓嶈兘涓虹┖"); } - if (null == reqEntity.getIds() || reqEntity.getIds().isEmpty()) { + if (null == dr.getIds() || dr.getIds().isEmpty()) { return fail("璇烽�夋嫨瑕佷笅杞界殑鏂囦欢"); } - if (!DownloadService.decryptPwd(reqEntity)) { + if (!DownloadService.decryptPwd(dr)) { return fail("瀵嗙爜瑙e瘑澶辫触", null); } - if (StringHelper.isPwdInvalid(reqEntity.getPwd())) { + if (StringHelper.isPwdInvalid(dr.getPwd())) { return fail("瀵嗙爜涓嶇鍚堣姹�"); } - List<MetaEntity> list = metaService.selectMetaFiles(reqEntity.getIds()); + List<MetaEntity> list = metaService.selectMetaFiles(dr.getIds()); if (null == list || list.isEmpty()) { - return fail("娌℃湁鎵惧埌婧愭暟鎹�"); + return fail("娌℃湁鎵惧埌鍏冩暟鎹�"); } UserEntity ue = tokenService.getCurrentUser(req); - String guid = downloadService.zipFiles(ue, list, reqEntity.getPwd()); + String guid = downloadService.zipFiles(ue, list, dr.getPwd()); return success(guid); } catch (Exception ex) { - return fail(ex.getMessage(), null); + return fail(ex, null); } } @@ -421,7 +435,7 @@ return success(file.exists()); } catch (Exception ex) { - return fail(ex.getMessage(), false); + return fail(ex, false); } } @@ -465,4 +479,14 @@ WebHelper.writeInfo(HttpStatus.ERROR, ex.getMessage(), res); } } + + @SysLog() + @ApiOperation(value = "鏌ョ湅鏂囦欢") + @ApiImplicitParams({ + @ApiImplicitParam(name = "guid", value = "闄勪欢Guid", dataType = "String", paramType = "body") + }) + @GetMapping(value = "/downloadForView") + public void downloadForView(String guid, HttpServletResponse res) { + metaService.downloadForView(guid, true, res); + } } -- Gitblit v1.9.3