|
@@ -0,0 +1,92 @@
|
|
|
+package com.miaxis.system.controller.test;
|
|
|
+
|
|
|
+import cn.hutool.core.io.FileUtil;
|
|
|
+import cn.hutool.extra.qrcode.QrCodeUtil;
|
|
|
+import cn.hutool.extra.qrcode.QrConfig;
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
+import com.miaxis.common.annotation.Log;
|
|
|
+import com.miaxis.common.core.domain.Response;
|
|
|
+import com.miaxis.common.enums.BusinessTypeEnum;
|
|
|
+import com.miaxis.feign.dto.WxTicket;
|
|
|
+import com.miaxis.feign.service.IWxMpService;
|
|
|
+import com.miaxis.feign.service.IWxSendService;
|
|
|
+import com.miaxis.wx.service.IWxGzhService;
|
|
|
+import io.swagger.annotations.Api;
|
|
|
+import io.swagger.annotations.ApiOperation;
|
|
|
+import io.swagger.annotations.ApiParam;
|
|
|
+import lombok.RequiredArgsConstructor;
|
|
|
+import org.slf4j.Logger;
|
|
|
+import org.slf4j.LoggerFactory;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.security.access.prepost.PreAuthorize;
|
|
|
+import org.springframework.web.bind.annotation.*;
|
|
|
+
|
|
|
+import java.net.URLEncoder;
|
|
|
+
|
|
|
+/**
|
|
|
+ * @author wwl
|
|
|
+ * @version 1.0
|
|
|
+ * @date 2021/10/21 14:02
|
|
|
+ */
|
|
|
+@RestController
|
|
|
+@RequiredArgsConstructor
|
|
|
+@RequestMapping("/wxTest")
|
|
|
+@Api(tags={"测试"})
|
|
|
+public class TestController {
|
|
|
+
|
|
|
+ private static final Logger log = LoggerFactory.getLogger(TestController.class);
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ IWxSendService wxSendService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ IWxGzhService wxGzhService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ IWxMpService wxMpService;
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 生成带参数的二维码
|
|
|
+ */
|
|
|
+ @GetMapping(value = "/generateTicket")
|
|
|
+ @ApiOperation("生成带参数的二维码")
|
|
|
+ public Response generateTicket() throws Exception{
|
|
|
+ String xcxMessageToken = wxGzhService.getGzhToken();
|
|
|
+ WxTicket wxTicket = new WxTicket();
|
|
|
+ wxTicket.setExpire_seconds(3000);
|
|
|
+ wxTicket.setAction_name("QR_SCENE");
|
|
|
+ JSONObject jsonObject1 = new JSONObject();
|
|
|
+ JSONObject jsonObject2 = new JSONObject();
|
|
|
+ jsonObject1.put("scene_id","123");
|
|
|
+ jsonObject2.put("scene",jsonObject1);
|
|
|
+ wxTicket.setAction_info(jsonObject2);
|
|
|
+ String result = wxSendService.generateTicket(xcxMessageToken,wxTicket);
|
|
|
+ System.out.println("生成ticket:" + result);
|
|
|
+ JSONObject jsonStr = JSONObject.parseObject(result);
|
|
|
+
|
|
|
+ QrCodeUtil.generate(
|
|
|
+ jsonStr.getString("url"), //二维码内容
|
|
|
+ QrConfig.create().setImg("C:\\Users\\wwl\\Desktop\\二维码\\微信图片_20211021120216.jpg"),
|
|
|
+ FileUtil.file("C:\\Users\\wwl\\Desktop\\二维码\\logo二维码.jpg")//写出到的文件
|
|
|
+ );
|
|
|
+
|
|
|
+ String decode = QrCodeUtil.decode(FileUtil.file("C:\\Users\\wwl\\Desktop\\二维码\\logo二维码.jpg"));
|
|
|
+ System.out.println("二维码信息:"+ decode);
|
|
|
+ return Response.success();
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 测试
|
|
|
+ */
|
|
|
+ @Log(title = "测试", businessType = BusinessTypeEnum.UPDATE)
|
|
|
+ @PutMapping("/test")
|
|
|
+ @ApiOperation("测试")
|
|
|
+ public void test(Object object){
|
|
|
+ System.out.println("----test-----"+ object);
|
|
|
+ log.info("测试:"+object);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+}
|