管道基础大数据平台系统开发-【后端】-Server
1
13693261870
2022-11-27 e0207d2328ccf6da00690ee1e263f4a9495e6c11
1
已修改3个文件
44 ■■■■■ 文件已修改
data/db_fn.sql 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/lf/server/controller/data/MetaController.java 25 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/lf/server/service/data/DownloadService.java 15 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
data/db_fn.sql
@@ -358,8 +358,8 @@
select * from bd.dlg_agnp where gid<13;     -- delete from bd.dlg_agnp where gid>12;     alter sequence bd.dlg_agnp_gid_seq restart with 20;
select gb,name,classes,pinyin,pac,bsm,geom,eventid,dirid,depid,verid,createtime,createuser,updateuser,updatetime from bd.dlg_agnp
select * from lf.sys_user
select * from lf.sys_download where guid='5ce046cc05b186332775c03ac6792caf'
src/main/java/com/lf/server/controller/data/MetaController.java
@@ -10,7 +10,6 @@
import com.lf.server.entity.data.MetaFileEntity;
import com.lf.server.entity.sys.UserEntity;
import com.lf.server.helper.Md5Helper;
import com.lf.server.helper.RsaHelper;
import com.lf.server.helper.StringHelper;
import com.lf.server.helper.WebHelper;
import com.lf.server.service.data.DownloadService;
@@ -290,26 +289,28 @@
    @SysLog()
    @ApiOperation(value = "下载文件")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "guid", value = "文件GUID", dataType = "String", paramType = "query")
            @ApiImplicitParam(name = "guid", value = "文件GUID", dataType = "String", paramType = "query"),
            @ApiImplicitParam(name = "pwd", value = "密码", dataType = "String", paramType = "query")
    })
    @ResponseBody
    @RequestMapping(value = "/downloadFile", method = RequestMethod.GET)
    public void downloadFile(@RequestBody DownloadReqEntity reqEntity, HttpServletRequest req, HttpServletResponse res) {
    @GetMapping(value = "/downloadFile")
    public void downloadFile(String guid, String pwd, HttpServletRequest req, HttpServletResponse res) {
        try {
            if (null == reqEntity || StringHelper.isEmpty(reqEntity.getPwd())) {
                WebHelper.writeInfo(HttpStatus.BAD_REQUEST, "密码不能为空", res);
            }
            if (StringHelper.isEmpty(reqEntity.getGuid())) {
                WebHelper.writeInfo(HttpStatus.BAD_REQUEST, "找不到文件ID", res);
                return;
            if (StringHelper.isEmpty(guid) || StringHelper.isEmpty(pwd)) {
                WebHelper.writeInfo(HttpStatus.BAD_REQUEST, "文件ID和密码不能为空", res);
            }
            DownloadEntity de = downloadService.selectByGuid(reqEntity.getGuid());
            String password = downloadService.decryptPwd(pwd);
            if (null == password) {
                WebHelper.writeInfo(HttpStatus.BAD_REQUEST, "密码解密失败", res);
            }
            DownloadEntity de = downloadService.selectByGuid(guid);
            if (null == de) {
                WebHelper.writeInfo(HttpStatus.NOT_FOUND, "文件不存在", res);
                return;
            }
            if (!StringHelper.isNull(de.getPwd()) && !Md5Helper.validatePassword(reqEntity.getPwd(), de.getPwd())) {
            if (!StringHelper.isNull(de.getPwd()) && !Md5Helper.validatePassword(password, de.getPwd())) {
                WebHelper.writeInfo(HttpStatus.UNAUTHORIZED, "密码不正确", res);
            }
src/main/java/com/lf/server/service/data/DownloadService.java
@@ -132,4 +132,19 @@
            return false;
        }
    }
    /**
     * 解密
     *
     * @param pwd 加密密码
     * @return 原始密码
     */
    public String decryptPwd(String pwd) {
        try {
            return RsaHelper.decrypt(pwd);
        } catch (Exception ex) {
            log.error(ex.getMessage(), ex);
            return null;
        }
    }
}