|
@@ -9,16 +9,26 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import com.usky.dxtop.common.constant.UserConstants;
|
|
|
import com.usky.dxtop.common.core.page.CommonPage;
|
|
|
import com.usky.dxtop.common.exception.CustomException;
|
|
|
+import com.usky.dxtop.common.utils.QRCodeUtil;
|
|
|
+import com.usky.dxtop.common.utils.SecurityUtils;
|
|
|
import com.usky.dxtop.common.utils.StringUtils;
|
|
|
import com.usky.dxtop.common.utils.file.FileUtils;
|
|
|
+import com.usky.dxtop.common.utils.sign.Base64;
|
|
|
import com.usky.dxtop.mapper.QrCodeMapper;
|
|
|
import com.usky.dxtop.model.QrCode;
|
|
|
+import com.usky.dxtop.model.SysConfig;
|
|
|
import com.usky.dxtop.model.TopChannel;
|
|
|
import com.usky.dxtop.model.TopRadio;
|
|
|
+import com.usky.dxtop.service.ISysConfigService;
|
|
|
import com.usky.dxtop.service.QrCodeService;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
+import org.springframework.util.FastByteArrayOutputStream;
|
|
|
|
|
|
+import javax.imageio.ImageIO;
|
|
|
+import java.awt.image.BufferedImage;
|
|
|
+import java.io.IOException;
|
|
|
import java.util.List;
|
|
|
|
|
|
/**
|
|
@@ -32,6 +42,35 @@ import java.util.List;
|
|
|
@Service
|
|
|
public class QrCodeServiceImpl extends ServiceImpl<QrCodeMapper, QrCode> implements QrCodeService {
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private ISysConfigService sysConfigService;
|
|
|
+
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public boolean add(QrCode qrCode) {
|
|
|
+ try {
|
|
|
+ String appPayPath = sysConfigService.selectConfigByKey("app.pay.path");
|
|
|
+ //生成二维码
|
|
|
+ BufferedImage image = QRCodeUtil.encode(appPayPath, null, true);
|
|
|
+ // 转换流信息写出
|
|
|
+ FastByteArrayOutputStream os = new FastByteArrayOutputStream();
|
|
|
+ try
|
|
|
+ {
|
|
|
+ ImageIO.write(image, "jpg", os);
|
|
|
+ }
|
|
|
+ catch (IOException e)
|
|
|
+ {
|
|
|
+ throw new CustomException("接口异常"+e.getMessage());
|
|
|
+ }
|
|
|
+ String encode = Base64.encode(os.toByteArray());
|
|
|
+ qrCode.setQrPath(encode);
|
|
|
+ qrCode.setCreateBy(SecurityUtils.getUsername());
|
|
|
+ }catch (Exception e){
|
|
|
+ throw new CustomException("生成二维码图片失败");
|
|
|
+ }
|
|
|
+ return this.save(qrCode);
|
|
|
+ }
|
|
|
+
|
|
|
@Override
|
|
|
public String checkNameUnique(QrCode qrCode) {
|
|
|
Long configId = StringUtils.isNull(qrCode.getId()) ? -1L : qrCode.getId();
|