| | |
| | | |
| | | import com.ruoyi.common.utils.WechatUtils; |
| | | import com.ruoyi.common.utils.StringUtils; |
| | | import com.ruoyi.common.config.WechatMpConfig; |
| | | import com.alibaba.fastjson2.JSONObject; |
| | | import com.ruoyi.system.domain.EvaluationDetail; |
| | | import com.ruoyi.system.service.IEvaluationDimensionService; |
| | | import com.ruoyi.system.domain.EvaluationDimension; |
| | | import org.springframework.security.access.prepost.PreAuthorize; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.beans.factory.annotation.Value; |
| | | import org.springframework.web.bind.annotation.GetMapping; |
| | | import org.springframework.web.bind.annotation.PostMapping; |
| | | import org.springframework.web.bind.annotation.PutMapping; |
| | |
| | | |
| | | @Autowired |
| | | private IEvaluationDimensionService evaluationDimensionService; |
| | | |
| | | @Autowired |
| | | private WechatMpConfig wechatMpConfig; |
| | | |
| | | /** |
| | | * 查询客户评价列表 |
| | |
| | | } |
| | | } |
| | | |
| | | @Value("${wechat.appId}") |
| | | private String wechatAppId; |
| | | |
| | | @Value("${wechat.appSecret}") |
| | | private String wechatAppSecret; |
| | | |
| | | /** |
| | | * 生成微信授权URL |
| | | */ |
| | |
| | | logger.info("生成微信授权URL - 原始redirectUri: {}", redirectUri); |
| | | |
| | | // 生成微信授权URL,使用snsapi_userinfo获取用户信息 |
| | | String authUrl = WechatUtils.generateAuthUrl(wechatAppId, redirectUri, "snsapi_userinfo", state); |
| | | String authUrl = WechatUtils.generateAuthUrl( |
| | | wechatMpConfig.getAppId(), |
| | | redirectUri, |
| | | "snsapi_userinfo", |
| | | state |
| | | ); |
| | | if (authUrl == null) { |
| | | return error("生成微信授权URL失败"); |
| | | } |
| | |
| | | Map<String, String> result = new HashMap<>(); |
| | | result.put("authUrl", authUrl); |
| | | result.put("originalRedirectUri", redirectUri); |
| | | result.put("appId", wechatAppId); |
| | | result.put("appId", wechatMpConfig.getAppId()); |
| | | return success(result); |
| | | } catch (Exception e) { |
| | | logger.error("生成微信授权URL失败", e); |
| | |
| | | } |
| | | |
| | | // 获取网页授权Access Token |
| | | JSONObject tokenInfo = WechatUtils.getWebAccessToken(wechatAppId, wechatAppSecret, code); |
| | | JSONObject tokenInfo = WechatUtils.getWebAccessToken( |
| | | wechatMpConfig.getAppId(), |
| | | wechatMpConfig.getAppSecret(), |
| | | code |
| | | ); |
| | | if (tokenInfo == null) { |
| | | return error("获取微信授权信息失败"); |
| | | } |