瀏覽代碼

公告附件下载

zhuhaiwen 3 年之前
父節點
當前提交
3dcf64d51d

+ 4 - 3
oa-app/src/main/java/com/css/oa/exam/announce/controller/AnnounceController.java

@ -67,14 +67,15 @@ public class AnnounceController extends BaseController {
67 67
    public void download(@RequestParam(value = "uuid") String uuid, HttpServletRequest request, HttpServletResponse response) {
68 68
        try {
69 69
            if(TextUtils.isEmpty(uuid)){
70
                exportPrint(response, "未找到此文件!");
70
                exportPrint(response, "uuid不能为空");
71 71
                return;
72 72
            }
73 73
            String token = getToken();
74 74
            mService.setToken(token);
75 75
            mService.download(uuid, request, response);
76
        } catch (Exception e1) {
77
            e1.printStackTrace();
76
        } catch (Exception e) {
77
            e.printStackTrace();
78
            exportPrint(response, e.getMessage());
78 79
        }
79 80
    }
80 81

+ 6 - 2
oa-app/src/main/java/com/css/oa/exam/announce/service/AnnounceService.java

@ -74,9 +74,13 @@ public class AnnounceService extends BaseService implements IAnnounceService {
74 74
     *  @param uuid = OP_XM_ENCLOSURE表主键
75 75
     */
76 76
    @Override
77
    public void download(String uuid, HttpServletRequest request, HttpServletResponse response) {
77
    public void download(String uuid, HttpServletRequest request, HttpServletResponse response) throws Exception {
78 78
        Admin admin = Admin.getAdminByToken(token);
79
        uploadService.download(admin, uuid, request, response);
79
        Announce announce = repository.findById(uuid).get();
80
        if(TextUtils.isEmpty(announce.getFile_id())){
81
            throw new Exception("此公告没有附件可下载");
82
        }
83
        uploadService.download(admin, announce.getFile_id(), request, response);
80 84
    }
81 85
82 86
    @Override

+ 1 - 1
oa-app/src/main/java/com/css/oa/exam/announce/service/IAnnounceService.java

@ -13,7 +13,7 @@ public interface IAnnounceService {
13 13
14 14
    void add(Announce test);
15 15
16
    void download(String uuid, HttpServletRequest request, HttpServletResponse response);
16
    void download(String uuid, HttpServletRequest request, HttpServletResponse response) throws Exception;
17 17
18 18
    Map queryPage(AnnoQueryReq req);
19 19

+ 2 - 2
oa-app/src/main/java/com/css/oa/exam/util/upload/UploadService.java

@ -65,13 +65,13 @@ public class UploadService {
65 65
    @Autowired
66 66
    FileInfoRepository fileInfoRepository;
67 67
68
    public void download(Admin admin, String uuid, HttpServletRequest request, HttpServletResponse response) {
68
    public void download(Admin admin, String file_id, HttpServletRequest request, HttpServletResponse response) {
69 69
        try {
70 70
            response.reset();
71 71
            // 设置文件输出类型
72 72
            response.setContentType("multipart/form-data");
73 73
            // 文件名编码
74
            FileInfoEntity entity = fileInfoRepository.findOne(uuid);
74
            FileInfoEntity entity = fileInfoRepository.findOne(file_id);
75 75
            String fileName = entity.getFileName();
76 76
            response.setHeader("Content-Disposition", "attachment; fileName=" + transCharacter(request, fileName));
77 77
            UploadUtil.downloadListFolderFiles(admin, entity.getUuid(), entity.getUploadPath(), fileName, entity.getCipherKey(), response);