管道基础大数据平台系统开发-【后端】-Server
1
13693261870
2023-03-06 64d3e9657fb45b6415b19e23f483d46a82efe939
1
已修改5个文件
94 ■■■■■ 文件已修改
src/main/java/com/lf/server/controller/sys/ResController.java 33 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/lf/server/mapper/sys/AttachMapper.java 11 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/lf/server/service/all/UploadAttachService.java 30 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/lf/server/service/sys/AttachService.java 7 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/resources/mapper/sys/AttachMapper.xml 13 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/lf/server/controller/sys/ResController.java
@@ -5,6 +5,7 @@
import com.lf.server.entity.all.ResponseMsg;
import com.lf.server.entity.sys.ResEntity;
import com.lf.server.entity.sys.UserEntity;
import com.lf.server.helper.StringHelper;
import com.lf.server.service.all.PermsService;
import com.lf.server.service.all.UploadAttachService;
import com.lf.server.service.data.DownloadService;
@@ -321,18 +322,44 @@
    })
    @ResponseBody
    @PostMapping(value = "/downloadReq")
    public ResponseMsg<Object> downloadReq(String[] guids, HttpServletRequest req, HttpServletResponse res) {
    public ResponseMsg<Object> downloadReqForGuids(String[] guids, HttpServletRequest req, HttpServletResponse res) {
        try {
            if (null == guids || guids.length == 0) {
                return fail("附件Guid数组为空");
                return fail("Guid数组为空");
            }
            UserEntity ue = tokenService.getCurrentUser(req);
            //String guid = downloadService.zipFiles(ue, list, reqEntity.getPwd());
            String guid = uploadAttachService.downloadReqForGuids(ue, guids);
            return success("");
        } catch (Exception ex) {
            return fail(ex, null);
        }
    }
    @SysLog()
    @ApiOperation(value = "请求下载")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "tab", value = "表名", dataType = "String", paramType = "body", example = "bd.b_borehole"),
            @ApiImplicitParam(name = "guids", value = "附件Guid数组", dataType = "String", paramType = "body", allowMultiple = true, example = "08e5b4ad-93b8-46f6-adaa-46a6274af4ce,6f94f4f8-6e8d-44e7-8803-3d068d34983f")
    })
    @ResponseBody
    @PostMapping(value = "/downloadReq")
    public ResponseMsg<Object> downloadReqForTabGuids(String tab, String[] guids, HttpServletRequest req, HttpServletResponse res) {
        try {
            if (StringHelper.isEmpty(tab)) {
                return fail("表名为空");
            }
            if (null != guids && guids.length == 0) {
                guids = null;
            }
            UserEntity ue = tokenService.getCurrentUser(req);
            String guid = uploadAttachService.downloadReqForTabGuids(ue, tab, guids);
            return success(guid);
        } catch (Exception ex) {
            return fail(ex, null);
        }
    }
}
src/main/java/com/lf/server/mapper/sys/AttachMapper.java
@@ -60,7 +60,7 @@
     * @param guids
     * @return
     */
    public AttachEntity selectByGuids(String[] guids);
    public List<AttachEntity> selectByGuids(String[] guids);
    /**
     * 根据表名和GUID查询
@@ -73,6 +73,15 @@
    public AttachEntity selectByTabAndGuid(String tab, String tabGuid, String guid);
    /**
     * 根据表名和GUID数组查询
     *
     * @param tab
     * @param guids
     * @return
     */
    public List<AttachEntity> selectByTabGuids(String tab, String[] guids);
    /**
     * 根据表和GUID查询
     *
     * @param tab
src/main/java/com/lf/server/service/all/UploadAttachService.java
@@ -1,6 +1,5 @@
package com.lf.server.service.all;
import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.lf.server.controller.all.BaseController;
import com.lf.server.entity.all.*;
@@ -405,4 +404,33 @@
        return entity;
    }
    /**
     * 请求下载
     */
    public String downloadReqForGuids(UserEntity ue, String[] guids) {
        List<AttachEntity> list = attachService.selectByGuids(guids);
        return downloadReq(ue, list);
    }
    /**
     * 请求下载
     */
    public String downloadReqForTabGuids(UserEntity ue, String tab, String[] guids) {
        List<AttachEntity> list = attachService.selectByTabGuids(tab, guids);
        return downloadReq(ue, list);
    }
    /**
     * 请求下载
     */
    protected String downloadReq(UserEntity ue, List<AttachEntity> list) {
        if (null == list || list.isEmpty()) {
            return null;
        }
        return "";
    }
}
src/main/java/com/lf/server/service/sys/AttachService.java
@@ -47,7 +47,7 @@
    }
    @Override
    public AttachEntity selectByGuids(String[] guids) {
    public List<AttachEntity> selectByGuids(String[] guids) {
        return attachMapper.selectByGuids(guids);
    }
@@ -57,6 +57,11 @@
    }
    @Override
    public List<AttachEntity> selectByTabGuids(String tab, String[] guids) {
        return attachMapper.selectByTabGuids(tab, guids);
    }
    @Override
    public List<AttachEntity> selectByTab(String tab, String guid) {
        return attachMapper.selectByTab(tab, guid);
    }
src/main/resources/mapper/sys/AttachMapper.xml
@@ -44,6 +44,19 @@
        select * from lf.sys_attach where tab = #{tab} and tab_guid = #{tabGuid} and guid = #{guid} limit 1
    </select>
    <select id="selectByTabGuids" resultType="com.lf.server.entity.sys.AttachEntity">
        select * from lf.sys_attach
        <where>
            tab = #{tab}
            <if test="guids != null">
                and tab_guid in
                <foreach item="guid" collection="guids" index="index" open="(" separator="," close=")">
                    #{guid}
                </foreach>
            </if>
        </where>
    </select>
    <select id="selectByTab" resultType="com.lf.server.entity.sys.AttachEntity">
        select * from lf.sys_attach where tab = #{tab} and tab_guid = #{guid}
    </select>