|
@@ -3,6 +3,8 @@ package com.ytpm.question.controller;
|
|
|
import cn.hutool.core.collection.CollUtil;
|
|
import cn.hutool.core.collection.CollUtil;
|
|
|
import cn.hutool.core.date.DateUtil;
|
|
import cn.hutool.core.date.DateUtil;
|
|
|
import cn.hutool.core.util.StrUtil;
|
|
import cn.hutool.core.util.StrUtil;
|
|
|
|
|
+import cn.hutool.extra.qrcode.QrCodeUtil;
|
|
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
import com.github.pagehelper.PageHelper;
|
|
import com.github.pagehelper.PageHelper;
|
|
|
import com.github.pagehelper.PageInfo;
|
|
import com.github.pagehelper.PageInfo;
|
|
|
import com.ytpm.advertise.enums.AdSourceTypeEnum;
|
|
import com.ytpm.advertise.enums.AdSourceTypeEnum;
|
|
@@ -35,6 +37,8 @@ import com.ytpm.risk.enums.BannedTypeEnum;
|
|
|
import com.ytpm.risk.view.RiskConfigView;
|
|
import com.ytpm.risk.view.RiskConfigView;
|
|
|
import com.ytpm.risk.view.RiskTemplateView;
|
|
import com.ytpm.risk.view.RiskTemplateView;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
|
+import org.apache.commons.codec.binary.Base64;
|
|
|
|
|
+import org.springframework.beans.factory.annotation.Value;
|
|
|
import org.springframework.web.bind.annotation.GetMapping;
|
|
import org.springframework.web.bind.annotation.GetMapping;
|
|
|
import org.springframework.web.bind.annotation.PostMapping;
|
|
import org.springframework.web.bind.annotation.PostMapping;
|
|
|
import org.springframework.web.bind.annotation.RequestBody;
|
|
import org.springframework.web.bind.annotation.RequestBody;
|
|
@@ -43,6 +47,9 @@ import org.springframework.web.bind.annotation.RequestParam;
|
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
import javax.annotation.Resource;
|
|
|
|
|
+import javax.imageio.ImageIO;
|
|
|
|
|
+import java.awt.image.BufferedImage;
|
|
|
|
|
+import java.io.ByteArrayOutputStream;
|
|
|
import java.math.BigDecimal;
|
|
import java.math.BigDecimal;
|
|
|
import java.time.LocalDate;
|
|
import java.time.LocalDate;
|
|
|
import java.time.LocalDateTime;
|
|
import java.time.LocalDateTime;
|
|
@@ -75,6 +82,9 @@ public class UserController {
|
|
|
@Resource
|
|
@Resource
|
|
|
private RiskFeign riskFeign;
|
|
private RiskFeign riskFeign;
|
|
|
|
|
|
|
|
|
|
+ @Value("${spring.application.name:}")
|
|
|
|
|
+ private String applicationName;
|
|
|
|
|
+
|
|
|
/**
|
|
/**
|
|
|
* 根据应用ID查询当月注册用户
|
|
* 根据应用ID查询当月注册用户
|
|
|
*/
|
|
*/
|
|
@@ -165,9 +175,31 @@ public class UserController {
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
+ JSONObject jsonObject = new JSONObject();
|
|
|
|
|
+ jsonObject.put("serverName", applicationName);
|
|
|
|
|
+ jsonObject.put("appId", user.getAppId());
|
|
|
|
|
+ jsonObject.put("userId", userId);
|
|
|
|
|
+ jsonObject.put("deviceId", user.getDeviceId());
|
|
|
|
|
+ String content = new Base64().encodeToString(JSONObject.toJSONString(jsonObject).getBytes());
|
|
|
|
|
+ BufferedImage qrCode = QrCodeUtil.generate(content, 50, 50);
|
|
|
|
|
+ user.setQrCode(bufferedImageToBase64(qrCode));
|
|
|
return Result.resultObjOk(user);
|
|
return Result.resultObjOk(user);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ public String bufferedImageToBase64(BufferedImage bufferedImage) {
|
|
|
|
|
+ try {
|
|
|
|
|
+ ByteArrayOutputStream stream = new ByteArrayOutputStream();
|
|
|
|
|
+ ImageIO.write(bufferedImage, "png", stream);
|
|
|
|
|
+ Base64 base64 = new Base64();
|
|
|
|
|
+ String base64String = base64.encodeToString(stream.toByteArray());
|
|
|
|
|
+ return "data:image/png;base64," + base64String;
|
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
|
+ log.error("生成qrCode失败", e);
|
|
|
|
|
+ return "";
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
/**
|
|
/**
|
|
|
* 查询用户信息
|
|
* 查询用户信息
|
|
|
*/
|
|
*/
|