Quellcode durchsuchen

获取微信二维码修复

lqc vor 5 Jahren
Ursprung
Commit
67d0b6a8d4

+ 18 - 12
src/main/java/com/mokamrp/privates/controller/pangu/FosterwxStationController.java

@@ -3,22 +3,22 @@ package com.mokamrp.privates.controller.pangu;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.mokamrp.privates.constant.Constants;
 import com.mokamrp.privates.constant.HttpStatus;
+import com.mokamrp.privates.controller.BaseController;
 import com.mokamrp.privates.entity.AddHandle;
 import com.mokamrp.privates.entity.EditHandle;
 import com.mokamrp.privates.entity.PostBasePageHandle;
 import com.mokamrp.privates.entity.pangu.LoginStationHandle;
 import com.mokamrp.privates.help.AjaxResult;
 import com.mokamrp.privates.interceptor.AuthUser;
+import com.mokamrp.privates.mapper.pangu.pojo.FosterwxStation;
 import com.mokamrp.privates.mapper.pojo.User;
 import com.mokamrp.privates.service.CoralApiService;
 import com.mokamrp.privates.service.WechatApiService;
+import com.mokamrp.privates.service.pangu.FosterwxStationService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.validation.BindingResult;
 import org.springframework.web.bind.annotation.*;
-import com.mokamrp.privates.service.pangu.FosterwxStationService;
-import com.mokamrp.privates.mapper.pangu.pojo.FosterwxStation;
-import org.springframework.web.bind.annotation.RequestMapping;
-import com.mokamrp.privates.controller.BaseController;
+
 import javax.validation.Valid;
 import java.util.Map;
 
@@ -51,11 +51,11 @@ public class FosterwxStationController extends BaseController<FosterwxStation> {
      */
 
     @PostMapping("/list")
-    public Object list(@Valid @RequestBody PostBasePageHandle postBasePageHandle, BindingResult bindingResult){
+    public Object list(@Valid @RequestBody PostBasePageHandle postBasePageHandle, BindingResult bindingResult) {
         if (bindingResult.hasErrors()) {
             return AjaxResult.error(HttpStatus.ERROR, bindingResult.getFieldError().getDefaultMessage());
         }
-        Map<String,Object> res = fosterwxStationService.getList(postBasePageHandle);
+        Map<String, Object> res = fosterwxStationService.getList(postBasePageHandle);
         return AjaxResult.success(res);
     }
 
@@ -78,6 +78,12 @@ public class FosterwxStationController extends BaseController<FosterwxStation> {
         this.onInsert(addHandle.getRaw());
         Boolean res = fosterwxStationService.save(addHandle.getRaw());
         if (res) {
+            FosterwxStation fosterwxStation = new FosterwxStation();
+            String response = coralApiService.getBoxToken("gh_e529abe24cce");
+            String qrcodeUrl = wechatApiService.BuildBoxUnlimited(response, "asd=123", "pages/index/index");
+            fosterwxStation.setBoxShareUrl(fosterwxStationService.makeBoxShareUrl(qrcodeUrl, String.valueOf(addHandle.getRaw().getId()), addHandle.getRaw().getStationName()));
+            fosterwxStation.setId(addHandle.getRaw().getId());
+            fosterwxStationService.updateById(fosterwxStation);
             return AjaxResult.success(Constants.SUCCESS, res);
         } else {
             return AjaxResult.error("新增失败", res);
@@ -90,18 +96,18 @@ public class FosterwxStationController extends BaseController<FosterwxStation> {
      * @return
      */
     @PostMapping("/login")
-    public Object login(@Valid @RequestBody LoginStationHandle loginStationHandle){
-        Map<String,Object> res = fosterwxStationService.login(loginStationHandle);
-        if (res.get("token") == null || res.get("token").toString().isEmpty()){
+    public Object login(@Valid @RequestBody LoginStationHandle loginStationHandle) {
+        Map<String, Object> res = fosterwxStationService.login(loginStationHandle);
+        if (res.get("token") == null || res.get("token").toString().isEmpty()) {
             return AjaxResult.error(res.get("msg").toString());
         }
-        return AjaxResult.success(res.get("msg").toString(),res);
+        return AjaxResult.success(res.get("msg").toString(), res);
     }
 
     @GetMapping("/test")
-    public Object test(){
+    public Object test() {
         String res = coralApiService.getBoxToken("gh_e529abe24cce");
-        String qrcodeUrl = wechatApiService.BuildBoxUnlimited(res,"asd=123","pages/index/index");
+        String qrcodeUrl = wechatApiService.BuildBoxUnlimited(res, "asd=123", "pages/index/index");
         return AjaxResult.success(qrcodeUrl);
     }
 

+ 2 - 4
src/main/java/com/mokamrp/privates/service/impl/WechatApiServiceImpl.java

@@ -1,9 +1,7 @@
 package com.mokamrp.privates.service.impl;
 
-import com.alibaba.fastjson.JSON;
 import com.mokamrp.privates.service.FileService;
 import com.mokamrp.privates.service.WechatApiService;
-import com.mokamrp.privates.utils.http.HttpUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.core.io.Resource;
 import org.springframework.http.HttpEntity;
@@ -40,8 +38,8 @@ public class WechatApiServiceImpl implements WechatApiService {
         Map<String, String> body = new HashMap<>();
         body.put("scene", scene);
         body.put("page", page);
-        String jsonStr = JSON.toJSONString(body);
-        String qrcodeStr = HttpUtils.sendPost(wechatApi + url, jsonStr, "utf-8");
+        // String jsonStr = JSON.toJSONString(body);
+        // String qrcodeStr = HttpUtils.sendPost(wechatApi + url, jsonStr, "utf-8");
 
         HttpEntity<Map<String, String>> requestEntity = new HttpEntity<>(body, null);
         ResponseEntity<Resource> jsonObject = restTemplate.exchange(wechatApi + url, HttpMethod.POST, requestEntity, Resource.class);