SpringBoot中使用OpenFeign請求參數爲JSON時小操作

最近在對接QQ小程序接口時使用了下OpenFeign,小記以下,以備下次Copy。

@FeignClient(name = "qqFeign",url = "${request.url.qq}")
public interface QqFeign {

    /**
     *  換取openid
     * @param appid
     * @param secret
     * @param js_code
     * @param grant_type
     * @return
     */
    @ResponseBody
    @GetMapping("/sns/jscode2session")
    String getOpenid(@RequestParam(value = "appid") String appid,
                     @RequestParam(value = "secret") String secret,
                     @RequestParam(value = "js_code") String js_code,
                     @RequestParam(value = "grant_type") String grant_type);

    /**
     * 獲取接口調用憑證 Token
     * @param appid         appid
     * @param secret        密鑰
     * @param grant_type
     * @return {"access_token": "ACCESS_TOKEN", "expires_in": 7200}
     */
    @ResponseBody
    @GetMapping("/api/getToken")
    String getToken(@RequestParam(value = "appid") String appid,
                    @RequestParam(value = "secret") String secret,
                    @RequestParam(value = "grant_type") String grant_type);


    /**
     *  生成小程序二維碼
     * @param params
     * @return
     */
    @ResponseBody
    @RequestMapping(value = "/api/json/qqa/CreateMiniCode",method = RequestMethod.POST,headers = {"content-type=application/json"})
    String CreateMiniCode(String params);

}

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章