|
|
|
@@ -16,6 +16,8 @@ import com.iformall.mapper.WxRentContractMapper; |
|
|
|
import com.iformall.mapper.WxShopMapper; |
|
|
|
import com.iformall.service.WxMerchantService; |
|
|
|
import com.iformall.service.WxRentContractService; |
|
|
|
import com.iformall.utils.Constant; |
|
|
|
import org.apache.commons.io.FileUtils; |
|
|
|
import org.slf4j.Logger; |
|
|
|
import org.slf4j.LoggerFactory; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
@@ -24,8 +26,11 @@ import org.springframework.transaction.annotation.Transactional; |
|
|
|
|
|
|
|
import javax.servlet.http.HttpServletRequest; |
|
|
|
import javax.servlet.http.HttpServletResponse; |
|
|
|
import java.io.File; |
|
|
|
import java.io.FileInputStream; |
|
|
|
import java.io.IOException; |
|
|
|
import java.io.InputStream; |
|
|
|
import java.net.URL; |
|
|
|
import java.util.*; |
|
|
|
|
|
|
|
/** |
|
|
|
@@ -122,9 +127,22 @@ public class WxRentContractServiceImpl implements WxRentContractService { |
|
|
|
public void download(HttpServletRequest request, HttpServletResponse response, String tenantId) { |
|
|
|
String id = request.getParameter("id"); |
|
|
|
WxRentContract wxRentContract = wxRentContractMapper.selectByPrimaryKey(id); |
|
|
|
String filename = wxRentContract.getFilepath().substring(wxRentContract.getFilepath().lastIndexOf("/")); |
|
|
|
downFile(wxRentContract.getFilepath(), filename, response, request); |
|
|
|
|
|
|
|
String filename = wxRentContract.getFilepath().substring(wxRentContract.getFilepath().lastIndexOf("/")+1); |
|
|
|
String filepath = Constant.fileDirectory; |
|
|
|
String destPath = filepath + filename; |
|
|
|
File dest = new File(destPath); |
|
|
|
File pDest = dest.getParentFile(); |
|
|
|
if (!pDest.exists()) { |
|
|
|
pDest.mkdirs(); |
|
|
|
} |
|
|
|
try { |
|
|
|
FileUtils.copyURLToFile(new URL(wxRentContract.getFilepath()),dest); |
|
|
|
downFile(destPath, filename, response, request); |
|
|
|
org.apache.commons.io.FileUtils.forceDelete(dest); |
|
|
|
} catch (IOException e) { |
|
|
|
logger.info("创建本地文件失败"+e.getMessage()); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
@Transactional(rollbackFor = {Exception.class}) |
|
|
|
|