|
@@ -15,12 +15,15 @@ import com.miaxis.wx.service.IWxXcxService;
|
|
|
import com.miaxis.wx.service.IWxService;
|
|
|
import io.swagger.annotations.Api;
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
+import org.apache.commons.io.IOUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.web.bind.annotation.GetMapping;
|
|
|
import org.springframework.web.bind.annotation.PutMapping;
|
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
|
|
|
|
+import java.io.IOException;
|
|
|
+import java.io.InputStream;
|
|
|
import java.security.KeyFactory;
|
|
|
import java.security.PrivateKey;
|
|
|
import java.security.Signature;
|
|
@@ -112,12 +115,12 @@ public class UserInfoController extends BaseController {
|
|
|
JSONObject resultData = JSONObject.parseObject(resultStr);
|
|
|
|
|
|
String errcode = resultData.getString("errcode");
|
|
|
- if("0".equals(errcode)) {
|
|
|
+ if ("0".equals(errcode)) {
|
|
|
JSONObject phoneInfo = resultData.getJSONObject("phone_info");
|
|
|
String purePhoneNumber = phoneInfo.getString("purePhoneNumber");
|
|
|
return Response.success(purePhoneNumber);
|
|
|
} else {
|
|
|
- throw new CustomException("手机号获取失败");
|
|
|
+ throw new CustomException("手机号获取失败");
|
|
|
}
|
|
|
|
|
|
}
|
|
@@ -127,20 +130,32 @@ public class UserInfoController extends BaseController {
|
|
|
*/
|
|
|
@GetMapping(value = "/getWxacodeunLimit")
|
|
|
@ApiOperation("获取个人小程序二维码")
|
|
|
- public Response getWxacodeunLimit() {
|
|
|
+ public Response getWxacodeunLimit() throws IOException {
|
|
|
UserInfo userInfo = SecurityUtils.getLoginUser().getStudent();
|
|
|
String token = xcxService.getLocalXcxToken();
|
|
|
WxacodeUnlimitDTO unlimitDTO = new WxacodeUnlimitDTO();
|
|
|
unlimitDTO.setScene(userInfo.getUnionId());
|
|
|
unlimitDTO.setEnv_version("trial");
|
|
|
- byte[] data = wxService.getWxacodeunLimit(token,unlimitDTO);
|
|
|
- String base64Str = Base64.getEncoder().encodeToString(data);
|
|
|
- System.out.println(base64Str);
|
|
|
- return Response.success(base64Str);
|
|
|
+ feign.Response response = wxService.getWxacodeunLimit(token, unlimitDTO);
|
|
|
+
|
|
|
+ String contentType = response.headers().get("Content-Type").stream().findFirst().orElse("");
|
|
|
+ System.out.println(contentType);
|
|
|
+ if (response.status() == 200) {
|
|
|
+ if (contentType.contains("image/jpeg")) {
|
|
|
+ InputStream io = response.body().asInputStream();
|
|
|
+ byte[] byteArray = IOUtils.toByteArray(io);
|
|
|
+ String base64Str = Base64.getEncoder().encodeToString(byteArray);
|
|
|
+ Response.success(base64Str);
|
|
|
+ } else if (contentType.contains("application/json")) {
|
|
|
+ Response res = new Response(502, "微信接口token问题,请管理员");
|
|
|
+ return res;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ Response res = new Response(502, "接口相关问题,请管理员");
|
|
|
+ return res;
|
|
|
}
|
|
|
|
|
|
|
|
|
-
|
|
|
private String getSign(Integer isVip, String unionId) throws Exception {
|
|
|
String str = unionId + isVip;
|
|
|
// 进行签名服务
|