Browse Source

登录日志新增字段

master
zxc 3 years ago
parent
commit
48f6175487
  1. 17
      epmet-auth/src/main/java/com/epmet/service/impl/ThirdLoginServiceImpl.java

17
epmet-auth/src/main/java/com/epmet/service/impl/ThirdLoginServiceImpl.java

@ -12,6 +12,7 @@ import com.epmet.commons.rocketmq.messages.LoginMQMsg;
import com.epmet.commons.tools.constant.AppClientConstant; import com.epmet.commons.tools.constant.AppClientConstant;
import com.epmet.commons.tools.constant.ServiceConstant; import com.epmet.commons.tools.constant.ServiceConstant;
import com.epmet.commons.tools.constant.StrConstant; import com.epmet.commons.tools.constant.StrConstant;
import com.epmet.commons.tools.dto.result.CustomerStaffInfoCacheResult;
import com.epmet.commons.tools.enums.EnvEnum; import com.epmet.commons.tools.enums.EnvEnum;
import com.epmet.commons.tools.exception.EpmetErrorCode; import com.epmet.commons.tools.exception.EpmetErrorCode;
import com.epmet.commons.tools.exception.EpmetException; import com.epmet.commons.tools.exception.EpmetException;
@ -19,6 +20,7 @@ import com.epmet.commons.tools.exception.ExceptionUtils;
import com.epmet.commons.tools.exception.RenException; import com.epmet.commons.tools.exception.RenException;
import com.epmet.commons.tools.feign.ResultDataResolver; import com.epmet.commons.tools.feign.ResultDataResolver;
import com.epmet.commons.tools.redis.common.CustomerDingDingRedis; import com.epmet.commons.tools.redis.common.CustomerDingDingRedis;
import com.epmet.commons.tools.redis.common.CustomerStaffRedis;
import com.epmet.commons.tools.redis.common.bean.DingMiniInfoCache; import com.epmet.commons.tools.redis.common.bean.DingMiniInfoCache;
import com.epmet.commons.tools.security.dto.GovTokenDto; import com.epmet.commons.tools.security.dto.GovTokenDto;
import com.epmet.commons.tools.security.dto.TokenDto; import com.epmet.commons.tools.security.dto.TokenDto;
@ -208,7 +210,7 @@ public class ThirdLoginServiceImpl implements ThirdLoginService, ResultDataResol
//7.发送登录事件 //7.发送登录事件
try { try {
sendLoginEvent(staffLatestAgencyResultDTO.getStaffId(), formDTO.getAppId(), AppClientConstant.APP_GOV, AppClientConstant.CLIENT_WXMP); sendLoginEvent(staffLatestAgencyResultDTO.getStaffId(), formDTO.getAppId(), AppClientConstant.APP_GOV, AppClientConstant.CLIENT_WXMP,userWechatDTO.getCustomerId());
} catch (RenException e) { } catch (RenException e) {
log.error(e.getInternalMsg()); log.error(e.getInternalMsg());
} catch (Exception e) { } catch (Exception e) {
@ -439,7 +441,7 @@ public class ThirdLoginServiceImpl implements ThirdLoginService, ResultDataResol
//6.发送登录事件 //6.发送登录事件
try { try {
sendLoginEvent(customerStaff.getUserId(), formDTO.getAppId(), AppClientConstant.APP_GOV, AppClientConstant.CLIENT_WXMP); sendLoginEvent(customerStaff.getUserId(), formDTO.getAppId(), AppClientConstant.APP_GOV, AppClientConstant.CLIENT_WXMP, formDTO.getCustomerId());
} catch (RenException e) { } catch (RenException e) {
log.error(e.getInternalMsg()); log.error(e.getInternalMsg());
} catch (Exception e) { } catch (Exception e) {
@ -501,7 +503,7 @@ public class ThirdLoginServiceImpl implements ThirdLoginService, ResultDataResol
//6.发送登录事件 //6.发送登录事件
try { try {
sendLoginEvent(customerStaff.getUserId(), formDTO.getAppId(), AppClientConstant.APP_GOV, AppClientConstant.CLIENT_WXMP); sendLoginEvent(customerStaff.getUserId(), formDTO.getAppId(), AppClientConstant.APP_GOV, AppClientConstant.CLIENT_WXMP, formDTO.getCustomerId());
} catch (RenException e) { } catch (RenException e) {
log.error(e.getInternalMsg()); log.error(e.getInternalMsg());
} catch (Exception e) { } catch (Exception e) {
@ -820,7 +822,7 @@ public class ThirdLoginServiceImpl implements ThirdLoginService, ResultDataResol
* @author wxz * @author wxz
* @date 2021.06.08 15:27 * @date 2021.06.08 15:27
*/ */
private void sendLoginEvent(String userId, String appId, String fromApp, String fromClient) { private void sendLoginEvent(String userId, String appId, String fromApp, String fromClient,String customerId) {
HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest(); HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
LoginMQMsg loginMQMsg = new LoginMQMsg(); LoginMQMsg loginMQMsg = new LoginMQMsg();
@ -830,7 +832,12 @@ public class ThirdLoginServiceImpl implements ThirdLoginService, ResultDataResol
loginMQMsg.setIp(IpUtils.getIpAddr(request)); loginMQMsg.setIp(IpUtils.getIpAddr(request));
loginMQMsg.setFromApp(fromApp); loginMQMsg.setFromApp(fromApp);
loginMQMsg.setFromClient(fromClient); loginMQMsg.setFromClient(fromClient);
CustomerStaffInfoCacheResult staffInfo = CustomerStaffRedis.getStaffInfo(customerId, userId);
if (null == staffInfo){
throw new EpmetException("未查询到工作人员信息:"+userId);
}
loginMQMsg.setOrgId(staffInfo.getAgencyId());
loginMQMsg.setOrgIdPath(StringUtils.isBlank(staffInfo.getAgencyPIds()) ? staffInfo.getAgencyId() : staffInfo.getAgencyPIds().concat(":").concat(staffInfo.getAgencyId()));
SystemMsgFormDTO form = new SystemMsgFormDTO(); SystemMsgFormDTO form = new SystemMsgFormDTO();
form.setMessageType(AuthOperationConstants.LOGIN); form.setMessageType(AuthOperationConstants.LOGIN);
form.setContent(loginMQMsg); form.setContent(loginMQMsg);

Loading…
Cancel
Save