Browse Source

feat: 添加ElasticSearch模块

pull/126/head 7.2.2.8
wangjun 3 years ago
parent
commit
fec8689a65
  1. 20
      vben28/src/router/routes/modules/admin.ts
  2. 273
      vben28/src/services/ServiceProxies.ts
  3. 56
      vben28/src/views/admin/elasticSearch/ElasticSearch.ts
  4. 81
      vben28/src/views/admin/elasticSearch/ElasticSearch.vue

20
vben28/src/router/routes/modules/admin.ts

@ -64,16 +64,6 @@ const admin: AppRouteModule = {
icon: 'ant-design:snippets-twotone', icon: 'ant-design:snippets-twotone',
}, },
}, },
{
path: 'esLogs',
name: 'ESLogs',
component: () => import('/@/views/admin/elasticSearch/ElasticSearch.vue'),
meta: {
title: t('routes.admin.esLogs'),
policy: 'AbpIdentity.ES',
icon: 'ant-design:snippets-twotone',
},
},
{ {
path: 'dataDictionary', path: 'dataDictionary',
name: 'dataDictionary', name: 'dataDictionary',
@ -104,16 +94,6 @@ const admin: AppRouteModule = {
policy: 'AbpIdentity.LanguageTexts', policy: 'AbpIdentity.LanguageTexts',
}, },
}, },
// {
// path: 'files',
// name: 'files',
// component: () => import('/@/views/admin/files/File.vue'),
// meta: {
// title: t('routes.admin.fileNameManagement'),
// icon: 'ant-design:snippets-outlined',
// policy: 'AbpIdentity.FileManagement',
// },
// },
], ],
}; };

273
vben28/src/services/ServiceProxies.ts

