|
|
|
@@ -21,10 +21,7 @@ import me.chanjar.weixin.open.bean.result.*; |
|
|
|
import org.slf4j.Logger; |
|
|
|
import org.slf4j.LoggerFactory; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.web.bind.annotation.GetMapping; |
|
|
|
import org.springframework.web.bind.annotation.PostMapping; |
|
|
|
import org.springframework.web.bind.annotation.RequestMapping; |
|
|
|
import org.springframework.web.bind.annotation.RestController; |
|
|
|
import org.springframework.web.bind.annotation.*; |
|
|
|
|
|
|
|
import javax.servlet.ServletOutputStream; |
|
|
|
import javax.servlet.http.HttpServletRequest; |
|
|
|
@@ -33,6 +30,7 @@ import java.io.File; |
|
|
|
import java.io.FileInputStream; |
|
|
|
import java.io.IOException; |
|
|
|
import java.io.InputStream; |
|
|
|
import java.net.URLEncoder; |
|
|
|
import java.util.Map; |
|
|
|
|
|
|
|
/** |
|
|
|
@@ -68,24 +66,24 @@ public class WechatWeappCodeController { |
|
|
|
|
|
|
|
@ApiOperation("获取体验小程序的体验二维码") |
|
|
|
@GetMapping("/getQrcode") |
|
|
|
public void getQrcode(String appId, String pagePath, Map<String, String> params, HttpServletResponse response, HttpServletRequest req) { |
|
|
|
public void getQrcode(@RequestParam(value = "appId") String appId, @RequestParam(value = "pagePath") String pagePath, |
|
|
|
@RequestParam(value = "params") Map<String, String> params, |
|
|
|
HttpServletResponse response, HttpServletRequest req) { |
|
|
|
try { |
|
|
|
WxOpenMaService openMaService = openService.getWxOpenComponentService().getWxMaServiceByAppid(appId); |
|
|
|
File file = openMaService.getTestQrcode(pagePath, params); |
|
|
|
ServletOutputStream out = response.getOutputStream(); |
|
|
|
|
|
|
|
response.reset(); |
|
|
|
response.setContentType("bin"); |
|
|
|
response.setContentType("image/jpeg"); |
|
|
|
String agent = req.getHeader("user-agent"); |
|
|
|
String filename = "qrcode"; |
|
|
|
String filename = "QRCode.jpg"; |
|
|
|
if (agent.contains("Firefox")) { |
|
|
|
response.setHeader("Content-disposition", |
|
|
|
"attachment; filename=" |
|
|
|
+ new String(filename.getBytes("GB2312"),"ISO-8859-1")); |
|
|
|
"attachment; filename=" + new String(filename.getBytes("GB2312"),"ISO-8859-1")); |
|
|
|
} else { |
|
|
|
response.setHeader("Content-disposition", |
|
|
|
"attachment; filename=" |
|
|
|
+ java.net.URLEncoder.encode(filename,"UTF-8")); |
|
|
|
"attachment; filename=" + URLEncoder.encode(filename,"UTF-8")); |
|
|
|
} |
|
|
|
// 循环取出流中的数据 |
|
|
|
byte[] b = new byte[1024]; |
|
|
|
|