From 70fce1b0c19fc1445d8b5fd0fa3bf15b410241cb Mon Sep 17 00:00:00 2001 From: hurui <177768073@qq.com> Date: Mon, 29 Apr 2024 09:46:59 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8F=90=E4=BA=A4=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/cweb/controller/tPigController.java | 22 ++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/hai-cweb/src/main/java/com/cweb/controller/tPigController.java b/hai-cweb/src/main/java/com/cweb/controller/tPigController.java index 16a9d75e..5c0d6a21 100644 --- a/hai-cweb/src/main/java/com/cweb/controller/tPigController.java +++ b/hai-cweb/src/main/java/com/cweb/controller/tPigController.java @@ -2,13 +2,18 @@ package com.cweb.controller; import com.alibaba.fastjson.JSONObject; +import com.hai.common.exception.ErrorCode; +import com.hai.common.exception.ErrorHelp; +import com.hai.common.exception.SysCode; import com.hai.common.security.UserCenter; import com.hai.common.utils.ResponseMsgUtil; import com.hai.config.CommonSysConst; import com.hai.config.QianZhuConfig; import com.hai.entity.HighUser; +import com.hai.model.HighUserModel; import com.hai.model.ResponseData; +import com.hai.model.UserInfoModel; import com.hai.service.HighUserService; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; @@ -56,15 +61,26 @@ public class tPigController { @RequestMapping(value = "/getTPigCinemaToken", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "【小程序】电影票获取千猪Token") - public ResponseData getTPigCinemaToken(@RequestParam(name = "userId", required = true) Long userId) { + public ResponseData queryCinemaUrl() { try { - HighUser highUser = highUserService.findByUserId(userId); + HighUserModel sessionModel = userCenter.getSessionModel(HighUserModel.class); + if (sessionModel == null) { + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMPETENCE_INSUFFICIENT, ""); + } + // 查询用户 + HighUser user = sessionModel.getHighUser(); + if (user == null || sessionModel.getHighUser() == null) { + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMPETENCE_INSUFFICIENT, ""); + } - JSONObject token = QianZhuConfig.getToken(highUser.getId().toString() , highUser.getName() , highUser.getPhone()); + // 获取token + JSONObject token = QianZhuConfig.getToken(""+user.getId() , user.getName() , user.getPhone()); String url = ""; if (token.getBoolean("success")) { JSONObject data = token.getJSONObject("data"); url = CommonSysConst.getSysConfig().getQinzhuHtmlUrl()+"/cinema/?platformId="+CommonSysConst.getSysConfig().getQinzhuPlatformId()+"&token="+data.getString("accessToken"); + } else { + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "获取地址失败"); } return ResponseMsgUtil.success(url); } catch (Exception e) {