feat: add disk monitor contracts and sql

This commit is contained in:
2026-04-22 21:42:35 +08:00
parent 455d394682
commit 2314b03404
6 changed files with 293 additions and 0 deletions

View File

@@ -0,0 +1,26 @@
import http from '@/api'
import type { DiskMonitor } from '@/api/system/diskMonitor/interface'
export const getDiskMonitorPolicyDetail = () => {
return http.get<DiskMonitor.PolicyDetailData>('/disk-monitor/policy/detail')
}
export const saveDiskMonitorPolicy = (params: DiskMonitor.SavePolicyParams) => {
return http.post('/disk-monitor/policy/save', params)
}
export const runDiskMonitorJob = (params: DiskMonitor.RunJobParams) => {
return http.post<DiskMonitor.RunJobResult>('/disk-monitor/job/run', params)
}
export const getDiskMonitorJobList = (params: DiskMonitor.JobListParams) => {
return http.post<DiskMonitor.JobPageData>('/disk-monitor/job/list', params)
}
export const getDiskMonitorJobDetail = (jobId: number) => {
return http.get<DiskMonitor.JobDetailData>(`/disk-monitor/job/${jobId}/detail`)
}
export const testDiskMonitorNotify = (params: DiskMonitor.NotifyTestParams) => {
return http.post('/disk-monitor/notify/test', params)
}

View File

@@ -0,0 +1,129 @@
import type { ReqPage, ResPage } from '@/api/interface'
export namespace DiskMonitor {
export type MonitorStatus = 'UNKNOWN' | 'NORMAL' | 'WARNING' | 'ALARM'
export type NotifyMode = 'STATUS_CHANGE' | 'EVERY_TIME'
export type JobSource = 'APP_START' | 'DAILY_SCHEDULE' | 'MANUAL'
export type JobStatus = 'RUNNING' | 'SUCCESS' | 'PARTIAL_SUCCESS' | 'FAILED'
export type NotifyLevel = 'WARNING' | 'ALARM' | 'RECOVER'
export type NotifyChannelType = 'PATH' | 'HTTP'
export type NotifySendStatus = 'SUCCESS' | 'FAILED'
export interface NotifyPathTarget {
path: string
name: string
enabled: boolean
}
export interface NotifyHttpTarget {
url: string
name: string
method: 'POST'
timeoutMs: number
enabled: boolean
}
export interface PolicyItem {
id?: number
policyName: string
monitorEnabled: boolean
runOnAppStart: boolean
dailyRunTime: string
warningNotifyMode: NotifyMode
alarmNotifyMode: NotifyMode
lastJobId?: number | null
remark: string
}
export interface TargetItem {
id?: number
policyId?: number
driveLetter: string
monitorEnabled: boolean
warningUsagePercent: number
alarmUsagePercent: number
notifyPathEnabled: boolean
notifyPathList: NotifyPathTarget[]
notifyHttpEnabled: boolean
notifyHttpList: NotifyHttpTarget[]
lastStatus: MonitorStatus
lastScanTime?: string | null
lastUsedPercent?: number | null
remark: string
}
export interface PolicyDetailData {
policy: PolicyItem
targets: TargetItem[]
}
export interface SavePolicyParams {
policy: PolicyItem
targets: TargetItem[]
}
export interface RunJobParams {
jobSource: 'MANUAL'
}
export interface RunJobResult {
jobId: number
jobNo: string
}
export interface JobListParams extends ReqPage {}
export interface JobListItem {
id: number
jobNo: string
jobSource: JobSource
startedAt: string
finishedAt?: string | null
jobStatus: JobStatus
targetCount: number
warningCount: number
alarmCount: number
message?: string
}
export interface ResultItem {
resultId: number
targetId: number
driveLetter: string
totalBytes: number
usedBytes: number
freeBytes: number
usedPercent: number
currentStatus: MonitorStatus
previousStatus: MonitorStatus
statusChanged: boolean
shouldNotify: boolean
notifyReason: 'ALARM_EVERY_TIME' | 'STATUS_CHANGED' | 'NO_NOTIFY'
scanTime: string
message?: string
}
export interface NotifyLogItem {
id: number
resultId: number
driveLetter: string
notifyLevel: NotifyLevel
channelType: NotifyChannelType
channelTarget: string
sendStatus: NotifySendStatus
responseMessage?: string
sentAt: string
}
export interface JobDetailData {
job: JobListItem
results: ResultItem[]
notifyLogs: NotifyLogItem[]
}
export interface NotifyTestParams {
driveLetter: string
}
export interface JobPageData extends ResPage<JobListItem> {}
}