feat: add frontend API integration for operation log
This commit is contained in:
@@ -0,0 +1,41 @@
|
|||||||
|
import request from '@/utils/request'
|
||||||
|
|
||||||
|
export interface OperationLog {
|
||||||
|
id?: number
|
||||||
|
username?: string
|
||||||
|
operation?: string
|
||||||
|
method?: string
|
||||||
|
params?: string
|
||||||
|
result?: string
|
||||||
|
ip?: string
|
||||||
|
duration?: number
|
||||||
|
status?: string
|
||||||
|
errorMsg?: string
|
||||||
|
createdAt?: string
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface PageResponse<T> {
|
||||||
|
content: T[]
|
||||||
|
totalPages: number
|
||||||
|
totalElements: number
|
||||||
|
currentPage: number
|
||||||
|
size: number
|
||||||
|
}
|
||||||
|
|
||||||
|
export const operationLogApi = {
|
||||||
|
getAll: () => request.get<OperationLog[]>('/logs/operation'),
|
||||||
|
|
||||||
|
getById: (id: number) => request.get<OperationLog>(`/logs/operation/${id}`),
|
||||||
|
|
||||||
|
getPage: (params: {
|
||||||
|
page?: number
|
||||||
|
size?: number
|
||||||
|
sort?: string
|
||||||
|
order?: string
|
||||||
|
keyword?: string
|
||||||
|
}) => request.get<PageResponse<OperationLog>>('/logs/operation/page', { params }),
|
||||||
|
|
||||||
|
getCount: () => request.get<number>('/logs/operation/count'),
|
||||||
|
|
||||||
|
create: (data: Partial<OperationLog>) => request.post<OperationLog>('/logs/operation', data)
|
||||||
|
}
|
||||||
@@ -91,10 +91,10 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { ref, reactive, onMounted } from 'vue'
|
import { ref, reactive, onMounted } from 'vue'
|
||||||
import { Search } from '@element-plus/icons-vue'
|
import { Search } from '@element-plus/icons-vue'
|
||||||
import request from '@/utils/request'
|
import { operationLogApi, OperationLog } from '@/api/operationLog'
|
||||||
|
|
||||||
const loading = ref(false)
|
const loading = ref(false)
|
||||||
const dataSource = ref([])
|
const dataSource = ref<OperationLog[]>([])
|
||||||
const searchKeyword = ref('')
|
const searchKeyword = ref('')
|
||||||
const pagination = reactive({
|
const pagination = reactive({
|
||||||
current: 1,
|
current: 1,
|
||||||
@@ -110,14 +110,12 @@ const sortInfo = reactive({
|
|||||||
const fetchData = async () => {
|
const fetchData = async () => {
|
||||||
loading.value = true
|
loading.value = true
|
||||||
try {
|
try {
|
||||||
const res: any = await request.get('/logs/operation/page', {
|
const res = await operationLogApi.getPage({
|
||||||
params: {
|
page: pagination.current - 1,
|
||||||
page: pagination.current - 1,
|
size: pagination.pageSize,
|
||||||
size: pagination.pageSize,
|
sort: sortInfo.sort,
|
||||||
sort: sortInfo.sort,
|
order: sortInfo.order,
|
||||||
order: sortInfo.order,
|
keyword: searchKeyword.value || undefined
|
||||||
keyword: searchKeyword.value || undefined
|
|
||||||
}
|
|
||||||
})
|
})
|
||||||
dataSource.value = res.content
|
dataSource.value = res.content
|
||||||
pagination.total = res.totalElements
|
pagination.total = res.totalElements
|
||||||
|
|||||||
Reference in New Issue
Block a user