lqc 5 лет назад
Родитель
Сommit
340aba00ea

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

@@ -80,8 +80,8 @@ public class FosterwxStationController extends BaseController<FosterwxStation> {
         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()));
+            String qrcodeUrl = wechatApiService.BuildBoxUnlimited(response, fosterwxStationService.makeBoxShareUrl(String.valueOf(addHandle.getRaw().getId()), addHandle.getRaw().getStationName()), "pages/index/index");
+            fosterwxStation.setBoxShareUrl(qrcodeUrl);
             fosterwxStation.setId(addHandle.getRaw().getId());
             fosterwxStationService.updateById(fosterwxStation);
             return AjaxResult.success(Constants.SUCCESS, res);

+ 5 - 4
src/main/java/com/mokamrp/privates/service/pangu/FosterwxStationService.java

@@ -1,11 +1,10 @@
 package com.mokamrp.privates.service.pangu;
 
-import com.mokamrp.privates.entity.pangu.LoginStationHandle;
-import com.mokamrp.privates.mapper.pangu.pojo.FosterwxStation;
 import com.baomidou.mybatisplus.extension.service.IService;
 import com.mokamrp.privates.entity.PostBasePageHandle;
+import com.mokamrp.privates.entity.pangu.LoginStationHandle;
+import com.mokamrp.privates.mapper.pangu.pojo.FosterwxStation;
 
-import java.util.List;
 import java.util.Map;
 
 /**
@@ -21,8 +20,10 @@ public interface FosterwxStationService extends IService<FosterwxStation> {
     public Map<String, Object> getList(PostBasePageHandle handle);
     //.@leon 站点负责人后台登录
     public Map<String, Object> login(LoginStationHandle loginStationHandle);
+
     //.@Leon 通过站点ID和TOKEN获取用户登录信息
     public FosterwxStation getAuthInfo(String token);
+
     //.@leon 加密小程序分享链接
-    public String makeBoxShareUrl(String boxShareUrl,String stationId,String stationName);
+    public String makeBoxShareUrl(String stationId, String stationName);
 }

+ 31 - 32
src/main/java/com/mokamrp/privates/service/pangu/impl/FosterwxStationServiceImpl.java

@@ -1,27 +1,25 @@
 package com.mokamrp.privates.service.pangu.impl;
 
 import com.alibaba.fastjson.JSON;
-import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.mokamrp.privates.constant.RedisKey;
+import com.mokamrp.privates.entity.PostBasePageHandle;
 import com.mokamrp.privates.entity.pangu.LoginStationHandle;
-import com.mokamrp.privates.mapper.pangu.pojo.FosterwxStation;
 import com.mokamrp.privates.mapper.pangu.FosterwxStationMapper;
+import com.mokamrp.privates.mapper.pangu.pojo.FosterwxStation;
 import com.mokamrp.privates.service.pangu.FosterwxStationService;
-import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.mokamrp.privates.utils.StringUtils;
 import com.mokamrp.privates.utils.sign.Base64;
 import com.mokamrp.privates.utils.sign.Md5Utils;
-import io.netty.util.internal.shaded.org.jctools.queues.MpscArrayQueue;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.data.redis.core.StringRedisTemplate;
 import org.springframework.stereotype.Service;
-import com.mokamrp.privates.entity.PostBasePageHandle;
-import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.beans.factory.annotation.Value;
 
-import java.nio.charset.StandardCharsets;
-import java.util.*;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
 
 /**
  * <p>
@@ -39,6 +37,7 @@ public class FosterwxStationServiceImpl extends ServiceImpl<FosterwxStationMappe
 
     @Autowired
     public StringRedisTemplate stringRedisTemplate;
+
     /**
      * 获取数据列表 支持分页
      * @param handle
@@ -60,30 +59,30 @@ public class FosterwxStationServiceImpl extends ServiceImpl<FosterwxStationMappe
      * @param loginStationHandle
      * @return
      */