@ -2485,119 +2485,6 @@ export class LanguageTextsServiceProxy extends ServiceProxyBase {
} }
} }
export class EsLogServiceProxy extends ServiceProxyBase {
private instance: AxiosInstance;
private baseUrl: string;
protected jsonParseReviver: ((key: string, value: any) => any) | undefined = undefined;
constructor(baseUrl?: string, instance?: AxiosInstance) {
super();
this.instance = instance ? instance : axios.create();
this.baseUrl = baseUrl !== undefined && baseUrl !== null ? baseUrl : "";
}
/**
* Es日志
* @param body (optional)
* @return Success
*/
page(body: PagingElasticSearchLogInput | undefined , cancelToken?: CancelToken | undefined): Promise<PagingElasticSearchLogOutputCustomPagedResultDto> {
let url_ = this.baseUrl + "/EsLog/page";
url_ = url_.replace(/[?&]$/, "");
const content_ = JSON.stringify(body);
let options_ = <AxiosRequestConfig>{
data: content_,
method: "POST",
url: url_,
headers: {
"Content-Type": "application/json",
"Accept": "text/plain"
},
cancelToken
};
return this.transformOptions(options_).then(transformedOptions_ => {
return this.instance.request(transformedOptions_);
}).catch((_error: any) => {
if (isAxiosError(_error) && _error.response) {
return _error.response;
} else {
throw _error;
}
}).then((_response: AxiosResponse) => {
return this.transformResult(url_, _response, (_response: AxiosResponse) => this.processPage(_response));
});
}
protected processPage(response: AxiosResponse): Promise<PagingElasticSearchLogOutputCustomPagedResultDto> {
const status = response.status;
let _headers: any = {};
if (response.headers && typeof response.headers === "object") {
for (let k in response.headers) {
if (response.headers.hasOwnProperty(k)) {
_headers[k] = response.headers[k];
}
}
}
if (status === 200) {
const _responseText = response.data;
let result200: any = null;
let resultData200 = _responseText;
result200 = PagingElasticSearchLogOutputCustomPagedResultDto.fromJS(resultData200);
return Promise.resolve<PagingElasticSearchLogOutputCustomPagedResultDto>(result200);
} else if (status === 403) {
const _responseText = response.data;
let result403: any = null;
let resultData403 = _responseText;
result403 = RemoteServiceErrorResponse.fromJS(resultData403);
return throwException("Forbidden", status, _responseText, _headers, result403);
} else if (status === 401) {
const _responseText = response.data;
let result401: any = null;
let resultData401 = _responseText;
result401 = RemoteServiceErrorResponse.fromJS(resultData401);
return throwException("Unauthorized", status, _responseText, _headers, result401);
} else if (status === 400) {
const _responseText = response.data;
let result400: any = null;
let resultData400 = _responseText;
result400 = RemoteServiceErrorResponse.fromJS(resultData400);
return throwException("Bad Request", status, _responseText, _headers, result400);
} else if (status === 404) {
const _responseText = response.data;
let result404: any = null;
let resultData404 = _responseText;
result404 = RemoteServiceErrorResponse.fromJS(resultData404);
return throwException("Not Found", status, _responseText, _headers, result404);
} else if (status === 501) {
const _responseText = response.data;
let result501: any = null;
let resultData501 = _responseText;
result501 = RemoteServiceErrorResponse.fromJS(resultData501);
return throwException("Server Error", status, _responseText, _headers, result501);
} else if (status === 500) {
const _responseText = response.data;
let result500: any = null;
let resultData500 = _responseText;
result500 = RemoteServiceErrorResponse.fromJS(resultData500);
return throwException("Server Error", status, _responseText, _headers, result500);
} else if (status !== 200 && status !== 204) {
const _responseText = response.data;
return throwException("An unexpected server error occurred.", status, _responseText, _headers);
}
return Promise.resolve<PagingElasticSearchLogOutputCustomPagedResultDto>(null as any);
}
}
export class NotificationServiceProxy extends ServiceProxyBase { export class NotificationServiceProxy extends ServiceProxyBase {
private instance: AxiosInstance; private instance: AxiosInstance;
private baseUrl: string; private baseUrl: string;
@ -13779,166 +13666,6 @@ export interface IPagingDataDictionaryOutputPagedResultDto {
totalCount: number; totalCount: number;
} }
export class PagingElasticSearchLogInput implements IPagingElasticSearchLogInput {
/** 当前页面.默认从1开始 */
pageIndex!: number;
/** 每页多少条.每页显示多少记录 */
pageSize!: number;
/** 跳过多少条 */
readonly skipCount!: number;
filter!: string | undefined;
startCreationTime!: dayjs.Dayjs | undefined;
endCreationTime!: dayjs.Dayjs | undefined;
constructor(data?: IPagingElasticSearchLogInput) {
if (data) {
for (var property in data) {
if (data.hasOwnProperty(property))
(<any>this)[property] = (<any>data)[property];
}
}
}
init(_data?: any) {
if (_data) {
this.pageIndex = _data["pageIndex"];
this.pageSize = _data["pageSize"];
(<any>this).skipCount = _data["skipCount"];
this.filter = _data["filter"];
this.startCreationTime = _data["startCreationTime"] ? dayjs(_data["startCreationTime"].toString()) : <any>undefined;
this.endCreationTime = _data["endCreationTime"] ? dayjs(_data["endCreationTime"].toString()) : <any>undefined;
}
}
static fromJS(data: any): PagingElasticSearchLogInput {
data = typeof data === 'object' ? data : {};
let result = new PagingElasticSearchLogInput();
result.init(data);
return result;
}
toJSON(data?: any) {
data = typeof data === 'object' ? data : {};
data["pageIndex"] = this.pageIndex;
data["pageSize"] = this.pageSize;
data["skipCount"] = this.skipCount;
data["filter"] = this.filter;
data["startCreationTime"] = this.startCreationTime ? this.startCreationTime.toISOString() : <any>undefined;
data["endCreationTime"] = this.endCreationTime ? this.endCreationTime.toISOString() : <any>undefined;
return data;
}
}
export interface IPagingElasticSearchLogInput {
/** 当前页面.默认从1开始 */
pageIndex: number;
/** 每页多少条.每页显示多少记录 */
pageSize: number;
/** 跳过多少条 */
skipCount: number;
filter: string | undefined;
startCreationTime: dayjs.Dayjs | undefined;
endCreationTime: dayjs.Dayjs | undefined;
}
export class PagingElasticSearchLogOutput implements IPagingElasticSearchLogOutput {
/** 日志级别 */
level!: string | undefined;
/** 日志内容 */
message!: string | undefined;
/** 创建时间 */
creationTime!: dayjs.Dayjs;
constructor(data?: IPagingElasticSearchLogOutput) {
if (data) {
for (var property in data) {
if (data.hasOwnProperty(property))
(<any>this)[property] = (<any>data)[property];
}
}
}
init(_data?: any) {
if (_data) {
this.level = _data["level"];
this.message = _data["message"];
this.creationTime = _data["creationTime"] ? dayjs(_data["creationTime"].toString()) : <any>undefined;
}
}
static fromJS(data: any): PagingElasticSearchLogOutput {
data = typeof data === 'object' ? data : {};
let result = new PagingElasticSearchLogOutput();
result.init(data);
return result;
}
toJSON(data?: any) {
data = typeof data === 'object' ? data : {};
data["level"] = this.level;
data["message"] = this.message;
data["creationTime"] = this.creationTime ? this.creationTime.toISOString() : <any>undefined;
return data;
}
}
export interface IPagingElasticSearchLogOutput {
/** 日志级别 */
level: string | undefined;
/** 日志内容 */
message: string | undefined;
/** 创建时间 */
creationTime: dayjs.Dayjs;
}
export class PagingElasticSearchLogOutputCustomPagedResultDto implements IPagingElasticSearchLogOutputCustomPagedResultDto {
items!: PagingElasticSearchLogOutput[] | undefined;
totalCount!: number;
constructor(data?: IPagingElasticSearchLogOutputCustomPagedResultDto) {
if (data) {
for (var property in data) {
if (data.hasOwnProperty(property))
(<any>this)[property] = (<any>data)[property];
}
}
}
init(_data?: any) {
if (_data) {
if (Array.isArray(_data["items"])) {
this.items = [] as any;
for (let item of _data["items"])
this.items!.push(PagingElasticSearchLogOutput.fromJS(item));
}
this.totalCount = _data["totalCount"];
}
}
static fromJS(data: any): PagingElasticSearchLogOutputCustomPagedResultDto {
data = typeof data === 'object' ? data : {};
let result = new PagingElasticSearchLogOutputCustomPagedResultDto();
result.init(data);
return result;
}
toJSON(data?: any) {
data = typeof data === 'object' ? data : {};
if (Array.isArray(this.items)) {
data["items"] = [];
for (let item of this.items)
data["items"].push(item.toJSON());
}
data["totalCount"] = this.totalCount;
return data;
}
}
export interface IPagingElasticSearchLogOutputCustomPagedResultDto {
items: PagingElasticSearchLogOutput[] | undefined;
totalCount: number;
}
export class PagingEntityChangeOutput implements IPagingEntityChangeOutput { export class PagingEntityChangeOutput implements IPagingEntityChangeOutput {
id!: string; id!: string;
auditLogId!: string; auditLogId!: string;

56
vben28/src/views/admin/elasticSearch/ElasticSearch.ts

@ -1,56 +0,0 @@
import { FormSchema } from '/@/components/Table';
import { BasicColumn } from '/@/components/Table';
import { useI18n } from '/@/hooks/web/useI18n';
const { t } = useI18n();
import { formatToDateTime, dateUtil } from '/@/utils/dateUtil';
import { EsLogServiceProxy, PagingElasticSearchLogInput } from '/@/services/ServiceProxies';
export const searchFormSchema: FormSchema[] = [
{
field: 'filter',
component: 'Input',
label: t('common.key'),
labelWidth: 120,
colProps: {
span: 6,
},
},
{
field: 'time',
component: 'RangePicker',
label: t('common.creationTime'),
labelWidth: 80,
colProps: { span: 6 },
defaultValue: [dateUtil().subtract(0, 'days'), dateUtil().add(1, 'days')],
},
];
export const tableColumns: BasicColumn[] = [
{
title: t('routes.admin.logLevel'),
dataIndex: 'level',
width: 200,
},
{
title: t('common.creationTime'),
dataIndex: 'creationTime',
customRender: ({ text }) => {
return formatToDateTime(text);
},
width: 200,
},
{
title: t('routes.admin.logContent'),
dataIndex: 'message',
},
];
/**
* ES日志
* @param request
* @returns
*/
export async function getElasticSearchLogAsync(request: PagingElasticSearchLogInput) {
const _elasticSearchServiceProxy = new EsLogServiceProxy();
return await _elasticSearchServiceProxy.page(request);
}

81
vben28/src/views/admin/elasticSearch/ElasticSearch.vue

@ -1,81 +0,0 @@
<template>
<div>
<BasicTable @register="registerTable" size="small">
<template #bodyCell="{ column, record }">
<template v-if="column.key === 'message'">
<a-button type="link" size="small" @click="lookJson(record)">
{{ t("common.detail") }}
</a-button>
</template>
</template>
</BasicTable>
<BasicModal :canFullscreen="false" @register="registerModal" :showOkButton="false">
{{ content }}
</BasicModal>
</div>
</template>
<script lang="ts">
import { defineComponent, ref } from "vue";
import { useI18n } from "/@/hooks/web/useI18n";
import { BasicModal, useModal } from "/@/components/Modal";
import { BasicTable, useTable } from "/@/components/Table";
import {
getElasticSearchLogAsync,
tableColumns,
searchFormSchema
} from "/@/views/admin/elasticSearch/ElasticSearch";
export default defineComponent({
name: "ElasticSearch",
components: {
BasicTable,
BasicModal
},
setup() {
const { t } = useI18n();
const [registerModal, { openModal: openJsonModal }] = useModal();
const [registerTable, { reload }] = useTable({
columns: tableColumns,
formConfig: {
labelWidth: 100,
schemas: searchFormSchema,
fieldMapToTime: [["time", ["startCreationTime", "endCreationTime"]]]
},
api: getElasticSearchLogAsync,
useSearchForm: true,
showTableSetting: true,
bordered: true,
canResize: true,
showIndexColumn: true,
actionColumn: {
title: t("common.action"),
dataIndex: "action",
slots: {
customRender: "action"
},
width: 150,
fixed: "right"
}
});
let content = ref("");
const lookJson = async (record) => {
openJsonModal();
content.value = record.message;
};
return {
t,
registerTable,
reload,
lookJson,
registerModal,
openJsonModal,
content
};
}
});
</script>
<style lang="less" scoped></style>
Loading…
Cancel
Save