|
|
|
@ -1,14 +1,29 @@
|
|
|
|
|
package com.sztzjy.block_finance.controller;
|
|
|
|
|
|
|
|
|
|
import com.sztzjy.block_finance.annotation.AnonymousAccess;
|
|
|
|
|
import com.sztzjy.block_finance.entity.StuUploadResourceInfo;
|
|
|
|
|
import com.sztzjy.block_finance.entity.StuUploadResourceInfoExample;
|
|
|
|
|
import com.sztzjy.block_finance.mappers.StuUploadResourceInfoMapper;
|
|
|
|
|
import com.sztzjy.block_finance.service.StuSendApplyService;
|
|
|
|
|
import com.sztzjy.block_finance.util.ResultEntity;
|
|
|
|
|
import com.sztzjy.block_finance.util.file.IFileUtil;
|
|
|
|
|
import io.swagger.annotations.Api;
|
|
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
|
|
import org.springframework.http.MediaType;
|
|
|
|
|
import org.springframework.http.ResponseEntity;
|
|
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
|
|
import java.io.IOException;
|
|
|
|
|
import java.nio.file.Files;
|
|
|
|
|
import java.nio.file.Paths;
|
|
|
|
|
import java.util.HashMap;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @author 17803
|
|
|
|
|
* @date 2024-04-01 13:57
|
|
|
|
@ -24,23 +39,68 @@ public class StuSendApplyController {
|
|
|
|
|
private StuSendApplyService service;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Value("${file.path}")
|
|
|
|
|
private String filePath;
|
|
|
|
|
|
|
|
|
|
@Resource
|
|
|
|
|
private IFileUtil IFileUtil;
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
private StuUploadResourceInfoMapper uploadResourceInfoMapper;
|
|
|
|
|
|
|
|
|
|
@ApiOperation("关联数字债权凭证上传")
|
|
|
|
|
@GetMapping("/uploadDebt")
|
|
|
|
|
@AnonymousAccess
|
|
|
|
|
public ResultEntity uploadDebt(@RequestParam(required = true) @RequestPart MultipartFile file,
|
|
|
|
|
@RequestParam(required = true) String userId){
|
|
|
|
|
public void uploadDebt(@RequestParam(required = true) @RequestPart MultipartFile file,
|
|
|
|
|
@RequestParam(required = true) String userId,String fileName){
|
|
|
|
|
|
|
|
|
|
// return service.readVoucher(userId);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
service.uploadDebt(file,userId,fileName);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@GetMapping("/readByDebt")
|
|
|
|
|
@ApiOperation("发起保理申请预览:统一接口")
|
|
|
|
|
@AnonymousAccess
|
|
|
|
|
ResponseEntity<byte[]> readByDebt(String userId, String docName) throws IOException, IOException {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
StuUploadResourceInfoExample example = new StuUploadResourceInfoExample();
|
|
|
|
|
example.createCriteria().andUserIdEqualTo(userId).andModuleEqualTo(docName);
|
|
|
|
|
List<StuUploadResourceInfo> uploadResourceInfos = uploadResourceInfoMapper.selectByExample(example);
|
|
|
|
|
|
|
|
|
|
if (uploadResourceInfos.isEmpty()){
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
String fileUrl = uploadResourceInfos.get(0).getFileUrl();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 模拟加载公章图片的数据(假设在硬盘上的某个路径下)
|
|
|
|
|
String imagePath = filePath +fileUrl;
|
|
|
|
|
// 替换为你的实际路径
|
|
|
|
|
byte[] sealBytes = Files.readAllBytes(Paths.get(imagePath));
|
|
|
|
|
|
|
|
|
|
// 构建HTTP响应,设置Content-Type为image/png
|
|
|
|
|
return ResponseEntity.ok().contentType(MediaType.APPLICATION_PDF).body(sealBytes);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@GetMapping("/downloadByInfo")
|
|
|
|
|
@ApiOperation("模板下载")
|
|
|
|
|
@AnonymousAccess
|
|
|
|
|
public void downloadByInfo(@RequestParam String userId , HttpServletResponse response) {
|
|
|
|
|
|
|
|
|
|
// TokenProvider.getJWTUser(TOKEN);
|
|
|
|
|
|
|
|
|
|
IFileUtil.download(response,"/supply/部分3 采购订单1.pdf");
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|