| @@ -77,8 +77,10 @@ public class BaseController { | |||||
| return id; | return id; | ||||
| } | } | ||||
| public WxMerchantBUser getLoginBUser() { | |||||
| Long userId = getMerchantBUserId(); | |||||
| private WxMerchantBUser getWxMerchantBUser(Long userId) { | |||||
| if (null == userId) { | |||||
| throw new MallinkException(ErrorCode.USER_IS_EMPTY.getCode(),"当前用户登陆信息已失效,请重新登陆."); | |||||
| } | |||||
| WxMerchantBUser user = wxMerchantBUserService.getById(userId); | WxMerchantBUser user = wxMerchantBUserService.getById(userId); | ||||
| if (user == null) { | if (user == null) { | ||||
| throw new MallinkException(ErrorCode.USER_IS_EMPTY.getCode(),"BUser[id:"+userId+"]未查询到WxMerchantBUser。请联系管理员或者重新登陆."); | throw new MallinkException(ErrorCode.USER_IS_EMPTY.getCode(),"BUser[id:"+userId+"]未查询到WxMerchantBUser。请联系管理员或者重新登陆."); | ||||
| @@ -86,6 +88,19 @@ public class BaseController { | |||||
| return user; | return user; | ||||
| } | } | ||||
| //该方法兼容微信登陆和非微信登陆 | |||||
| public WxMerchantBUser getLoginBUser() { | |||||
| Long wxBuserId = getWxBuserId(); | |||||
| if (null != wxBuserId) { | |||||
| WxBuser buser = getWxBuser(); | |||||
| Long userId = buser.getUserId(); | |||||
| return getWxMerchantBUser(userId); | |||||
| }else { | |||||
| Long userId = getMerchantBUserId(); | |||||
| return getWxMerchantBUser(userId); | |||||
| } | |||||
| } | |||||
| public Long getWxBuserId() { | public Long getWxBuserId() { | ||||
| HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest(); | HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest(); | ||||
| Long id = (Long) request.getAttribute(Constant.LOGIN_USER_KEY); | Long id = (Long) request.getAttribute(Constant.LOGIN_USER_KEY); | ||||