guoshilong
2023-06-20 e95a5d39eabc286c574e39dea14377fcd159051b
skjcmanager/skjcmanager-service/skjcmanager-sm/src/main/java/cn/gistack/sm/appmanage/controller/AppManageController.java
@@ -1,7 +1,9 @@
package cn.gistack.sm.appmanage.controller;
import cn.gistack.common.utils.WxUtils;
import cn.gistack.sm.appmanage.entity.AppManage;
import cn.gistack.sm.appmanage.service.IAppManageService;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.metadata.IPage;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
@@ -11,6 +13,10 @@
import org.springblade.core.mp.support.Query;
import org.springblade.core.tool.api.R;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.client.RestTemplate;
import java.util.LinkedHashMap;
import java.util.Map;
/**
 * @ClassName app管理
@@ -89,4 +95,50 @@
      return R.data(appManage);
   }
   /**
    * 获取微信小程序跳转链接
    *
    * @return
    */
   @ApiOperation(value = "app管理-获取微信小程序跳转链接", notes = "app管理-获取微信小程序跳转链接")
   @GetMapping(value = "/getMiniProgramPath")
   public R getMiniProgramPath(){
      String wxAccessToken = WxUtils.getWxAccessToken();
      String url = WxUtils.WX_GET_GENERATESCHEME+"?access_token="+wxAccessToken;
      RestTemplate template = new RestTemplate();
      Map<String, Object> params = new LinkedHashMap<>();
      /**
       * {
       *     "jump_wxa":
       *     {
       *         "path": "/pages/publishHomework/publishHomework",
       *         "query": "",
       *         "env_version": "release"
       *     },
       *     "is_expire":true,
       *     "expire_type":1,
       *     "expire_interval":1
       * }
       */
      JSONObject jump_wxa = new JSONObject();
      jump_wxa.put("path","/pages/home/index");
      jump_wxa.put("query","");
      jump_wxa.put("env_version","release");
      params.put("jump_wxa",jump_wxa);
      params.put("is_expire",true);
      params.put("expire_type",1);
      params.put("expire_interval",1);
      String result = template.postForObject(url, params, String.class);
      JSONObject resultObj = (JSONObject)JSONObject.parse(result);
      String openLink = resultObj.getString("openlink");
      return R.data(openLink);
   }
}