优化代码

pull/65/head
awenes 2023-10-05 13:26:16 +08:00
parent 2ed71ca215
commit 4ab97e9521
9 changed files with 26 additions and 32 deletions

View File

@ -39,11 +39,6 @@ import lombok.NonNull;
@Builder
public class Actor implements Serializable {
public static final String ACTOR_ID = "actor.id";
public static final String ACTOR_TYPE = "actor.type";
public static final String ACTOR_AUTH_TYPE = "actor.auth_type.keyword";
@Serial
private static final long serialVersionUID = -1144169992714000310L;
@ -51,20 +46,17 @@ public class Actor implements Serializable {
* ID
*/
@NonNull
@Field(type = FieldType.Keyword, name = "id")
private String id;
/**
*
*/
@NonNull
@Field(type = FieldType.Keyword, name = "type")
private UserType type;
/**
*
*/
@Field(type = FieldType.Keyword, name = "auth_type")
private String authType;
}

View File

@ -52,67 +52,56 @@ public class GeoLocation implements Serializable {
/**
* IP
*/
@Field(type = FieldType.Ip, name = "ip")
private String ip;
/**
* continent code
*/
@Field(type = FieldType.Keyword, name = "continent_code")
private String continentCode;
/**
* continent Name
*/
@Field(type = FieldType.Text, name = "continent_code")
private String continentName;
/**
* code
*/
@Field(type = FieldType.Keyword, name = "country_code")
private String countryCode;
/**
*
*/
@Field(type = FieldType.Text, name = "country_name")
private String countryName;
/**
* code
*/
@Field(type = FieldType.Keyword, name = "province_code")
private String provinceCode;
/**
*
*/
@Field(type = FieldType.Text, name = "province_name")
private String provinceName;
/**
* code
*/
@Field(type = FieldType.Keyword, name = "city_code")
private String cityCode;
/**
*
*/
@Field(type = FieldType.Text, name = "city_name")
private String cityName;
/**
*
*/
@GeoPointField
private GeoPoint point;
/**
*
*/
@Field(type = FieldType.Keyword, name = "provider")
private GeoLocationProvider provider;
}

View File

@ -50,24 +50,20 @@ public class Target implements Serializable {
/**
* ID
*/
@Field(type = FieldType.Keyword, name = "id")
private String id;
/**
*
*/
@Field(type = FieldType.Keyword, name = "name")
private String name;
/**
*
*
*/
@Field(type = FieldType.Keyword, name = "type")
private TargetType type;
/**
*
*/
@Field(type = FieldType.Keyword, name = "type_name")
private String typeName;
}

View File

@ -38,21 +38,15 @@ import lombok.NoArgsConstructor;
@NoArgsConstructor
public class UserAgent implements Serializable {
@Field(type = FieldType.Keyword, name = "device_type")
private String deviceType;
@Field(type = FieldType.Keyword, name = "platform")
private String platform;
@Field(type = FieldType.Keyword, name = "platform_version")
private String platformVersion;
@Field(type = FieldType.Keyword, name = "browser")
private String browser;
@Field(type = FieldType.Keyword, name = "browser_type")
private String browserType;
@Field(type = FieldType.Keyword, name = "browser_major_version")
private String browserMajorVersion;
}

View File

@ -54,6 +54,13 @@ export default (props: { userId: string }) => {
);
},
},
{
title: intl.formatMessage({ id: 'pages.account.user_detail.login_audit.columns.platform' }),
ellipsis: true,
dataIndex: 'platform',
width: 110,
search: false,
},
{
title: intl.formatMessage({ id: 'pages.account.user_detail.login_audit.columns.browser' }),
dataIndex: 'browser',

View File

@ -67,6 +67,7 @@ export default {
'pages.account.user_detail.login_audit.columns.app_name': '应用名称',
'pages.account.user_detail.login_audit.columns.client_ip': '客户端IP',
'pages.account.user_detail.login_audit.columns.browser': '浏览器',
'pages.account.user_detail.login_audit.columns.platform': '操作系统',
'pages.account.user_detail.login_audit.columns.location': '地理位置',
'pages.account.user_detail.login_audit.columns.event_time': '登录时间',
'pages.account.user_detail.login_audit.columns.event_status': '登录结果',

View File

@ -221,6 +221,10 @@ declare namespace AccountAPI {
export interface UserLoginAuditList {
appName: string;
clientIp: string;
userAgent: {
platformVersion:string;
platform:string
};
browser: string;
eventStatus: string;
eventTime: string;

View File

@ -21,6 +21,8 @@ import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.List;
import cn.topiam.employee.audit.entity.GeoLocation;
import cn.topiam.employee.audit.entity.UserAgent;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.springframework.data.elasticsearch.client.elc.NativeQuery;
@ -275,10 +277,13 @@ public interface UserConverter {
if (audit.getEventType().getCode().equals(PortalEventType.LOGIN_PORTAL.getCode())) {
result.setAppName(PORTAL.getDesc());
}
UserAgent userAgent=audit.getUserAgent();
GeoLocation geoLocation= audit.getGeoLocation();
result.setEventTime(audit.getEventTime());
result.setClientIp(audit.getGeoLocation().getIp());
result.setBrowser(audit.getUserAgent().getBrowser());
result.setLocation(audit.getGeoLocation().getCityName());
result.setClientIp(geoLocation.getIp());
result.setLocation(geoLocation.getCityName());
result.setBrowser(userAgent.getBrowser());
result.setPlatform(userAgent.getPlatform()+" "+userAgent.getPlatformVersion());
result.setEventStatus(audit.getEventStatus());
list.add(result);
});

View File

@ -53,6 +53,12 @@ public class UserLoginAuditListResult {
@Parameter(description = "客户端IP")
private String clientIp;
/**
*
*/
@Parameter(description = "操作系统")
private String platform;
/**
*
*/