优化代码

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 @Builder
public class Actor implements Serializable { 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 @Serial
private static final long serialVersionUID = -1144169992714000310L; private static final long serialVersionUID = -1144169992714000310L;
@ -51,20 +46,17 @@ public class Actor implements Serializable {
* ID * ID
*/ */
@NonNull @NonNull
@Field(type = FieldType.Keyword, name = "id")
private String id; private String id;
/** /**
* *
*/ */
@NonNull @NonNull
@Field(type = FieldType.Keyword, name = "type")
private UserType type; private UserType type;
/** /**
* *
*/ */
@Field(type = FieldType.Keyword, name = "auth_type")
private String authType; private String authType;
} }

View File

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

View File

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

View File

@ -38,21 +38,15 @@ import lombok.NoArgsConstructor;
@NoArgsConstructor @NoArgsConstructor
public class UserAgent implements Serializable { public class UserAgent implements Serializable {
@Field(type = FieldType.Keyword, name = "device_type")
private String deviceType; private String deviceType;
@Field(type = FieldType.Keyword, name = "platform")
private String platform; private String platform;
@Field(type = FieldType.Keyword, name = "platform_version")
private String platformVersion; private String platformVersion;
@Field(type = FieldType.Keyword, name = "browser")
private String browser; private String browser;
@Field(type = FieldType.Keyword, name = "browser_type")
private String browserType; private String browserType;
@Field(type = FieldType.Keyword, name = "browser_major_version")
private String browserMajorVersion; 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' }), title: intl.formatMessage({ id: 'pages.account.user_detail.login_audit.columns.browser' }),
dataIndex: '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.app_name': '应用名称',
'pages.account.user_detail.login_audit.columns.client_ip': '客户端IP', '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.browser': '浏览器',
'pages.account.user_detail.login_audit.columns.platform': '操作系统',
'pages.account.user_detail.login_audit.columns.location': '地理位置', '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_time': '登录时间',
'pages.account.user_detail.login_audit.columns.event_status': '登录结果', 'pages.account.user_detail.login_audit.columns.event_status': '登录结果',

View File

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

View File

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

View File

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