add 资料中心-下载

This commit is contained in:
liao
2023-10-31 15:07:59 +08:00
parent 5f2bf3e593
commit 89525e6523
@@ -3,13 +3,18 @@ package com.jero.modules.laws.dataCenter.controller;
import java.util.Arrays;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import com.jero.common.api.vo.Result;
import com.jero.common.exception.JeroBootException;
import com.jero.common.util.MessageUtils;
import com.jero.modules.laws.common.constant.FieldCommon;
import com.jero.modules.laws.common.constant.ResultCommon;
import com.jero.modules.laws.common.util.CurrentUserUtil;
import com.jero.modules.laws.dataCenter.entity.LawsDataCenterFile;
import com.jero.modules.laws.dataCenter.service.ILawsDataCenterFileService;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.jero.modules.system.controller.CommonController;
import lombok.extern.slf4j.Slf4j;
import com.jero.common.system.base.controller.JeroController;
import org.springframework.beans.factory.annotation.Autowired;
@@ -35,6 +40,8 @@ import org.apache.poi.ss.formula.functions.T;
public class LawsDataCenterFileController extends JeroController<LawsDataCenterFile, ILawsDataCenterFileService> {
@Autowired
private ILawsDataCenterFileService lawsDataCenterFileService;
@Autowired
private CommonController commonController;
/**
* 分页列表查询
@@ -125,12 +132,30 @@ public class LawsDataCenterFileController extends JeroController<LawsDataCenterF
@AutoLog(value = "资料中心-文件数据-通过id查询")
@ApiOperation(value = "资料中心-文件数据-通过id查询", notes = "资料中心-文件数据-通过id查询")
@GetMapping(value = "/queryById")
public Result<LawsDataCenterFile> queryById(@RequestParam(name = "id", required = true) String id) {
public Result<LawsDataCenterFile> queryById(@RequestParam(name = "id") String id) {
LawsDataCenterFile lawsDataCenterFile = lawsDataCenterFileService.queryById(id);
if (lawsDataCenterFile == null) {
return Result.error("未找到对应数据");
return Result.error(ResultCommon.NO_CORRESPONDING_DATA_FOUND);
}
return Result.OK(lawsDataCenterFile);
}
@AutoLog(value = "资料中心-文件数据-下载")
@ApiOperation(value = "资料中心-文件数据-下载", notes = "资料中心-文件数据-下载")
@GetMapping(value = "/download")
public void download(@RequestParam(name = "id") String id,HttpServletRequest request, HttpServletResponse response) {
LawsDataCenterFile file = lawsDataCenterFileService.queryById(id);
if (file == null) {
throw new JeroBootException(ResultCommon.NO_CORRESPONDING_DATA_FOUND);
}
// 不是管理员,不是自己上传的文件,并且推送范围不包含自己
if (!CurrentUserUtil.getRoles().contains(FieldCommon.ROLE_ADMIN)
&& !CurrentUserUtil.getId().equals(file.getOwnerId())
&& (StringUtils.isBlank(file.getPushRangeIds()) || !file.getPushRangeIds().contains(CurrentUserUtil.getId()))) {
throw new JeroBootException(ResultCommon.NO_PERMISSION);
}
// 下载
commonController.view(file.getFileId(), request, response);
}
}