import { request } from "@umijs/max"; import qs from "query-string"; type ObjType = Record; // user info export async function currentUser(options?: ObjType) { return request("/auth/info", { method: "GET", timeout: 5000, ...(options || {}), }); } // Logout export async function outLogin(options?: ObjType) { return request("/auth/logout", { method: "GET", ...(options || {}), }); } export async function changeUserPass( data: API.ChangeUserPassParams, options?: ObjType, ) { return request>("/auth/update-password", { method: "POST", data: qs.stringify(data), ...(options || {}), headers: { "Content-Type": "application/x-www-form-urlencoded", }, }); } // Login export async function login(data: API.LoginParams, options?: ObjType) { return request("/auth/login", { method: "POST", data, ...(options || {}), }); } // company export async function getCompanyList( params?: { name?: string; status?: number; }, options?: ObjType, ) { return request("/company/list", { method: "GET", params, ...(options || {}), }); } export async function getCompanyDetail( id: number | string, options?: ObjType, ) { return request(`/company/${id}`, { method: "GET", ...(options || {}), }); } export async function getCompanyPages( params: { name?: string; } & API.PageParams, options?: ObjType, ) { return request<{ data: API.CompanyData; }>("/company/page", { method: "GET", params, ...(options || {}), }); } export async function companyHandle( data: { id?: number; name?: string; email?: string; status?: number; validityStartTime?: string | null; validityEndTime?: string | null; }, options?: ObjType, ) { return request("/company", { method: data.id !== void 0 ? "PUT" : "POST", data, ...(options || {}), }); } // data source export async function getDataSourceList( params?: { sourceName?: string; sourceType?: number; status?: number }, options?: ObjType, ) { return request<{ data: { data: API.DataSourceListItem[]; }; }>("/data-source/list", { method: "GET", params, ...(options || {}), }); } export async function getDataSourcePages( params: API.PageParams, options?: ObjType, ) { return request<{ data: API.DataSourceData; }>("/data-source/page", { method: "GET", params, ...(options || {}), }); } export async function dataSourceHandle( data: Partial, options?: ObjType, ) { return request("/data-source", { method: data.id !== void 0 ? "PUT" : "POST", data, ...(options || {}), }); } export async function dataSourceDelete( params: { id: number | string; }, options?: ObjType, ) { return request(`/data-source/${params.id}`, { method: "DELETE", ...(options || {}), }); } // user export async function getUserList(options?: ObjType) { return request("/user/list", { method: "GET", ...(options || {}), }); } export async function getUserDetail(id: number | string, options?: ObjType) { return request(`/auth/user/${id}`, { method: "GET", ...(options || {}), }); } export async function getUserPages( params: API.PageParams & { companyId?: number | string; email?: string; }, options?: ObjType, ) { return request<{ data: API.UserData; }>("/auth/user/page", { method: "GET", params, ...(options || {}), }); } export async function userHandle( data: Partial, options?: ObjType, ) { const hasId = data.id !== void 0; return request(`/auth/user${hasId ? `/update` : "/add"}`, { method: hasId ? "PUT" : "POST", data, ...(options || {}), }); } export async function userDelete( params: { id: number | string; }, options?: ObjType, ) { return request(`/auth/user/${params.id}`, { method: "DELETE", ...(options || {}), }); } // trade account export async function getAccountList(options?: ObjType) { return request("/account/list", { method: "GET", ...(options || {}), }); } export async function getAccountInfo(id: number | string, options?: ObjType) { return request(`/trade-account/${id}`, { method: "GET", ...(options || {}), }); } export async function getAccountPages( params: API.PageParams & { dataSourceId?: number; companyId?: number; platformId?: string; }, options?: ObjType, ) { return request<{ data: API.TradeAccountData; }>("/trade-account/page", { method: "GET", params, skip417Error: true, ...(options || {}), }); } // alert export async function getAlertList(options?: ObjType) { return request("/alert/list", { method: "GET", ...(options || {}), }); } export async function alertAllRead(options?: ObjType) { return request("/alert-record/batch-view", { method: "GET", ...(options || {}), }); } export async function getAlertPages( params: API.PageParams & API.AlertRequestParams & { sortJson?: string; }, options?: ObjType, ) { let url = "/alert-record/page"; if (params.sortJson) { url += `?sortJson=${params.sortJson}`; delete params.sortJson; } return request(url, { method: "GET", params, skip417Error: true, skip401Refresh: true, ...(options || {}), }); } export async function getAlertDetail(id: number | string, options?: ObjType) { return request(`/alert-record/${id}`, { method: "GET", skip417Error: true, skip401Refresh: true, ...(options || {}), }); } export async function alertDataExport( params: API.PageParams & API.AlertRequestParams, options?: ObjType, ) { return request(`/alert-record/excel/export`, { params, method: "GET", responseType: "blob", getResponse: true, ...(options || {}), }); } export async function alertStatusHandle( params: { id: number | string; status: number; }, options?: ObjType, ) { return request(`/alert-record/${params.id}/${params.status}`, { method: "DELETE", ...(options || {}), }); } // role export async function getRoleList( params?: { name?: string; companyId?: number | string }, options?: ObjType, ) { return request("/role/list", { method: "GET", params, ...(options || {}), }); } export async function getRoleDetail( params: { id: number | string; }, options?: ObjType, ) { return request(`/role/${params.id}`, { method: "GET", ...(options || {}), }); } export async function getRolePages( params: API.PageParams & { companyId?: number | string; }, options?: ObjType, ) { return request<{ data: API.RolesListData; }>("/role/page", { method: "GET", params, ...(options || {}), }); } export async function roleHandle( data: { id?: number; mark?: string; name?: string; level?: number; menuIds?: string; }, options?: ObjType, ) { return request("/role", { method: data.id !== void 0 ? "PUT" : "POST", data, ...(options || {}), }); } // rule export async function getRuleList( params?: { type: string | number; dataSourceId?: string | number; }, options?: ObjType, ) { return request("/rule/list", { method: "GET", params, ...(options || {}), }); } export async function getRulePages( params: API.PageParams & { type: string | number; dataSourceId?: string | number; }, options?: ObjType, ) { return request<{ data: API.RuleData; }>("/rule/page", { method: "GET", params, skip417Error: true, ...(options || {}), }); } export async function getRuleDetail(id: number | string, options?: ObjType) { return request(`/rule/${id}`, { method: "GET", skip401Refresh: true, ...(options || {}), }); } export async function ruleHandle( data: Partial, options?: ObjType, ) { return request("/rule", { method: data.id !== void 0 ? "PUT" : "POST", data, ...(options || {}), }); } export async function ruleStatusHandle( data: Partial, options?: ObjType, ) { return request(`/rule/${data.id}/${data.status}`, { method: "DELETE", data, ...(options || {}), }); } // product/symbol export async function getSymbolList( params: { dataSourceId: string | number }, options?: ObjType, ) { return request<{ data: { data: API.SymbolDataItem[]; }; }>("/symbol/list", { method: "GET", params, ...(options || {}), }); } export async function getProductList(options?: ObjType) { return request("/product/list", { method: "GET", ...(options || {}), }); } export async function getProductPages( params: API.PageParams, options?: ObjType, ) { return request("/product-mapper/page", { method: "GET", params, ...(options || {}), }); } export async function productHandle( data: Partial, options?: ObjType, ) { return request("/product-mapper", { method: data.id !== void 0 ? "PUT" : "POST", data, ...(options || {}), }); } export async function productDelete( params: { id: number | string; }, options?: ObjType, ) { return request(`/product-mapper/${params.id}`, { method: "DELETE", ...(options || {}), }); } export async function productCateHandle( data: Partial, options?: ObjType, ) { return request("/product-category", { method: data.id !== void 0 ? "PUT" : "POST", data, ...(options || {}), }); } export async function getProductCates(options?: ObjType) { return request("/product-category/list", { method: "GET", ...(options || {}), }); } // email-service export async function getEmailConfigDetail( id: number | string, options?: ObjType, ) { return request(`/mail-host-config/${id}`, { method: "GET", ...(options || {}), }); } export async function emailConfigTest( params: { email: string; id: number | string; }, options?: ObjType, ) { return request('/mail-host-config/test', { method: "GET", params, ...(options || {}), }); } export async function emailConfigDelete( id: number | string, options?: ObjType, ) { return request(`/mail-host-config/${id}`, { method: "DELETE", ...(options || {}), }); } export async function getEmailConfigList( options?: ObjType, ) { return request("/mail-host-config/list", { method: "GET", ...(options || {}), }); } export async function getEmailConfigPages( params: API.PageParams, options?: ObjType, ) { return request("/mail-host-config/page", { method: "GET", params, ...(options || {}), }); } export async function emailConfigHandle( data: Partial, options?: ObjType, ) { return request("/mail-host-config", { method: data.id !== void 0 ? "PUT" : "POST", data, ...(options || {}), }); } // oper log export async function getOperLogPages( params: API.PageParams, options?: ObjType, ) { return request("/oper-log/page", { method: "GET", params, ...(options || {}), }); } export async function getOperLogAction(options?: ObjType) { return request("/oper-log/list", { method: "GET", ...(options || {}), }); } export async function getUserConfig(options?: ObjType) { return request("/user-config/show", { method: "GET", ...(options || {}), }); } export async function userNoticeTest(params: ObjType, options?: ObjType) { return request("/user-config/test", { method: "GET", params, ...(options || {}), }); } export async function userConfigUpdate( data: Partial, options?: ObjType, ) { return request(`/user-config/update`, { method: "POST", data, ...(options || {}), }); } export async function userUpdateLang( data: { lang: string; }, options?: ObjType, ) { return request(`/user-config/updateLang`, { method: "POST", data: qs.stringify(data), ...(options || {}), headers: { "Content-Type": "application/x-www-form-urlencoded", }, }); } export async function getTimeZoneList(options?: ObjType) { return request("/system/time-zone-list", { method: "GET", ...(options || {}), }); } export async function getRuleTypeList(options?: ObjType) { return request("/system/rule-type-list", { method: "GET", ...(options || {}), }); } export async function closeSSEWithApi(options?: ObjType) { return request("/sse/close", { method: "DELETE", ...(options || {}), }); } export async function getPlatformList(options?: ObjType) { return request("/system/platform-list", { method: "GET", ...(options || {}), }); } export async function getDashboardTotal(options?: ObjType) { return request("/dashboard/total", { method: "GET", ...(options || {}), }); } export async function getDashboardAlertTrend( params: { startDate: string; endDate: string }, options?: ObjType, ) { return request("/dashboard/alert-trend", { params, method: "GET", ...(options || {}), }); } export async function getDashboardRuleTrigger( params: { startDate: string; endDate: string }, options?: ObjType, ) { return request("/dashboard/rule-triggered-distribution", { params, method: "GET", ...(options || {}), }); } export async function testSSESend(data: any, options?: ObjType) { return request(`/sse/send`, { method: "POST", data, ...(options || {}), }); } export async function getGroupList( params: { dataSourceId: string | number }, options?: ObjType, ) { return request("/group/list", { params, method: "GET", ...(options || {}), }); }