zsw-farm
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

48 lines
1.4 KiB

package co.yixiang.utils;
import cn.hutool.core.codec.Base64;
import cn.hutool.core.util.StrUtil;
import cn.hutool.extra.spring.EnableSpringUtil;
import cn.iocoder.yudao.framework.common.exception.YshopException;
import co.yixiang.constant.SystemConfigConstants;
import co.yixiang.modules.shop.service.YxSystemConfigService;
import lombok.experimental.UtilityClass;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
@Component
public class QrCodeutil {
@Autowired
private YxSystemConfigService systemConfigService;
/**
* 这个是生成单纯的内容二维码
* @param code
* @return
*/
public String generateQrStr(String code){
String apiUrl = systemConfigService.getData(SystemConfigConstants.API_URL);
if(StrUtil.isEmpty(apiUrl)){
throw new YshopException("未配置api地址");
}
return apiUrl + "/bxgApp/qrcode/image/"+code+".png";
}
/**
* 这个是生成带跳转的URL
* @param code
* @return
*/
public String generateQrUrlBase64(String code){
String apiUrl = systemConfigService.getData(SystemConfigConstants.API_URL);
if(StrUtil.isEmpty(apiUrl)){
throw new YshopException("未配置api地址");
}
String xcode = Base64.encode(code);
return apiUrl + "/bxgApp/qrcode/image/"+xcode+".png";
}
}