This commit is contained in:
sjm
2023-12-22 23:25:19 +08:00
parent 7adff734ea
commit a9a4cbcf83
11 changed files with 398 additions and 41 deletions

View File

@@ -1,27 +1,25 @@
package com.lovenav.controller;
import com.alibaba.fastjson.JSON;
import com.lovenav.entity.CollectIconList;
import com.lovenav.service.QRCService;
import com.lovenav.utils.QRCodeUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
@RestController
import java.util.Collection;
@RestController
@RequestMapping("/qrcode")
public class QRCodeController {
private QRCodeUtil qrCodeUtil;
@RequestMapping(method = RequestMethod.GET, value = "/qrc")
public String QRCode(String url){
String text = url;
String logoPath ="src/main/resources/static/logo/NAV.png";
String destPath = "src/main/resources/static/qr";
try {
String url2 = qrCodeUtil.encode(text, logoPath, destPath, true);
String base64 = qrCodeUtil.getBase64(url2);
return JSON.toJSONString(base64);
} catch (Exception e) {
throw new RuntimeException(e);
}
@Autowired
private QRCService qrcService;
@RequestMapping(method = RequestMethod.POST, value = "/qrc_return")
public String QRCode(@RequestBody CollectIconList collect) throws Exception {
return qrcService.QR(collect);
}
}
}