| | |
| | | import com.dsh.other.util.TokenUtil; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import org.apache.commons.lang3.StringUtils; |
| | | import org.springframework.web.bind.annotation.GetMapping; |
| | | import org.springframework.web.bind.annotation.PathVariable; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | |
| | | @Autowired private QrLinkMapper qrLinkMapper; |
| | | @Autowired private TokenUtil tokenUtil; |
| | | |
| | | @GetMapping("/q/{shortCode}") |
| | | public void guidePage(@PathVariable String shortCode, HttpServletRequest request, |
| | | HttpServletResponse response) throws IOException { |
| | | // 仅重定向到静态 H5;避免 String 被 MVC 当作视图名并触发 LocaleResolver。 |
| | | String code = shortCode.replaceAll("[^A-Za-z0-9]", ""); |
| | | response.sendRedirect(request.getContextPath() + "/app-guide.html?code=" + code); |
| | | } |
| | | // @GetMapping("/q/{shortCode}") |
| | | // public void guidePage(@PathVariable String shortCode, HttpServletRequest request, |
| | | // HttpServletResponse response) throws IOException { |
| | | // // 仅重定向到静态 H5;避免 String 被 MVC 当作视图名并触发 LocaleResolver。 |
| | | // String code = shortCode.replaceAll("[^A-Za-z0-9]", ""); |
| | | // response.sendRedirect(request.getContextPath() + "/app-guide.html?code=" + code); |
| | | // } |
| | | |
| | | @GetMapping("/public/app-guide/config") |
| | | @RequestMapping("/public/app-guide/config") |
| | | @ApiOperation("获取下载引导页配置(无需登录)") |
| | | public ResultUtil<Map<String, Object>> guideConfig(String code) { |
| | | AppGuideConfig config = appGuideConfigMapper.selectOne(new QueryWrapper<AppGuideConfig>() |
| | |
| | | QrLink link = validLink(code); |
| | | if (code != null && !code.isEmpty() && link == null) return ResultUtil.error("二维码无效或已失效"); |
| | | Map<String, Object> data = new HashMap<>(); |
| | | data.put("appName", config.getAppName()); |
| | | data.put("appScheme", config.getAppScheme()); |
| | | data.put("androidPackage", config.getAndroidPackage()); |
| | | data.put("appName", StringUtils.isNotBlank(config.getAppName()) ? config.getAppName() : "玩湃生活"); |
| | | data.put("androidPackage", StringUtils.isNotBlank(config.getAndroidPackage()) ? config.getAndroidPackage() : "com.sinata.wepark"); |
| | | data.put("iosPackage", StringUtils.isNotBlank(config.getIosPackage()) ? config.getIosPackage() : "com.sinata.WeParkLife"); |
| | | data.put("iosStoreUrl", config.getIosStoreUrl()); |
| | | data.put("androidDefaultUrl", config.getAndroidDefaultUrl()); |
| | | data.put("apkUrl", config.getApkUrl()); |
| | | data.put("androidMarketUrls", parseJson(config.getAndroidMarketUrls())); |
| | | data.put("androidDeepLink", config.getAndroidDeepLink() + (StringUtils.isNotBlank(code) ? "?route=" + code : "")); |
| | | data.put("iosDeepLink", "weparklife://app" + (StringUtils.isNotBlank(code) ? "?code=" + code : "")); |
| | | data.put("banners", appGuideBannerMapper.selectList(new QueryWrapper<AppGuideBanner>() |
| | | .eq("enabled", EnableStatusEnum.ENABLED.getCode()).orderByAsc("sort").orderByDesc("id"))); |
| | | if (link != null) data.put("target", target(link)); |
| | | // if (link != null) data.put("target", target(link)); |
| | | return ResultUtil.success(data); |
| | | } |
| | | |
| | | @GetMapping("/api/qr/resolve") |
| | | @RequestMapping("/api/qr/resolve") |
| | | @ApiOperation("App扫码解析二维码") |
| | | public ResultUtil<Map<String, Object>> resolve(String code) { |
| | | try { |
| | | if (tokenUtil.getUserIdFormRedis() == null) return ResultUtil.tokenErr(); |
| | | } catch (Exception e) { |
| | | return ResultUtil.tokenErr(); |
| | | } |
| | | QrLink link = validLink(code); |
| | | if (link == null) return ResultUtil.error("二维码无效或已失效"); |
| | | return ResultUtil.success(target(link)); |
| | |
| | | |
| | | private Map<String, Object> target(QrLink link) { |
| | | Map<String, Object> target = new HashMap<>(); |
| | | target.put("type", link.getType()); |
| | | target.put("storeId", link.getStoreId()); |
| | | target.put("siteId", link.getSiteId()); |
| | | target.put("bookingId", link.getBookingId()); |
| | | target.put("route", QrLinkTypeEnum.SITE_BOOKING.getCode().equals(link.getType()) ? "/pages/site/booking" : "/pages/site/my-booking"); |
| | | target.put("pageName", link.getPageName()); |
| | | Map<String, Object> params = new HashMap<>(); |
| | | params.put("id", link.getSiteId().toString()); |
| | | target.put("params", JSON.toJSONString(params)); |
| | | return target; |
| | | } |
| | | |