| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198 |
- import { defHttp } from '@jeesite/core/utils/http/axios';
- import { useGlobSetting } from '@jeesite/core/hooks/setting';
- import type { Result } from '@jeesite/types/axios';
- import type { FileInfo } from '@jeesite/types/api';
- import { CalcTaskDTO, DataTableDTO, DoCleanDTO, GovernTree, PrepareProcessFileDTO } from './types/dto';
- import { Query } from '@jeesite/types';
- import { GovernTreeQuery } from './types/query';
- const { adminPath } = useGlobSetting();
- const DEFAULT_ELECTRON_API_URL = 'http://localhost:8980';
- const trimRightSlash = (value = '') => value.replace(/\/+$/, '');
- const ensureLeftSlash = (value = '') => (value.startsWith('/') ? value : `/${value}`);
- const joinUrl = (...parts: Array<string | undefined>) => {
- const filtered = parts.filter(Boolean) as string[];
- if (!filtered.length) return '';
- return filtered
- .map((part, index) => {
- if (index === 0) return trimRightSlash(part);
- return ensureLeftSlash(part).replace(/\/+$/, '');
- })
- .join('');
- };
- const getRuntimeOrigin = () => {
- if (typeof window === 'undefined') return '';
- const { origin, protocol } = window.location;
- if (protocol !== 'http:' && protocol !== 'https:') return '';
- return origin && origin !== 'null' ? origin : '';
- };
- const getPackagedFallbackOrigin = () => {
- if (typeof window === 'undefined') return '';
- return window.location.protocol === 'file:' ? DEFAULT_ELECTRON_API_URL : '';
- };
- export const getAdminBaseUrl = () => {
- const { apiUrl, urlPrefix, adminPath } = useGlobSetting();
- if (adminPath?.startsWith('http')) {
- return trimRightSlash(adminPath);
- }
- const prefix = urlPrefix || '';
- const normalizedAdminPath =
- prefix && adminPath?.startsWith(`${prefix}/`) ? adminPath : joinUrl(prefix, adminPath || '/a');
- const host = trimRightSlash(apiUrl || '') || getRuntimeOrigin() || getPackagedFallbackOrigin();
- return joinUrl(host, normalizedAdminPath);
- };
- export const getGovernTaskSseUrl = () => joinUrl(getAdminBaseUrl(), '/govern/sse');
- export const getGovernSseUrl = getGovernTaskSseUrl;
- export interface GovernConfItem {
- id?: ApiId | number;
- confStr?: 'Y' | 'N' | ApiText;
- confType?: 'useOpenInfo' | 'hasGovern' | 'duplicate' | 'other' | ApiText;
- }
- export interface CleanErrorLogItem {
- id?: ApiId | number;
- fileId?: ApiId | number;
- sheetId?: ApiId | number;
- fileName?: ApiText | null;
- sheetName?: ApiText | null;
- content?: ApiText | null;
- createDateTime?: ApiDateString;
- }
- export interface CleanErrorLogQuery extends Query {
- batchId?: ApiId | number;
- fileId?: ApiId | number;
- sheetId?: ApiId | number;
- }
- export interface CleanErrorLogPage {
- records?: ApiList<CleanErrorLogItem>;
- total?: ApiCount;
- size?: ApiCount;
- current?: ApiCount;
- pages?: ApiCount;
- }
- // ==================== 治理任务管理 ====================
- /**
- * SSE连接建立 - 创建Server-Sent Events连接
- */
- export const sse = (params?: Recordable) => defHttp.get<void>({ url: adminPath + '/govern/sse', params });
- /**
- * 测试 SSE 推送
- */
- export const testSse = () => defHttp.get<void>({ url: adminPath + '/govern/sse/put' });
- /**
- * 启动治理计算任务
- */
- export const calcTask = (params: CalcTaskDTO) => defHttp.get<void>({ url: adminPath + '/govern/calcTask', params });
- // ==================== 治理树结构管理 ====================
- /**
- * 获取治理树结构
- */
- export const getTree = () => defHttp.get<GovernTree[]>({ url: adminPath + '/gt/tree' });
- /**
- * 获取治理树表格分页数据
- */
- export const treeTablePage = (data: GovernTreeQuery) =>
- defHttp.postJson<DataTableDTO>({ url: adminPath + '/gt/treeTablePage', data });
- /**
- * 获取治理树关联的交易人员分页数据
- */
- export const getTreeTransPersonPage = (data: GovernTreeQuery) =>
- defHttp.postJson<DataTableDTO>({ url: adminPath + '/gt/getTreeTransPersonPage', data });
- /**
- * 获取治理树关联的交易银行卡分页数据
- */
- export const getTreeTransBankPage = (data: GovernTreeQuery) =>
- defHttp.postJson<DataTableDTO>({ url: adminPath + '/gt/getTreeTransBankPage', data });
- /**
- * 获取治理树关联的通话人员分页数据
- */
- export const getTreeCallPersonPage = (data: GovernTreeQuery) =>
- defHttp.postJson<DataTableDTO>({ url: adminPath + '/gt/getTreeCallPersonPage', data });
- /**
- * 获取治理树关联的通话对方号码分页数据
- */
- export const getTreeCallOperPage = (data: GovernTreeQuery) =>
- defHttp.postJson<DataTableDTO>({ url: adminPath + '/gt/getTreeCallOperPage', data });
- /**
- * 获取治理树关联的开户使用本人信息分页数据
- */
- export const getTreeCallPersonUseOpenInfoPage = (data: GovernTreeQuery) =>
- defHttp.postJson<Result>({ url: adminPath + '/gt/getTreeCallPersonUseOpenInfoPage', data });
- /**
- * 获取治理树关联的开户使用对方信息分页数据
- */
- export const getTreeCallOperUseOpenInfoPage = (data: GovernTreeQuery) =>
- defHttp.postJson<Result>({ url: adminPath + '/gt/getTreeCallOperUseOpenInfoPage', data });
- // ==================== 数据管理 ====================
- /**
- * 执行数据清洗
- */
- export const doClean = (data: DoCleanDTO) => defHttp.postJson<Recordable>({ url: adminPath + '/dm/doClean', data });
- /**
- * 文件预处理
- */
- export const preFile = (data: PrepareProcessFileDTO) =>
- defHttp.postJson<FileInfo[]>({ url: adminPath + '/dm/preFile', data });
- /**
- * 取消清洗任务
- */
- export const cancelClean = (params: { batchId?: ApiId | number }) =>
- defHttp.get<void>({ url: adminPath + '/dm/cancelClean', params });
- /**
- * 已导入文件列表
- * @param data
- * @returns
- */
- export const importFileList = (data: Query) => defHttp.postJson<FileInfo[]>({ url: adminPath + '/dm/getFiles', data });
- /**
- * 已删除文件列表
- * @param data
- * @returns
- */
- export const deletedFileList = (data: { ids: string[] }) =>
- defHttp.postJson<void>({ url: adminPath + '/dm/deletedFiles', data });
- /**
- * 获取治理配置
- */
- export const getGovernConfList = () => defHttp.get<GovernConfItem[]>({ url: adminPath + '/dm/getGovernConfList' });
- /**
- * 保存治理配置
- */
- export const saveGovernConf = (data: GovernConfItem[]) =>
- defHttp.postJson<void>({ url: adminPath + '/dm/saveGovernCon', data });
- /**
- * 获取清洗错误日志列表
- */
- export const cleanErrorLogList = (params: Partial<CleanErrorLogQuery>) =>
- defHttp.get<CleanErrorLogPage>({ url: adminPath + '/cleanLog/list', params });
|