From 48a703dec596b5d2c1b04b0b4f7ed0f28c1ca898 Mon Sep 17 00:00:00 2001 From: lidongdong <1459917685@qq.com> Date: 星期一, 13 十一月 2023 18:00:50 +0800 Subject: [PATCH] 新增社区共建评论模块2 --- springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/controller/BaseController.java | 55 +++++++++++++++++++++++++++++++++++++++++++++---------- 1 files changed, 45 insertions(+), 10 deletions(-) diff --git a/springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/controller/BaseController.java b/springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/controller/BaseController.java index c6f6fc5..3d844a2 100644 --- a/springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/controller/BaseController.java +++ b/springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/controller/BaseController.java @@ -1,6 +1,7 @@ package com.panzhihua.common.controller; import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; import com.panzhihua.common.model.vos.community.ComActVO; import com.panzhihua.common.utlis.StringUtils; @@ -18,6 +19,9 @@ import lombok.SneakyThrows; import lombok.extern.slf4j.Slf4j; + +import static java.util.Objects.isNull; +import static org.apache.commons.lang3.StringUtils.isBlank; /** * @program: springcloud_k8s_panzhihuazhihuishequ @@ -43,6 +47,14 @@ return ((ServletRequestAttributes)RequestContextHolder.getRequestAttributes()).getRequest(); } + + /** + * 获取request对象 + */ + public HttpServletResponse getResponse() { + return ((ServletRequestAttributes)RequestContextHolder.getRequestAttributes()).getResponse(); + } + /** * 获取登录对象信息 * @@ -62,9 +74,9 @@ public Long getCommunityId() { LoginUserInfoVO loginUserInfo = this.getLoginUserInfo(); Long communityId = loginUserInfo.getCommunityId(); - if (null == communityId || 0 == communityId) { - throw new ServiceException("用户未绑定社区"); - } +// if (null == communityId) { +// throw new ServiceException("用户未绑定社区"); +// } return communityId; } @@ -99,15 +111,26 @@ /** * 获取登录对象所在区域编码 * - * @return 小区id + * @return */ public String getAreaCode() { - LoginUserInfoVO loginUserInfo = this.getLoginUserInfo(); - ComActVO comActVO = loginUserInfo.getComActVO(); - if (comActVO==null) { - return "510423"; - } - else { + String appid = this.getRequest().getHeader("appid"); + if(StringUtils.isNotEmpty(appid)){ + if(appid.equals("wx08932ba29546ff82")){ + return "510411"; + } + else if(appid.equals("wx50d8c395af50481b")){ + return "510402"; + } + else { + return "510423"; + } + } else { + LoginUserInfoVO loginUserInfoVO=this.getLoginUserInfo(); + ComActVO comActVO=loginUserInfoVO.getComActVO(); + if(isNull(comActVO) || isBlank(comActVO.getAreaCode())){ + return "510423"; + } return comActVO.getAreaCode(); } } @@ -124,6 +147,18 @@ return header; } + public String getAppId(){ + String appid = this.getRequest().getHeader("appid"); + if(StringUtils.isEmpty(appid)){ + return "wx0cef797390444b75"; + } + return appid; + } + + public String getAppSecret(){ + LoginUserInfoVO loginUserInfo = this.getLoginUserInfo(); + return loginUserInfo.getAppSecret(); + } /** * 获取登录对象所有信息 * -- Gitblit v1.7.1