Commit 0e67b117 authored by 唐峰's avatar 唐峰

Merge branch 'feature-migration-20230628' of...

Merge branch 'feature-migration-20230628' of git.quantgroup.cn:head_group/xyqb-user2 into feature-migration-20230628
parents 23fed51a de79c554
......@@ -3,6 +3,10 @@ package cn.quantgroup.xyqb.aspect.logcaller;
import cn.quantgroup.xyqb.util.IpUtil;
import com.alibaba.fastjson.JSON;
import com.google.common.base.Stopwatch;
import java.io.Serializable;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;
import lombok.extern.slf4j.Slf4j;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
......@@ -51,8 +55,10 @@ public class LogCallHttpAspect {
long elapsed = stopwatch.stop().elapsed(TimeUnit.MILLISECONDS);
String resultStr = result == null ? "" : JSON.toJSONString(result);
resultStr = resultStr.length() < 500 ? resultStr : resultStr.substring(0, 500);
log.info("[httpRequestLog],url:[{}],duration:[{}],[耗时区间]{},remoteIP:[{}],exception:[{}],result:[{}]",
request.getRequestURL(), elapsed, slowlyTag(elapsed), remoteIP, hasException, resultStr);
List<Object> argList = Arrays.stream(args).filter(arg -> arg instanceof Serializable)
.collect(Collectors.toList());
log.info("[httpRequestLog],url:[{}],duration:[{}],[耗时区间]{},remoteIP:[{}],args:[{}],exception:[{}],result:[{}]",
request.getRequestURL(), elapsed, slowlyTag(elapsed), remoteIP, JSON.toJSONString(argList), hasException, resultStr);
}
return result;
}
......
......@@ -572,7 +572,7 @@ public class UserController implements IBaseController {
}
}
User user = sessionStruct.getValues().getUser();
if (user.getTenantId() == null || !user.getEnable().equals(tenantId)) {
if (user.getTenantId() == null || !user.getEnable()) {
log.info("当前token对应的用户非当前租户,userId:{},用户tenantId:{},入参tenantId:{},token:{}", user.getId(), user.getTenantId(), tenantId, token);
return JsonResult.buildSuccessResult(null, result);
}
......@@ -609,7 +609,7 @@ public class UserController implements IBaseController {
return JsonResult.buildSuccessResult(null, tokenExchange);
}
User user = sessionStruct.getValues().getUser();
if (user.getTenantId() == null || !user.getEnable().equals(tenantId)) {
if (user.getTenantId() == null || !user.getEnable()) {
log.info("当前token对应的用户非当前租户,userId:{},用户tenantId:{},入参tenantId:{},token:{}", user.getId(), user.getTenantId(), tenantId, token);
return JsonResult.buildSuccessResult(null, tokenExchange);
}
......
......@@ -4,6 +4,7 @@ import cn.quantgroup.xyqb.entity.User;
import cn.quantgroup.xyqb.entity.WechatUserInfo;
import cn.quantgroup.xyqb.repository.IUserRepository;
import cn.quantgroup.xyqb.repository.IWeChatUserRepository;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationListener;
......@@ -31,11 +32,13 @@ public class WechatBindingEventListener implements ApplicationListener<UserLogin
public void onApplicationEvent(UserLoginEvent userLoginEvent) {
if (userLoginEvent.getUserTag() != null) {
User user = userRepository.findByIdAndTenantId(userLoginEvent.getUserTag().getUserId(), userLoginEvent.getUserTag().getTenantId());
if (StringUtils.isNotEmpty(user.getPhoneNo())) {
if (user != null && StringUtils.isNotEmpty(user.getPhoneNo())) {
List<WechatUserInfo> wechatUserInfoList = weChatUserRepository.findByPhoneNoAndTenantId(user.getPhoneNo(), user.getTenantId());
wechatUserInfoList.forEach(i -> i.setUserId(user.getId()));
if (CollectionUtils.isNotEmpty(wechatUserInfoList)) {
weChatUserRepository.save(wechatUserInfoList);
}
}
}
}
......
package cn.quantgroup.xyqb.service.middleoffice.applet.impl;
import cn.quantgroup.xyqb.constant.UserConstant;
import cn.quantgroup.xyqb.controller.middleoffice.login.ILoginModule;
import cn.quantgroup.xyqb.controller.middleoffice.login.LoginVo;
import cn.quantgroup.xyqb.entity.User;
......@@ -54,6 +55,9 @@ public class AppletServiceImpl implements IAppletService {
public Long relevance(AppletParamEntry appletParamEntry) {
WechatUserInfo wechatUserInfo = iWeChatUserRepository.findByOpenIdAndAppNameAndAppIdAndTenantId(appletParamEntry.getOpenId(), appletParamEntry.getAppName(), appletParamEntry.getAppId(), appletParamEntry.getTenantId());
//这个接口先不考虑更换手机号的情况
if(appletParamEntry.getTenantId()==null){
appletParamEntry.setTenantId(UserConstant.defaultTenantId);
}
wechatUserInfo = (wechatUserInfo == null ? new WechatUserInfo() : wechatUserInfo);
wechatUserInfo.setNickName(appletParamEntry.getNickName());
......@@ -69,6 +73,7 @@ public class AppletServiceImpl implements IAppletService {
wechatUserInfo.setPhoneNo(appletParamEntry.getMobile());
wechatUserInfo.setEncryptedPhoneNo(appletParamEntry.getMobile());
wechatUserInfo.setUtmSource(appletParamEntry.getUtmSource());
wechatUserInfo.setTenantId(appletParamEntry.getTenantId());
if (null == wechatUserInfo.getUserId()) {//只要存在userid 就说明已经在用户表里了 不考虑小程序这边换手机号了
User user = userService.findByPhoneInDb(appletParamEntry.getMobile(), appletParamEntry.getTenantId());
//如果不存在就去注册一下
......
......@@ -140,6 +140,10 @@ public class WechatServiceImpl implements IWechatService {
@Override
@Transactional(rollbackFor = Exception.class)
public WechatUserInfo saveWechatUserInfo(WechatUserInfo userInfo) {
if(userInfo.getTenantId()==null){
userInfo.setTenantId(UserConstant.defaultTenantId);
}
log.info("微信信息保存开始:{}", JSON.toJSONString(userInfo));
if (Objects.isNull(userInfo) || Objects.isNull(userInfo.getOpenId())) {
return null;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment