管道基础大数据平台系统开发-【后端】-Server
1
13693261870
2023-04-06 4ec6b4b2f09d573d303940d453187c21e407e6ee
src/main/java/com/lf/server/controller/show/ApplyController.java
@@ -2,17 +2,21 @@
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.DownloadEntity;
import com.lf.server.entity.show.ApplyEntity;
import com.lf.server.entity.show.FlowEntity;
import com.lf.server.entity.sys.UserEntity;
import com.lf.server.helper.AesHelper;
import com.lf.server.helper.StringHelper;
import com.lf.server.helper.WebHelper;
import com.lf.server.service.data.DownloadService;
import com.lf.server.service.show.ApplyService;
import com.lf.server.service.show.FlowService;
import com.lf.server.service.sys.DownlogService;
import com.lf.server.service.sys.TokenService;
import com.lf.server.service.sys.UserService;
import io.swagger.annotations.Api;
@@ -23,6 +27,7 @@
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.sql.Timestamp;
import java.util.List;
@@ -45,6 +50,12 @@
    @Autowired
    UserService userService;
    @Autowired
    DownlogService downlogService;
    @Autowired
    DownloadService downloadService;
    @SysLog()
    @ApiOperation(value = "插入数据申请")
@@ -266,4 +277,29 @@
            return fail(ex, null);
        }
    }
    @SysLog()
    @ApiOperation(value = "下载文件")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "guid", value = "文件GUID", dataType = "String", paramType = "query")
    })
    @ResponseBody
    @GetMapping(value = "/downloadFile")
    public void downloadFile(String guid, HttpServletRequest req, HttpServletResponse res) {
        try {
            DownloadEntity de = downloadService.selectByGuid(guid);
            if (null == de) {
                WebHelper.writeInfo(HttpStatus.NOT_FOUND, "文件不存在", res);
                return;
            }
            UserEntity ue = tokenService.getCurrentUser(req);
            downlogService.updateInfos(ue, de, req);
            String filePath = downloadService.getDownloadFilePath(de);
            WebHelper.download(filePath, de.getName(), res);
        } catch (Exception ex) {
            WebHelper.writeInfo(HttpStatus.ERROR, ex.getMessage(), res);
        }
    }
}