-    public Map<String,Object>login(LoginStationHandle loginStationHandle){
+    public Map<String, Object> login(LoginStationHandle loginStationHandle) {
         FosterwxStation fosterwxStation = this.getOne(new QueryWrapper<FosterwxStation>()
 //                .eq("id",loginStationHandle.getStationId())
-                .eq("login_username",loginStationHandle.getUsername())
+                        .eq("login_username", loginStationHandle.getUsername())
         );
-        Map<String,Object> res = new HashMap<>();
-        res.put("msg","");
-        res.put("data","");
-        res.put("token","");
-        if (fosterwxStation == null){
-            res.put("msg","账户不存在");
+        Map<String, Object> res = new HashMap<>();
+        res.put("msg", "");
+        res.put("data", "");
+        res.put("token", "");
+        if (fosterwxStation == null) {
+            res.put("msg", "账户不存在");
             return res;
         }
-        if (!loginStationHandle.getPassword().equals(fosterwxStation.getLoginPassword())){
-            res.put("msg","密码不正确");
+        if (!loginStationHandle.getPassword().equals(fosterwxStation.getLoginPassword())) {
+            res.put("msg", "密码不正确");
             return res;
         }
         String token = Md5Utils.hash(loginStationHandle.getUsername()) + StringUtils.getRandomString(6);
         fosterwxStation.setLoginPassword("*********");
-        res.put("data",fosterwxStation);
-        res.put("msg","登录成功");
-        res.put("token",token);
+        res.put("data", fosterwxStation);
+        res.put("msg", "登录成功");
+        res.put("token", token);
         String jsonStr = JSON.toJSONString(fosterwxStation);
-        stringRedisTemplate.opsForValue().set(RedisKey.PanStationToken+token,jsonStr);
+        stringRedisTemplate.opsForValue().set(RedisKey.PanStationToken + token, jsonStr);
         return res;
     }
 
@@ -92,12 +91,12 @@ public class FosterwxStationServiceImpl extends ServiceImpl<FosterwxStationMappe
      * @param token
      * @return
      */
-    public FosterwxStation getAuthInfo(String token){
-        String jsonStr = stringRedisTemplate.opsForValue().get(RedisKey.PanStationToken+token);
-        if (jsonStr == null || jsonStr.isEmpty()){
+    public FosterwxStation getAuthInfo(String token) {
+        String jsonStr = stringRedisTemplate.opsForValue().get(RedisKey.PanStationToken + token);
+        if (jsonStr == null || jsonStr.isEmpty()) {
             return null;
         }
-        FosterwxStation fosterwxStation = JSON.parseObject(jsonStr,FosterwxStation.class);
+        FosterwxStation fosterwxStation = JSON.parseObject(jsonStr, FosterwxStation.class);
         return fosterwxStation;
     }
 
@@ -107,10 +106,10 @@ public class FosterwxStationServiceImpl extends ServiceImpl<FosterwxStationMappe
      * @param stationId
      * @return
      */
-    public String makeBoxShareUrl(String boxShareUrl,String stationId,String stationName){
-        String key = StringUtils.getRandomString(10)+stationId+StringUtils.getRandomString(5);
+    public String makeBoxShareUrl(String stationId, String stationName) {
+        String key = StringUtils.getRandomString(10) + stationId + "-" + stationName + StringUtils.getRandomString(5);
         byte[] keyB = key.getBytes();
-        String newBoxShareUrl = boxShareUrl + "?station="+ Base64.encode(keyB)+"&stationName="+Base64.encode(stationName.getBytes(StandardCharsets.UTF_8));
-        return newBoxShareUrl;
+        // String newBoxShareUrl = boxShareUrl + "?station=" + Base64.encode(keyB) + "&stationName=" + Base64.encode(stationName.getBytes(StandardCharsets.UTF_8));
+        return Base64.encode(keyB);
     }
 }