package com.hotwj.platform.reportStatistics.verify.service;

import cn.hutool.core.codec.Base64;
import cn.hutool.core.img.ImgUtil;
import cn.hutool.extra.qrcode.QrCodeUtil;
import org.springframework.stereotype.Service;

import java.awt.image.BufferedImage;
import java.io.ByteArrayOutputStream;

@Service
public class QrCodeService {

    public String generatePngDataUrl(String content, int width, int height) {
        BufferedImage image = QrCodeUtil.generate(content, width, height);
        ByteArrayOutputStream out = new ByteArrayOutputStream();
        ImgUtil.writePng(image, out);
        return "data:image/png;base64," + Base64.encode(out.toByteArray());
    }
}

