import { reqCatchV2, type catchRt } from '@/utils/catch'; import request from '@/utils/request'; import * as types from '@/api/repo/types'; import axios from 'axios'; // 详情-获取版本信息 export function releaseInfo(params: { softwareId: string }): Promise { const { softwareId } = params; return request({ url: `/api/v1/repo/release/info?softwareId=${softwareId}`, method: 'get' }); } // 详情-搜索结果列表 export function releasePage(data): Promise { return request({ url: `/api/v1/repo/release/page`, method: 'post', data }); } // 获取邀请列表 export function getInviteListData(): catchRt { return reqCatchV2(() => request( { url: '/api/v1/group/member/invite/list', method: 'get' }, { customError: true } ) ); } // 处理邀请 export function acceptInvite(params): catchRt { return reqCatchV2(() => request( { url: '/api/v1/group/member/invite/accept', method: 'post', data: params }, { customError: true } ) ); } // 发送订阅 export function subscribeSoftware(params): catchRt { return reqCatchV2(() => request( { url: '/api/v1/alert/subscribe', method: 'post', data: params }, { customError: true } ) ); } // 获取高级筛选语言列表 export function searchLanguageList() { return request({ url: `/api/v1/repo/lan/list`, method: 'get' }); } // 获取首页公告列表 export function getHomeNoticeList() { return request({ url: '/api/v1/home/notice/list', method: 'get', params: {} }); } // 获取依赖关系列表 export function getDepencyList(softwareId: string) { return request({ url: '/api/v1/repo/dependency/info', method: 'POST', data: { softwareId: 47, current: 1, size: 20 } }); } // 获取AI修复建议 export function getRepairInfo(data) { return request({ url: '/api/v1/repo/repair/info', method: 'POST', data }); } // 可信软件详情-AI 修复建议接口 export const remediationSearchRemediations = (data): Promise => { return reqCatchV2(() => request({ url: '/api/v1/repo/repair/info', method: 'POST', data }) ); }; // 获取许可证列表 export function getLicenseList(data) { return request({ url: '/api/v1/repo/license/info', method: 'POST', data }); } // 获取详情漏洞列表 export function getVulnerabilityList() { return request({ url: '/api/v1/repo/vulnerability/page', method: 'GET', params: { current: 1, size: 10, softwareId: 47 } }); } // 获取漏洞数据 export const getVulnList = (data): Promise => { return reqCatchV2(() => request({ url: `/api/v1/repo/vulnerability/page`, method: 'post', data }) ); }; // 获取SBOM依赖树 export const dependencyTree = (data: any): Promise => { return reqCatchV2(() => request({ url: `/api/v1/repo/dependency/tree`, method: 'POST', data }) ); }; // 获取开发者社区信息 export const communityInfo = (softwareId: any): Promise => { return reqCatchV2(() => request({ url: `/api/v1/repo/community/info`, method: 'POST', data: { softwareId } }) ); }; // 编辑用户信息(包含订阅默认预警方式) export const userEdit = (data: any): Promise => { return reqCatchV2(() => request({ url: `/api/v1/user/edit`, method: 'POST', data }) ); }; // 获取漏洞数据 export const getVulnDetail = (data): Promise => { return reqCatchV2(() => request({ url: `/api/v1/repo/vulnerability/info`, method: 'POST', data }) ); }; // 迁移批量导入 export function repoImport(data: types.commonRepoReqType) { return reqCatchV2(() => request({ url: `/api/v1/home/software/valid`, method: 'post', data, headers: { 'Content-Type': 'multipart/form-data' // 设置请求头 } }) ); } // 个人中心-获取预警列表 export const getNoticeList = (data): Promise => { return reqCatchV2(() => request({ url: `/api/v1/alert/notice/list`, method: 'POST', data }) ); }; // 个人中心-获取组织级预警列表 export const getgroupNoticeList = (data): Promise => { return reqCatchV2(() => request({ url: `/api/v1/alert/group/notice/list`, method: 'POST', data }) ); }; // 个人中心-获取订阅列表 export const getSubscribeList = (data): Promise => { return reqCatchV2(() => request({ url: `/api/v1/alert/subscribe/list`, method: 'POST', data, }) ); } // 个人中心-获取组织级订阅列表 export const getGroupSubscribeList = (data): Promise => { return reqCatchV2(() => request({ url: `/api/v1/alert/group/subscribe/list`, method: 'POST', data, }) ); } // 搜索结果导出接口 export const getReleaseExport = (data): Promise => { return reqCatchV2(() => request({ url: `/api/v1/repo/release/export`, method: 'POST', data, responseType: 'blob' // 关键:告诉axios这是二进制数据 }) ); } // 获取AI修复建议 export function getVulSuggestion(data) { return axios.request({ url: '/gateway/detect' + `/ai/vul_suggestion`, method: 'POST', data, headers: { Authorization: 'Bearer ' + localStorage.getItem('access_token'), }, }); } // 许可证信息详情 export const getLicenseDetail = ({ id }): Promise => { return reqCatchV2(() => request({ url: `/api/v1/repo/license/detail/${id}`, method: 'get', }) ); }; // 是否订阅 export const alertIsSubscribe = (data): Promise => { return reqCatchV2(() => request({ url: `/api/v1/alert/isSubscribe`, method: 'POST', data, }) ); }; // 获取邀请历史 export function getInviteHistoryData(): catchRt { return reqCatchV2(() => request( { url: `/api/v1/group/member/invite/history`, method: 'get' }, { customError: true } ) ); } // 删除个人邀请历史记录 export function acceptHistoryDelete(params): catchRt { return reqCatchV2(() => request( { url: '/api/v1/group/member/invite/history/delete', method: 'post', data: params }, { customError: true } ) ); }