package com.ruoyi.project.tr.AndroidQrCode;
|
|
import com.ruoyi.common.utils.QRCodeUtil;
|
import com.ruoyi.project.tr.versionControl.domain.VersionControl;
|
import com.ruoyi.project.tr.versionControl.service.IVersionControlService;
|
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.stereotype.Controller;
|
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
import javax.servlet.ServletOutputStream;
|
import javax.servlet.http.HttpServletResponse;
|
import java.util.List;
|
|
@Controller
|
@RequestMapping(value = "/androidQrCode")
|
public class AndroidQrCodeController {
|
@Autowired
|
private IVersionControlService versionControlService;
|
|
|
/**
|
* 页面
|
*/
|
@GetMapping("/page")
|
public String articleRegulation() {
|
return "tr/androidQrCode/androidQrCode";
|
}
|
|
|
/**
|
* 双预防安卓版下载二维码 图片
|
*/
|
@RequestMapping(value = "/showPic")
|
public void showPic(HttpServletResponse response) throws Exception {
|
ServletOutputStream stream = null;
|
try {
|
List<VersionControl> versionControlList = versionControlService.selectVersionControlList(new VersionControl());
|
if (versionControlList.size() > 0) {
|
String url = versionControlList.get(0).getApkPtah();
|
stream = response.getOutputStream();
|
String logoPath = "classpath:static/logo.jpg";
|
//使用工具类生成二维码
|
QRCodeUtil.encode(url, logoPath, stream, true);
|
}
|
} catch (Exception e) {
|
e.getStackTrace();
|
} finally {
|
if (stream != null) {
|
stream.flush();
|
stream.close();
|
}
|
}
|
}
|
|
|
/**
|
* 双预防安卓版下载二维码 下载
|
*/
|
@RequestMapping(value = "/downLoad")
|
public void downLoad(HttpServletResponse response) throws Exception {
|
response.setContentType("application/x-download");
|
response.setCharacterEncoding("UTF-8");
|
response.setHeader("Content-type", "text/html;charset=UTF-8");
|
response.setHeader("Content-Disposition", "attachment;filename=" + java.net.URLEncoder.encode("双预防安卓版下载二维码.jpg", "UTF-8"));
|
ServletOutputStream stream = null;
|
try {
|
List<VersionControl> versionControlList = versionControlService.selectVersionControlList(new VersionControl());
|
if (versionControlList.size() > 0) {
|
String url = versionControlList.get(0).getApkPtah();
|
stream = response.getOutputStream();
|
String logoPath = "classpath:static/logo.jpg";
|
//使用工具类生成二维码
|
QRCodeUtil.encode(url, logoPath, stream, true);
|
}
|
} catch (Exception e) {
|
e.getStackTrace();
|
} finally {
|
if (stream != null) {
|
stream.flush();
|
stream.close();
|
}
|
}
|
}
|
}
|