yangys
2025-11-27 34428bd30b004336f9ebc93de0ebe8fae65017c9
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
package org.springblade.mdm.commons.controller;
 
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.servlet.http.HttpServletResponse;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.io.IOUtils;
import org.apache.commons.lang3.StringUtils;
import org.springblade.core.mp.support.Condition;
import org.springblade.core.oss.OssTemplate;
import org.springblade.core.secure.utils.AuthUtil;
import org.springblade.core.tool.api.R;
import org.springblade.core.tool.utils.Func;
import org.springblade.mdm.commons.service.OssFileCommonService;
import org.springblade.mdm.commons.service.ParamService;
import org.springblade.mdm.commons.vo.RemindVO;
import org.springblade.mdm.flow.service.FlowBusinessService;
import org.springblade.mdm.flow.vo.FlowVO;
import org.springblade.mdm.flow.vo.TodoQueryVO;
import org.springblade.mdm.program.service.NcProgramApprovedService;
import org.springblade.mdm.program.vo.NcProgramExportDncPageVO;
import org.springblade.mdm.program.vo.NcProgramExportDncQueryVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
 
import java.io.IOException;
import java.io.InputStream;
import java.util.List;
 
@Slf4j
@RestController
@RequestMapping("/ossfile")
@Tag(name = "任务提醒", description = "任务提醒")
public class OssFileController {
 
    @Autowired
    private OssFileCommonService ossFileCommonService;
    @Autowired
    private OssTemplate ossTemplate;
    @Autowired
    private ParamService paramService;
    /**
     * 待办任务列表页
     */
    @GetMapping("file-content")
    @ApiOperationSupport(order = 3)
    @Operation(summary = "获取文件文本内容", description = "获取文件文本内容")
    public R<String> fileContent(String ossFileName) {
        if(StringUtils.isBlank(ossFileName)){
            throw new RuntimeException("文件名为空");
        }
        return R.data(ossFileCommonService.getOssFileContent(ossFileName));
    }
 
 
    @GetMapping("file-bytes")
    @ApiOperationSupport(order = 3)
    @Operation(summary = "获取文件字节", description = "获取文件字节")
    public void fileBytes(String ossFileName, HttpServletResponse response) throws IOException {
        if(StringUtils.isBlank(ossFileName)){
            throw new RuntimeException("文件名为空");
        }
        //ossTemplate.fileLink()
        try(InputStream ins = ossTemplate.statFileStream(ossFileName);){
            response.getOutputStream().write(IOUtils.toByteArray(ins));
        }
    }
 
    @GetMapping("file-link")
    @ApiOperationSupport(order = 3)
    @Operation(summary = "获取文件字节", description = "获取文件字节")
    public R<String> fileLink(String ossFileName, HttpServletResponse response) throws IOException {
        if(StringUtils.isBlank(ossFileName)){
            throw new RuntimeException("文件名为空");
        }
        String link = ossTemplate.fileLink(ossFileName);
        return R.data(link);
    }
}