|
|
@@ -1,13 +1,13 @@
|
|
|
package shop.alien.store.controller;
|
|
|
|
|
|
import io.swagger.annotations.Api;
|
|
|
-import io.swagger.annotations.ApiImplicitParam;
|
|
|
-import io.swagger.annotations.ApiImplicitParams;
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
import lombok.RequiredArgsConstructor;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
+import org.springframework.util.StringUtils;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
import shop.alien.entity.result.R;
|
|
|
+import shop.alien.store.dto.WxJsSdkConfigRequest;
|
|
|
import shop.alien.store.dto.WxJsSdkConfigVo;
|
|
|
import shop.alien.store.service.WxJsSdkService;
|
|
|
|
|
|
@@ -24,13 +24,14 @@ public class WxJsSdkController {
|
|
|
|
|
|
private final WxJsSdkService wxJsSdkService;
|
|
|
|
|
|
- @ApiOperation("获取微信 JS-SDK 签名参数(前端 wx.config 使用)")
|
|
|
- @ApiImplicitParams({
|
|
|
- @ApiImplicitParam(name = "url", value = "当前 H5 页面完整 URL(不含 # 及后面部分,需与前端 location.href 处理后一致)",
|
|
|
- dataType = "String", paramType = "query", required = true)
|
|
|
- })
|
|
|
- @GetMapping("/getWxConfig")
|
|
|
- public R<WxJsSdkConfigVo> getWxConfig(@RequestParam String url) {
|
|
|
+ @ApiOperation(value = "获取微信 JS-SDK 签名参数(前端 wx.config 使用)",
|
|
|
+ notes = "url 放在请求体,避免 GET query 过长导致 413")
|
|
|
+ @PostMapping("/getWxConfig")
|
|
|
+ public R<WxJsSdkConfigVo> getWxConfig(@RequestBody WxJsSdkConfigRequest request) {
|
|
|
+ if (request == null || !StringUtils.hasText(request.getUrl())) {
|
|
|
+ return R.fail("url 不能为空");
|
|
|
+ }
|
|
|
+ String url = request.getUrl().trim();
|
|
|
log.info("WxJsSdkController.getWxConfig url={}", url);
|
|
|
return R.data(wxJsSdkService.buildJsSdkConfig(url));
|
|
|
}
|