2021-06-11 23:00:33 +08:00
|
|
|
|
/**
|
|
|
|
|
|
* @author 陈劲松
|
|
|
|
|
|
* @date 2021/6/11
|
2021-06-22 21:19:04 +08:00
|
|
|
|
* @description 1.定义api;2.定义通用查询方法,函数名应为 获取详情getItem、获取列表getItemList。例如getUser、getUserList
|
2021-06-11 23:00:33 +08:00
|
|
|
|
*/
|
2021-06-22 21:19:04 +08:00
|
|
|
|
import { get, post } from '@/utils/http'
|
2021-10-16 15:50:12 +08:00
|
|
|
|
import axios from 'axios'
|
2021-06-22 21:19:04 +08:00
|
|
|
|
import { sortByOrderNum } from '@/permission'
|
2021-08-11 22:14:23 +08:00
|
|
|
|
import { storageKey } from '@/utils/constants'
|
2021-06-11 23:00:33 +08:00
|
|
|
|
|
2021-06-15 09:25:10 +08:00
|
|
|
|
export const api = {
|
2021-06-22 21:19:04 +08:00
|
|
|
|
// 系统相关
|
|
|
|
|
|
permission: '/sys/user/permissions',
|
|
|
|
|
|
i18n: '/sys/i18n/lang',
|
|
|
|
|
|
dict: '/sys/dict',
|
2021-09-02 17:12:27 +08:00
|
|
|
|
user: '/sys/user',
|
|
|
|
|
|
role: '/sys/role',
|
|
|
|
|
|
galaxyProxy: '/galaxy/setting',
|
|
|
|
|
|
operationLog: '/sys/log',
|
2021-10-15 16:42:15 +08:00
|
|
|
|
chartList: '/visual/chart/list',
|
2021-06-22 21:19:04 +08:00
|
|
|
|
// 业务
|
2021-06-15 09:25:10 +08:00
|
|
|
|
panel: '/visual/panel',
|
2021-07-07 22:58:52 +08:00
|
|
|
|
chart: '/visual/chart',
|
2021-12-31 10:55:49 +08:00
|
|
|
|
entityList: '/interface/entity/list/basic',
|
2022-01-05 20:24:02 +08:00
|
|
|
|
entityListTotal: '/interface/entity/list/total',
|
2021-08-11 22:14:23 +08:00
|
|
|
|
entityCount: '/interface/entity/total',
|
2021-12-31 10:55:49 +08:00
|
|
|
|
entityFilter: '/interface/entity/filter/count',
|
|
|
|
|
|
entityFilterTop: '/interface/entity/filter/top',
|
2021-09-30 00:50:11 +08:00
|
|
|
|
ipThroughput: '/interface/entity/ip/detail/throughput',
|
|
|
|
|
|
domainThroughput: '/interface/entity/domain/detail/throughput',
|
2021-12-23 17:17:06 +08:00
|
|
|
|
appThroughput: '/interface/entity/app/detail/throughput',
|
2021-12-31 10:40:37 +08:00
|
|
|
|
filterTop: '/interface/entity/filter/top',
|
|
|
|
|
|
entityTotal: '/interface/entity/index/total',
|
|
|
|
|
|
entityNew: '/interface/entity/index/new',
|
|
|
|
|
|
entityActive: '/interface/entity/index/active',
|
|
|
|
|
|
entityTraffic: '/interface/entity/list/traffic',
|
|
|
|
|
|
entityAlertNum: '/interface/entity/list/alertNum',
|
|
|
|
|
|
entitySecurityNum: '/interface/entity/list/detectionNum',
|
|
|
|
|
|
ipBytes: '/interface/entity/detail/ip/bytes',
|
|
|
|
|
|
domainBytes: '/interface/entity/detail/domain/bytes',
|
2022-01-04 14:54:26 +08:00
|
|
|
|
appBytes: '/interface/entity/detail/app/bytes',
|
|
|
|
|
|
// app detail
|
|
|
|
|
|
entityAppDetailTraffic: '/interface/entity/detail/overview/app/traffic',
|
|
|
|
|
|
entityAppDetailRelation: '/interface/entity/detail/overview/app/relation',
|
2022-02-13 23:20:24 +08:00
|
|
|
|
entityAppDetailNetworkQuantity: '/interface/entity/detail/overview/app/networkQuantity',
|
|
|
|
|
|
entityAppDetailLinkIn: '/interface/entity/detail/overview/app/linkIn',
|
|
|
|
|
|
entityAppDetailLinkOut: '/interface/entity/detail/overview/app/linkOut',
|
2022-01-04 14:54:26 +08:00
|
|
|
|
entityAppDetailAlert: '/interface/entity/detail/overview/app/alert',
|
|
|
|
|
|
entityAppDetailSecurity: '/interface/entity/detail/overview/app/security',
|
2022-02-16 18:19:58 +08:00
|
|
|
|
entityAppRelatedServerDomain: '/interface/entity/detail/overview/app/relatedDomain',
|
|
|
|
|
|
entityAppRelatedServerIp: '/interface/entity/detail/overview/app/relatedServerIp',
|
2022-01-04 14:54:26 +08:00
|
|
|
|
// domain detail
|
|
|
|
|
|
entityDomainDetailBasic: '/interface/entity/detail/overview/domain/basic',
|
|
|
|
|
|
entityDomainDetailTraffic: '/interface/entity/detail/overview/domain/traffic',
|
|
|
|
|
|
entityDomainDetailRelation: '/interface/entity/detail/overview/domain/relation',
|
|
|
|
|
|
entityDomainDetailNetworkQuantity: '/interface/entity/detail/overview/domain/networkQuantity',
|
|
|
|
|
|
entityDomainDetailLinkIn: '/interface/entity/detail/overview/domain/linkIn',
|
|
|
|
|
|
entityDomainDetailLinkOut: '/interface/entity/detail/overview/domain/linkOut',
|
|
|
|
|
|
entityDomainDetailAlert: '/interface/entity/detail/overview/domain/alert',
|
|
|
|
|
|
entityDomainDetailSecurity: '/interface/entity/detail/overview/domain/security',
|
2022-02-16 18:19:58 +08:00
|
|
|
|
entityDomainRelatedServerIp: '/interface/entity/detail/overview/domain/relatedServerIp',
|
|
|
|
|
|
entityDomainRelatedServerApp: '/interface/entity/detail/overview/domain/relatedApp',
|
2022-01-04 14:54:26 +08:00
|
|
|
|
// ip detail
|
|
|
|
|
|
entityIpDetailTraffic: '/interface/entity/detail/overview/ip/traffic',
|
2022-01-21 21:03:39 +08:00
|
|
|
|
entityIpDetailTrafficMap: '/interface/entity/detail/ip/trafficMap',
|
2022-01-26 14:39:17 +08:00
|
|
|
|
entityDomainDetailTrafficMap: '/interface/entity/detail/domain/trafficMap',
|
|
|
|
|
|
entityAppDetailTrafficMap: '/interface/entity/detail/app/trafficMap',
|
2022-01-04 14:54:26 +08:00
|
|
|
|
entityIpDetailRelation: '/interface/entity/detail/overview/ip/relation',
|
2022-02-13 23:20:24 +08:00
|
|
|
|
entityIpDetailNetworkQuantity: '/interface/entity/detail/overview/ip/networkQuantity',
|
|
|
|
|
|
entityIpDetailLinkIn: '/interface/entity/detail/overview/ip/linkIn',
|
|
|
|
|
|
entityIpDetailLinkOut: '/interface/entity/detail/overview/ip/linkOut',
|
2022-01-04 14:54:26 +08:00
|
|
|
|
entityIpDetailAlert: '/interface/entity/detail/overview/ip/alert',
|
2022-02-16 18:19:58 +08:00
|
|
|
|
entityIpDetailSecurity: '/interface/entity/detail/overview/ip/security',
|
|
|
|
|
|
entityIpRelatedServerDomain: '/interface/entity/detail/overview/ip/relatedDomain',
|
2022-02-17 19:28:48 +08:00
|
|
|
|
entityIpRelatedServerApp: '/interface/entity/detail/overview/ip/relatedApp',
|
2022-02-18 18:09:44 +08:00
|
|
|
|
// detection
|
2022-02-25 13:33:54 +08:00
|
|
|
|
detection: {
|
|
|
|
|
|
securityEvent: {
|
2022-02-28 11:53:37 +08:00
|
|
|
|
eventSeverityTrend: '/interface/detection/security/filter/severityTrend',
|
|
|
|
|
|
securityType: '/interface/detection/security/filter/securityType',
|
|
|
|
|
|
offenderIp: '/interface/detection/security/filter/offenderIp',
|
|
|
|
|
|
offenderLocation: '/interface/detection/security/filter/offenderLocation',
|
|
|
|
|
|
victimIp: '/interface/detection/security/filter/victimIp',
|
|
|
|
|
|
victimLocation: '/interface/detection/security/filter/victimLocation',
|
|
|
|
|
|
eventSeverity: '/interface/detection/security/filter/severity',
|
|
|
|
|
|
listBasic: '/interface/detection/security/list/basic',
|
2022-03-05 20:25:03 +08:00
|
|
|
|
listCount: '/interface/detection/security/list/count',
|
2022-02-28 11:53:37 +08:00
|
|
|
|
overviewBasic: '/interface/detection/security/detail/overview/basic',
|
|
|
|
|
|
overviewEvent: '/interface/detection/security/detail/overview/event'
|
2022-02-25 13:33:54 +08:00
|
|
|
|
},
|
|
|
|
|
|
performanceEvent: {
|
2022-02-28 11:53:37 +08:00
|
|
|
|
eventSeverityTrend: '/interface/detection/performance/filter/severityTrend',
|
2022-03-04 15:46:30 +08:00
|
|
|
|
eventType: '/interface/detection/performance/filter/eventType',
|
2022-02-28 11:53:37 +08:00
|
|
|
|
eventSeverity: '/interface/detection/performance/filter/severity',
|
|
|
|
|
|
activeEntity: '/interface/detection/performance/filter/activeEntity',
|
|
|
|
|
|
listBasic: '/interface/detection/performance/list/basic',
|
2022-03-05 20:25:03 +08:00
|
|
|
|
listCount: '/interface/detection/performance/list/count',
|
2022-02-28 11:53:37 +08:00
|
|
|
|
overviewBasic: '/interface/detection/performance/detail/overview/basic'
|
2022-02-25 13:33:54 +08:00
|
|
|
|
}
|
2022-03-07 17:27:55 +08:00
|
|
|
|
}
|
2021-06-15 09:25:10 +08:00
|
|
|
|
}
|
2021-08-13 09:39:02 +08:00
|
|
|
|
|
2021-06-20 13:31:55 +08:00
|
|
|
|
/* panel */
|
2021-06-11 23:00:33 +08:00
|
|
|
|
export async function getPanelList (params) {
|
2021-06-15 09:25:10 +08:00
|
|
|
|
return await getData(api.panel, params, true)
|
2021-06-11 23:00:33 +08:00
|
|
|
|
}
|
2021-06-20 13:31:55 +08:00
|
|
|
|
export async function getPanel (id) {
|
|
|
|
|
|
return await getData(`${api.chart}/${id}`)
|
|
|
|
|
|
}
|
|
|
|
|
|
/* chart */
|
|
|
|
|
|
export async function getChartList (params) {
|
|
|
|
|
|
return await getData(api.chart, params, true)
|
|
|
|
|
|
}
|
|
|
|
|
|
export async function getChart (id) {
|
|
|
|
|
|
return await getData(`${api.chart}/${id}`)
|
2021-06-11 23:00:33 +08:00
|
|
|
|
}
|
2021-08-11 22:14:23 +08:00
|
|
|
|
/* entity列表 */
|
|
|
|
|
|
export async function getEntityList (params) {
|
|
|
|
|
|
return await getData(api.entityList, params, true)
|
2021-07-07 22:58:52 +08:00
|
|
|
|
}
|
2021-08-11 22:14:23 +08:00
|
|
|
|
/* entity总数 */
|
|
|
|
|
|
export async function getEntityCount (params) {
|
|
|
|
|
|
return await getData(api.entityCount, params)
|
2021-07-09 10:10:06 +08:00
|
|
|
|
}
|
2021-08-11 22:14:23 +08:00
|
|
|
|
/* ip类型entity过滤器数据 */
|
|
|
|
|
|
export async function getEntityFilter (params) {
|
|
|
|
|
|
return await getData(api.entityFilter, params, true)
|
2021-07-09 10:10:06 +08:00
|
|
|
|
}
|
2021-06-22 21:19:04 +08:00
|
|
|
|
/* 字典 */
|
|
|
|
|
|
export async function getDictList (params) {
|
|
|
|
|
|
return await getData(api.dict, params, true)
|
|
|
|
|
|
}
|
2022-03-12 16:56:46 +08:00
|
|
|
|
function handleResult (response) {
|
|
|
|
|
|
if (response.data.list || response.data.result) {
|
|
|
|
|
|
return response.data.list || response.data.result
|
|
|
|
|
|
} else if (response.data.result === 0) {
|
|
|
|
|
|
return response.data.result
|
|
|
|
|
|
} else {
|
|
|
|
|
|
return response.data
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2021-06-20 13:31:55 +08:00
|
|
|
|
export async function getData (url, params = {}, isQueryList) {
|
2021-08-11 22:14:23 +08:00
|
|
|
|
const request = new Promise((resolve, reject) => {
|
|
|
|
|
|
try {
|
|
|
|
|
|
get(url, params).then(response => {
|
|
|
|
|
|
if (response.code === 200) {
|
2022-03-12 16:56:46 +08:00
|
|
|
|
resolve(handleResult(response))
|
2021-08-11 22:14:23 +08:00
|
|
|
|
} else {
|
|
|
|
|
|
reject(response)
|
|
|
|
|
|
}
|
|
|
|
|
|
})
|
|
|
|
|
|
} catch (e) {
|
|
|
|
|
|
reject(e)
|
|
|
|
|
|
}
|
|
|
|
|
|
}).catch(response => {
|
|
|
|
|
|
console.error(response)
|
2021-06-11 23:00:33 +08:00
|
|
|
|
})
|
|
|
|
|
|
return await request
|
|
|
|
|
|
}
|
2021-06-22 21:19:04 +08:00
|
|
|
|
|
|
|
|
|
|
export async function getConfigJson () {
|
|
|
|
|
|
const request = new Promise(resolve => {
|
|
|
|
|
|
get(`${process.env.BASE_URL}config.json?Timestamp=${new Date().getTime()}`).then(config => {
|
|
|
|
|
|
resolve(config)
|
|
|
|
|
|
})
|
|
|
|
|
|
})
|
|
|
|
|
|
return await request
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
export async function getPermission () {
|
|
|
|
|
|
const request = new Promise(resolve => {
|
2022-01-03 22:46:22 +08:00
|
|
|
|
post(api.permission, { token: localStorage.getItem('cn-token') }).then(response => {
|
2021-06-22 21:19:04 +08:00
|
|
|
|
resolve({
|
|
|
|
|
|
menuList: sortByOrderNum(response.data.menus),
|
|
|
|
|
|
buttonList: response.data.buttons,
|
|
|
|
|
|
roleList: response.data.roles
|
|
|
|
|
|
})
|
|
|
|
|
|
})
|
|
|
|
|
|
})
|
|
|
|
|
|
return await request
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
export async function getI18n () {
|
2022-02-21 10:52:14 +08:00
|
|
|
|
const dictData = await getDictList({ type: 'lang' })
|
2021-06-22 21:19:04 +08:00
|
|
|
|
const langs = dictData.map(d => d.value).join(',')
|
2022-01-03 22:46:22 +08:00
|
|
|
|
localStorage.setItem(storageKey.languages, langs)
|
2021-06-22 21:19:04 +08:00
|
|
|
|
const request = new Promise(resolve => {
|
|
|
|
|
|
get(api.i18n, { l: langs }).then(response => {
|
2021-07-21 16:02:44 +08:00
|
|
|
|
response.data.cn = response.data.zh
|
2021-06-22 21:19:04 +08:00
|
|
|
|
resolve(response.data)
|
|
|
|
|
|
})
|
|
|
|
|
|
})
|
|
|
|
|
|
return await request
|
|
|
|
|
|
}
|
2021-07-01 15:39:48 +08:00
|
|
|
|
|
2021-07-05 17:40:43 +08:00
|
|
|
|
/* 获得原始的3611-2 json字符串数据 */
|
|
|
|
|
|
export async function getIso36112JsonData (suffix) {
|
|
|
|
|
|
const request = new Promise(resolve => {
|
2021-10-16 15:50:12 +08:00
|
|
|
|
axios({
|
2021-11-11 23:28:52 +08:00
|
|
|
|
url: `${window.location.protocol}//${window.location.host}:${window.location.port}/geojson/${suffix}.json`
|
2021-10-16 15:50:12 +08:00
|
|
|
|
}).then(response => {
|
|
|
|
|
|
resolve(response.data || response || null)
|
2021-07-05 17:40:43 +08:00
|
|
|
|
})
|
2021-07-01 15:39:48 +08:00
|
|
|
|
})
|
2021-07-05 17:40:43 +08:00
|
|
|
|
return await request
|
2021-07-01 15:39:48 +08:00
|
|
|
|
}
|