From 38ef4366ad819bb3a7fc604e6c51a95193d59b00 Mon Sep 17 00:00:00 2001 From: 13693261870 <252740454@qq.com> Date: 星期三, 21 十二月 2022 11:53:03 +0800 Subject: [PATCH] 1 --- src/main/java/com/lf/server/controller/data/MetaController.java | 133 +++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 131 insertions(+), 2 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 663138a..d4bd77e 100644 --- a/src/main/java/com/lf/server/controller/data/MetaController.java +++ b/src/main/java/com/lf/server/controller/data/MetaController.java @@ -1,17 +1,26 @@ package com.lf.server.controller.data; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.core.metadata.OrderItem; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; 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.all.StaticData; import com.lf.server.entity.ctrl.DownloadReqEntity; +import com.lf.server.entity.data.DictEntity; import com.lf.server.entity.data.DownloadEntity; import com.lf.server.entity.data.MetaEntity; import com.lf.server.entity.data.MetaFileEntity; import com.lf.server.entity.sys.UserEntity; +import com.lf.server.helper.ClassHelper; import com.lf.server.helper.Md5Helper; import com.lf.server.helper.StringHelper; import com.lf.server.helper.WebHelper; +import com.lf.server.mapper.all.BasicMapper; +import com.lf.server.service.all.BaseQueryService; import com.lf.server.service.data.DownloadService; import com.lf.server.service.data.MetaService; import com.lf.server.service.sys.TokenService; @@ -21,6 +30,9 @@ import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; +import java.io.File; +import java.net.URLDecoder; +import java.nio.charset.StandardCharsets; import java.util.List; /** @@ -36,6 +48,9 @@ @Autowired TokenService tokenService; + + @Autowired + BaseQueryService baseQueryService; @Autowired DownloadService downloadService; @@ -92,6 +107,70 @@ MetaEntity entity = metaService.selectById(id); return success(entity); + } catch (Exception ex) { + return fail(ex.getMessage(), null); + } + } + + @SysLog() + @ApiOperation(value = "鏌ヨ琛ㄤ腑鏁版嵁") + @ApiImplicitParams({ + @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") + }) + @GetMapping(value = "/selectDbData") + public ResponseMsg<Object> selectDbData(Integer id, Integer pageIndex, Integer pageSize) { + // noinspection AlibabaRemoveCommentedCode + try { + if (null == id || id < 0) { + return fail("鍏冩暟鎹甀D涓嶈兘涓虹┖鎴栧皬浜�0", null); + } + + MetaEntity meta = metaService.selectById(id); + if (null == meta || null == meta.getTab() || !meta.getTab().contains(StaticData.POINT)) { + return fail("鎵句笉鍒板厓鏁版嵁淇℃伅", null); + } + + String entity = meta.getTab().substring(meta.getTab().indexOf(".") + 1).replace("_", "").toLowerCase(); + BasicMapper baseMapper = ClassHelper.getBasicMapper(entity); + if (null == baseMapper) { + return null; + } + + QueryWrapper wrapper = new QueryWrapper(); + //wrapper.eq("dirid", meta.getDirid()); + //wrapper.eq("depid", meta.getDepid()); + //wrapper.eq("verid", meta.getVerid()); + wrapper.eq("createuser", meta.getCreateUser()); + wrapper.eq("createtime", meta.getCreateTime()); + + Page<Object> page = new Page<>(pageIndex, pageSize); + page.addOrder(OrderItem.asc("gid")); + IPage<Object> paged = baseMapper.selectPage(page, wrapper); + + return success(paged.getTotal(), paged.getRecords()); + } catch (Exception ex) { + return fail(ex.getMessage(), null); + } + } + + @SysLog() + @ApiOperation(value = "鏌ヨ瀛楁淇℃伅") + @ApiImplicitParams({ + @ApiImplicitParam(name = "ns", value = "鍚嶇О绌洪棿", dataType = "String", paramType = "query", example = "bd"), + @ApiImplicitParam(name = "tab", value = "琛ㄥ悕", dataType = "String", paramType = "query", example = "dlg25wAanp") + }) + @GetMapping(value = "/selectTabFields") + public ResponseMsg<List<DictEntity>> selectTabFields(String ns, String tab) { + try { + if (StringHelper.isEmpty(ns) || StringHelper.isEmpty(tab)) { + return fail("鍚嶇О绌洪棿鍜岃〃鍚嶄笉鑳戒负绌�", null); + } + + List<DictEntity> list = baseQueryService.selectFields(ns, tab); + + return success(list); } catch (Exception ex) { return fail(ex.getMessage(), null); } @@ -274,15 +353,62 @@ if (null == reqEntity.getIds() || reqEntity.getIds().isEmpty()) { return fail("璇烽�夋嫨瑕佷笅杞界殑鏂囦欢"); } - if (!downloadService.validatePwd(reqEntity)) { + if (!downloadService.decryptPwd(reqEntity)) { + return fail("瀵嗙爜瑙e瘑澶辫触", null); + } + if (!StringHelper.checkPwdValid(reqEntity.getPwd())) { return fail("瀵嗙爜涓嶇鍚堣姹�"); } List<MetaFileEntity> list = metaService.selectMetaFiles(reqEntity.getIds()); + if (null == list || list.isEmpty()) { + return fail("娌℃湁鎵惧埌鍏冩暟鎹�"); + } - return success(true); + UserEntity ue = tokenService.getCurrentUser(req); + String guid = downloadService.zipFiles(ue, list, reqEntity.getPwd()); + + return success(guid); } catch (Exception ex) { return fail(ex.getMessage(), null); + } + } + + @SysLog() + @ApiOperation(value = "鏌ヨ涓嬭浇鏂囦欢") + @ApiImplicitParams({ + @ApiImplicitParam(name = "guid", value = "鏂囦欢GUID", dataType = "String", paramType = "query"), + @ApiImplicitParam(name = "pwd", value = "瀵嗙爜", dataType = "String", paramType = "query") + }) + @GetMapping(value = "/selectDownloadFile") + public ResponseMsg<Boolean> selectDownloadFile(String guid, String pwd) { + try { + if (StringHelper.isEmpty(guid) || StringHelper.isEmpty(pwd)) { + return fail("鏂囦欢ID鍜屽瘑鐮佷笉鑳戒负绌�", null); + } + if (!pwd.endsWith(StaticData.EQ)) { + pwd = URLDecoder.decode(pwd, StandardCharsets.UTF_8.name()); + } + + String password = downloadService.decryptPwd(pwd); + if (null == password) { + return fail("瀵嗙爜瑙e瘑澶辫触", null); + } + + DownloadEntity de = downloadService.selectByGuid(guid); + if (null == de) { + return fail("鏂囦欢涓嶅瓨鍦�", null); + } + if (!StringHelper.isNull(de.getPwd()) && !Md5Helper.validatePassword(password, de.getPwd())) { + return fail("瀵嗙爜涓嶆纭�", null); + } + + String filePath = downloadService.getDownloadFilePath(de); + File file = new File(filePath); + + return success(file.exists()); + } catch (Exception ex) { + return fail(ex.getMessage(), false); } } @@ -299,6 +425,9 @@ if (StringHelper.isEmpty(guid) || StringHelper.isEmpty(pwd)) { WebHelper.writeInfo(HttpStatus.BAD_REQUEST, "鏂囦欢ID鍜屽瘑鐮佷笉鑳戒负绌�", res); } + if (!pwd.endsWith(StaticData.EQ)) { + pwd = URLDecoder.decode(pwd, StandardCharsets.UTF_8.name()); + } String password = downloadService.decryptPwd(pwd); if (null == password) { -- Gitblit v1.9.3