[PROD]-修改用户版本号更新逻辑
This commit is contained in:
@@ -24,6 +24,10 @@ public class DeviceInfo {
|
||||
private String mcc;
|
||||
private String lang;
|
||||
|
||||
private Long uid;
|
||||
|
||||
private String clientIp;
|
||||
|
||||
public String getClient() {
|
||||
return client;
|
||||
}
|
||||
@@ -176,6 +180,22 @@ public class DeviceInfo {
|
||||
this.lang = lang;
|
||||
}
|
||||
|
||||
public Long getUid() {
|
||||
return uid;
|
||||
}
|
||||
|
||||
public void setUid(Long uid) {
|
||||
this.uid = uid;
|
||||
}
|
||||
|
||||
public String getClientIp() {
|
||||
return clientIp;
|
||||
}
|
||||
|
||||
public void setClientIp(String clientIp) {
|
||||
this.clientIp = clientIp;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "DeviceInfo{" +
|
||||
@@ -190,6 +210,16 @@ public class DeviceInfo {
|
||||
", deviceId='" + deviceId + '\'' +
|
||||
", channel='" + channel + '\'' +
|
||||
", linkedmeChannel='" + linkedmeChannel + '\'' +
|
||||
", idfa='" + idfa + '\'' +
|
||||
", oaid='" + oaid + '\'' +
|
||||
", oaidMd5='" + oaidMd5 + '\'' +
|
||||
", androidId='" + androidId + '\'' +
|
||||
", client='" + client + '\'' +
|
||||
", adid='" + adid + '\'' +
|
||||
", mcc='" + mcc + '\'' +
|
||||
", lang='" + lang + '\'' +
|
||||
", uid=" + uid +
|
||||
", clientIp='" + clientIp + '\'' +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
|
@@ -1,7 +1,9 @@
|
||||
package com.accompany.core.base;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.accompany.common.constant.ApplicationConstant;
|
||||
import com.accompany.common.device.DeviceInfo;
|
||||
import com.accompany.common.utils.IPUtils;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.web.context.request.RequestContextHolder;
|
||||
import org.springframework.web.context.request.ServletRequestAttributes;
|
||||
@@ -31,6 +33,18 @@ public class DeviceInfoContextHolder {
|
||||
deviceInfo.setOsVersion(request.getParameter(ApplicationConstant.PublicParameters.OS_VERSION));
|
||||
deviceInfo.setClient(request.getHeader(ApplicationConstant.PublicParameters.CLIENT));
|
||||
deviceInfo.setLang(request.getHeader(ApplicationConstant.PublicParameters.ACCEPT_LANGUAGE));
|
||||
Long uid = null;
|
||||
String pubUid = request.getHeader(ApplicationConstant.PublicParameters.PUB_UID);
|
||||
if (StrUtil.isNotEmpty(pubUid)) {
|
||||
uid = Long.parseLong(pubUid);
|
||||
} else {
|
||||
String uidStr = request.getParameter(ApplicationConstant.PublicParameters.UID);
|
||||
if (StrUtil.isNotEmpty(uidStr)) {
|
||||
uid = Long.parseLong(uidStr);
|
||||
}
|
||||
}
|
||||
deviceInfo.setUid(uid);
|
||||
deviceInfo.setClientIp(IPUtils.getRealIpAddress(request));
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error(e.getMessage(), e);
|
||||
|
@@ -0,0 +1,36 @@
|
||||
package com.accompany.business.event.listener.client;
|
||||
|
||||
import com.accompany.business.event.client.ClientInitEvent;
|
||||
import com.accompany.common.device.DeviceInfo;
|
||||
import com.accompany.core.service.account.UserAppService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.ApplicationListener;
|
||||
import org.springframework.scheduling.annotation.Async;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* @author: liaozetao
|
||||
* @date: 2024/7/1 17:42
|
||||
* @description:
|
||||
*/
|
||||
@Slf4j
|
||||
@Component
|
||||
public class ClientInitListener implements ApplicationListener<ClientInitEvent> {
|
||||
|
||||
@Autowired
|
||||
private UserAppService userAppService;
|
||||
|
||||
@Async
|
||||
@Override
|
||||
public void onApplicationEvent(ClientInitEvent event) {
|
||||
Object source = event.getSource();
|
||||
if (source == null) {
|
||||
return;
|
||||
}
|
||||
DeviceInfo deviceInfo = (DeviceInfo) source;
|
||||
userAppService.updateCurrentApp(deviceInfo.getUid(), deviceInfo.getApp(), new Date(), deviceInfo.getClientIp(), deviceInfo.getAppVersion());
|
||||
}
|
||||
}
|
@@ -59,8 +59,8 @@ public class ClientServiceImpl implements ClientService {
|
||||
@Override
|
||||
public AppInitVo init() {
|
||||
AppInitVo appInitVo = new AppInitVo();
|
||||
DeviceInfo deviceInfo = DeviceInfoContextHolder.get();
|
||||
try {
|
||||
DeviceInfo deviceInfo = DeviceInfoContextHolder.get();
|
||||
String appVersion = deviceInfo.getAppVersion();
|
||||
// 表情包的JSON数据
|
||||
FaceJson faceJson = faceJsonService.getValidFaceJson(appVersion);
|
||||
@@ -99,7 +99,7 @@ public class ClientServiceImpl implements ClientService {
|
||||
log.error(e.getMessage(), e);
|
||||
}
|
||||
//app初始化事件
|
||||
//SpringContextHolder.getApplicationContext().publishEvent(new ClientInitEvent(UidContextHolder.get()));
|
||||
SpringContextHolder.getApplicationContext().publishEvent(new ClientInitEvent(deviceInfo));
|
||||
return appInitVo;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user