common.ts 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616
  1. import type { Fetcher } from 'swr'
  2. import { del, download, get, patch, post, put, upload } from './base'
  3. import type {
  4. AccountIntegrate,
  5. ApiBasedExtension,
  6. CodeBasedExtension,
  7. CommonResponse,
  8. DataSourceNotion,
  9. FileUploadConfigResponse,
  10. ICurrentWorkspace,
  11. IWorkspace,
  12. InitValidateStatusResponse,
  13. InvitationResponse,
  14. LangGeniusVersionResponse,
  15. Member,
  16. ModerateResponse,
  17. OauthResponse,
  18. PluginProvider,
  19. Provider,
  20. ProviderAnthropicToken,
  21. ProviderAzureToken,
  22. SetupStatusResponse,
  23. UserProfileOriginResponse,
  24. } from '@/models/common'
  25. import type {
  26. UpdateOpenAIKeyResponse,
  27. ValidateOpenAIKeyResponse,
  28. } from '@/models/app'
  29. import type {
  30. DefaultModelResponse,
  31. Model,
  32. ModelItem,
  33. ModelLoadBalancingConfig,
  34. ModelParameterRule,
  35. ModelProvider,
  36. ModelTypeEnum,
  37. } from '@/app/components/header/account-setting/model-provider-page/declarations'
  38. import type { RETRIEVE_METHOD } from '@/types/app'
  39. import type { SystemFeatures } from '@/types/feature'
  40. type LoginSuccess = {
  41. result: 'success'
  42. data: { access_token: string; refresh_token: string }
  43. }
  44. type LoginFail = {
  45. result: 'fail'
  46. data: string
  47. code: string
  48. message: string
  49. }
  50. type LoginResponse = LoginSuccess | LoginFail
  51. export const login: Fetcher<LoginResponse, { url: string; body: Record<string, any> }> = ({ url, body }) => {
  52. return post(url, { body }) as Promise<LoginResponse>
  53. }
  54. export const fetchNewToken: Fetcher<CommonResponse & { data: { access_token: string; refresh_token: string } }, { body: Record<string, any> }> = ({ body }) => {
  55. return post('/refresh-token', { body }) as Promise<CommonResponse & { data: { access_token: string; refresh_token: string } }>
  56. }
  57. export const setup: Fetcher<CommonResponse, { body: Record<string, any> }> = ({ body }) => {
  58. return post<CommonResponse>('/setup', { body })
  59. }
  60. export const initValidate: Fetcher<CommonResponse, { body: Record<string, any> }> = ({ body }) => {
  61. return post<CommonResponse>('/init', { body })
  62. }
  63. export const fetchInitValidateStatus = () => {
  64. return get<InitValidateStatusResponse>('/init')
  65. }
  66. export const fetchSetupStatus = () => {
  67. return get<SetupStatusResponse>('/setup')
  68. }
  69. export const fetchUserProfile: Fetcher<UserProfileOriginResponse, { url: string; params: Record<string, any> }> = ({ url, params }) => {
  70. return get<UserProfileOriginResponse>(url, params, { needAllResponseContent: true })
  71. }
  72. export const updateUserProfile: Fetcher<CommonResponse, { url: string; body: Record<string, any> }> = ({ url, body }) => {
  73. return post<CommonResponse>(url, { body })
  74. }
  75. export const logout: Fetcher<CommonResponse, { url: string; params: Record<string, any> }> = ({ url, params }) => {
  76. return get<CommonResponse>(url, params)
  77. }
  78. export const fetchLanggeniusVersion: Fetcher<LangGeniusVersionResponse, { url: string; params: Record<string, any> }> = ({ url, params }) => {
  79. return get<LangGeniusVersionResponse>(url, { params })
  80. }
  81. export const oauth: Fetcher<OauthResponse, { url: string; params: Record<string, any> }> = ({ url, params }) => {
  82. return get<OauthResponse>(url, { params })
  83. }
  84. export const oneMoreStep: Fetcher<CommonResponse, { url: string; body: Record<string, any> }> = ({ url, body }) => {
  85. return post<CommonResponse>(url, { body })
  86. }
  87. export const fetchMembers: Fetcher<{ accounts: Member[] | null }, { url: string; params: Record<string, any> }> = ({ url, params }) => {
  88. return get<{ accounts: Member[] | null }>(url, { params })
  89. }
  90. export const fetchTypes = ({ url, params }: any) => {
  91. console.log('查询类型列表')
  92. return get(url, { params })
  93. }
  94. export const fetchKnowledges = ({ url, params }: any) => {
  95. console.log('查询知识服务', params, url)
  96. return get(url, { params })
  97. }
  98. export const fetchMoulds = ({ url, params }: any) => {
  99. console.log('查询知识库模板', params, url)
  100. return get<{ accounts: Member[] | null }>(url, { params })
  101. }
  102. export const fetchProviders: Fetcher<Provider[] | null, { url: string; params: Record<string, any> }> = ({ url, params }) => {
  103. return get<Provider[] | null>(url, { params })
  104. }
  105. export const validateProviderKey: Fetcher<ValidateOpenAIKeyResponse, { url: string; body: { token: string } }> = ({ url, body }) => {
  106. return post<ValidateOpenAIKeyResponse>(url, { body })
  107. }
  108. export const updateProviderAIKey: Fetcher<UpdateOpenAIKeyResponse, { url: string; body: { token: string | ProviderAzureToken | ProviderAnthropicToken } }> = ({ url, body }) => {
  109. return post<UpdateOpenAIKeyResponse>(url, { body })
  110. }
  111. export const fetchAccountIntegrates: Fetcher<{ data: AccountIntegrate[] | null }, { url: string; params: Record<string, any> }> = ({ url, params }) => {
  112. return get<{ data: AccountIntegrate[] | null }>(url, { params })
  113. }
  114. export const inviteMember: Fetcher<InvitationResponse, { url: string; body: Record<string, any> }> = ({ url, body }) => {
  115. return post<InvitationResponse>(url, { body })
  116. }
  117. export const updateMemberRole: Fetcher<CommonResponse, { url: string; body: Record<string, any> }> = ({ url, body }) => {
  118. return put<CommonResponse>(url, { body })
  119. }
  120. export const deleteMemberOrCancelInvitation: Fetcher<CommonResponse, { url: string }> = ({ url }) => {
  121. return del<CommonResponse>(url)
  122. }
  123. export const addType = ({ url, body }: any) => {
  124. console.log('新增类型', url, body)
  125. return post(url, { body })
  126. }
  127. export const editType = ({ url, body }: any) => {
  128. console.log('编辑类型', url, body)
  129. return patch(url, { body })
  130. }
  131. export const delType = ({ url, body }: any) => {
  132. console.log('删除类型', url, body)
  133. return del(url, { body })
  134. }
  135. export const addKnowledge = ({ url, body }: any) => {
  136. console.log('新增知识', body, url)
  137. return post(url, { body })
  138. }
  139. export const editKnowledge = ({ url, body }: any) => {
  140. console.log('编辑知识', body, url)
  141. return patch(url, { body })
  142. }
  143. export const delKnowledge = ({ url, body }: any) => {
  144. console.log('删除知识', url, body)
  145. return del(url, { body })
  146. }
  147. export const addMouldFile = ({ url, body }: any) => {
  148. console.log('新增模板文件', body, url)
  149. return upload({
  150. xhr: new XMLHttpRequest(),
  151. data: body,
  152. }, false, url)
  153. }
  154. export const delMouldFile = ({ url, body }: any) => {
  155. console.log('删除模板文件', url)
  156. return del(url)
  157. }
  158. export const downloadMouldFile = ({ url, fileName }: any) => {
  159. console.log('下载模板文件', url, fileName)
  160. return download(url, {}, { fileName })
  161. }
  162. export const handleExamine = ({ url, body }: any) => {
  163. // return post<InvitationResponse>(url, { body })
  164. console.log('处理上下线审核', body)
  165. return new Promise((resolve) => {
  166. setTimeout(() => {
  167. resolve({
  168. result: 'success',
  169. })
  170. }, 1000)
  171. })
  172. }
  173. export const applyExamine = ({ url, body }: any) => {
  174. // return post<InvitationResponse>(url, { body })
  175. console.log('提交上下线审核', body)
  176. return new Promise((resolve) => {
  177. setTimeout(() => {
  178. resolve({
  179. result: 'success',
  180. })
  181. }, 1000)
  182. })
  183. }
  184. export const fetchFilePreview: Fetcher<{ content: string }, { fileID: string }> = ({ fileID }) => {
  185. return get<{ content: string }>(`/files/${fileID}/preview`)
  186. }
  187. export const fetchCurrentWorkspace: Fetcher<ICurrentWorkspace, { url: string; params: Record<string, any> }> = ({ url, params }) => {
  188. return get<ICurrentWorkspace>(url, { params })
  189. }
  190. export const updateCurrentWorkspace: Fetcher<ICurrentWorkspace, { url: string; body: Record<string, any> }> = ({ url, body }) => {
  191. return post<ICurrentWorkspace>(url, { body })
  192. }
  193. export const fetchWorkspaces: Fetcher<{ workspaces: IWorkspace[] }, { url: string; params: Record<string, any> }> = ({ url, params }) => {
  194. return get<{ workspaces: IWorkspace[] }>(url, { params })
  195. }
  196. export const switchWorkspace: Fetcher<CommonResponse & { new_tenant: IWorkspace }, { url: string; body: Record<string, any> }> = ({ url, body }) => {
  197. return post<CommonResponse & { new_tenant: IWorkspace }>(url, { body })
  198. }
  199. export const fetchDataSource: Fetcher<{ data: DataSourceNotion[] }, { url: string }> = ({ url }) => {
  200. return get<{ data: DataSourceNotion[] }>(url)
  201. }
  202. export const syncDataSourceNotion: Fetcher<CommonResponse, { url: string }> = ({ url }) => {
  203. return get<CommonResponse>(url)
  204. }
  205. export const updateDataSourceNotionAction: Fetcher<CommonResponse, { url: string }> = ({ url }) => {
  206. return patch<CommonResponse>(url)
  207. }
  208. export const fetchPluginProviders: Fetcher<PluginProvider[] | null, string> = (url) => {
  209. return get<PluginProvider[] | null>(url)
  210. }
  211. export const validatePluginProviderKey: Fetcher<ValidateOpenAIKeyResponse, { url: string; body: { credentials: any } }> = ({ url, body }) => {
  212. return post<ValidateOpenAIKeyResponse>(url, { body })
  213. }
  214. export const updatePluginProviderAIKey: Fetcher<UpdateOpenAIKeyResponse, { url: string; body: { credentials: any } }> = ({ url, body }) => {
  215. return post<UpdateOpenAIKeyResponse>(url, { body })
  216. }
  217. export const invitationCheck: Fetcher<CommonResponse & { is_valid: boolean; data: { workspace_name: string; email: string; workspace_id: string } }, { url: string; params: { workspace_id?: string; email?: string; token: string } }> = ({ url, params }) => {
  218. return get<CommonResponse & { is_valid: boolean; data: { workspace_name: string; email: string; workspace_id: string } }>(url, { params })
  219. }
  220. export const activateMember: Fetcher<LoginResponse, { url: string; body: any }> = ({ url, body }) => {
  221. return post<LoginResponse>(url, { body })
  222. }
  223. export const fetchModelProviders: Fetcher<{ data: ModelProvider[] }, string> = (url) => {
  224. return get<{ data: ModelProvider[] }>(url)
  225. }
  226. export type ModelProviderCredentials = {
  227. credentials?: Record<string, string | undefined | boolean>
  228. load_balancing: ModelLoadBalancingConfig
  229. }
  230. export const fetchModelProviderCredentials: Fetcher<ModelProviderCredentials, string> = (url) => {
  231. return get<ModelProviderCredentials>(url)
  232. }
  233. export const fetchModelLoadBalancingConfig: Fetcher<{
  234. credentials?: Record<string, string | undefined | boolean>
  235. load_balancing: ModelLoadBalancingConfig
  236. }, string> = (url) => {
  237. return get<{
  238. credentials?: Record<string, string | undefined | boolean>
  239. load_balancing: ModelLoadBalancingConfig
  240. }>(url)
  241. }
  242. export const fetchModelProviderModelList: Fetcher<{ data: ModelItem[] }, string> = (url) => {
  243. return get<{ data: ModelItem[] }>(url)
  244. }
  245. export const fetchModelList: Fetcher<{ data: Model[] }, string> = (url) => {
  246. return get<{ data: Model[] }>(url)
  247. }
  248. export const validateModelProvider: Fetcher<ValidateOpenAIKeyResponse, { url: string; body: any }> = ({ url, body }) => {
  249. return post<ValidateOpenAIKeyResponse>(url, { body })
  250. }
  251. export const validateModelLoadBalancingCredentials: Fetcher<ValidateOpenAIKeyResponse, { url: string; body: any }> = ({ url, body }) => {
  252. return post<ValidateOpenAIKeyResponse>(url, { body })
  253. }
  254. export const setModelProvider: Fetcher<CommonResponse, { url: string; body: any }> = ({ url, body }) => {
  255. return post<CommonResponse>(url, { body })
  256. }
  257. export const deleteModelProvider: Fetcher<CommonResponse, { url: string; body?: any }> = ({ url, body }) => {
  258. return del<CommonResponse>(url, { body })
  259. }
  260. export const changeModelProviderPriority: Fetcher<CommonResponse, { url: string; body: any }> = ({ url, body }) => {
  261. return post<CommonResponse>(url, { body })
  262. }
  263. export const setModelProviderModel: Fetcher<CommonResponse, { url: string; body: any }> = ({ url, body }) => {
  264. return post<CommonResponse>(url, { body })
  265. }
  266. export const deleteModelProviderModel: Fetcher<CommonResponse, { url: string }> = ({ url }) => {
  267. return del<CommonResponse>(url)
  268. }
  269. export const getPayUrl: Fetcher<{ url: string }, string> = (url) => {
  270. return get<{ url: string }>(url)
  271. }
  272. export const fetchDefaultModal: Fetcher<{ data: DefaultModelResponse }, string> = (url) => {
  273. return get<{ data: DefaultModelResponse }>(url)
  274. }
  275. export const updateDefaultModel: Fetcher<CommonResponse, { url: string; body: any }> = ({ url, body }) => {
  276. return post<CommonResponse>(url, { body })
  277. }
  278. export const fetchModelParameterRules: Fetcher<{ data: ModelParameterRule[] }, string> = (url) => {
  279. return get<{ data: ModelParameterRule[] }>(url)
  280. }
  281. export const fetchFileUploadConfig: Fetcher<FileUploadConfigResponse, { url: string }> = ({ url }) => {
  282. return get<FileUploadConfigResponse>(url)
  283. }
  284. export const fetchNotionConnection: Fetcher<{ data: string }, string> = (url) => {
  285. return get(url) as Promise<{ data: string }>
  286. }
  287. export const fetchDataSourceNotionBinding: Fetcher<{ result: string }, string> = (url) => {
  288. return get(url) as Promise<{ result: string }>
  289. }
  290. export const fetchApiBasedExtensionList: Fetcher<ApiBasedExtension[], string> = (url) => {
  291. return get(url) as Promise<ApiBasedExtension[]>
  292. }
  293. export const fetchApiBasedExtensionDetail: Fetcher<ApiBasedExtension, string> = (url) => {
  294. return get(url) as Promise<ApiBasedExtension>
  295. }
  296. export const addApiBasedExtension: Fetcher<ApiBasedExtension, { url: string; body: ApiBasedExtension }> = ({ url, body }) => {
  297. return post(url, { body }) as Promise<ApiBasedExtension>
  298. }
  299. export const updateApiBasedExtension: Fetcher<ApiBasedExtension, { url: string; body: ApiBasedExtension }> = ({ url, body }) => {
  300. return post(url, { body }) as Promise<ApiBasedExtension>
  301. }
  302. export const deleteApiBasedExtension: Fetcher<{ result: string }, string> = (url) => {
  303. return del(url) as Promise<{ result: string }>
  304. }
  305. export const fetchCodeBasedExtensionList: Fetcher<CodeBasedExtension, string> = (url) => {
  306. return get(url) as Promise<CodeBasedExtension>
  307. }
  308. export const moderate = (url: string, body: { app_id: string; text: string }) => {
  309. return post(url, { body }) as Promise<ModerateResponse>
  310. }
  311. type RetrievalMethodsRes = {
  312. retrieval_method: RETRIEVE_METHOD[]
  313. }
  314. export const fetchSupportRetrievalMethods: Fetcher<RetrievalMethodsRes, string> = (url) => {
  315. return get<RetrievalMethodsRes>(url)
  316. }
  317. export const getSystemFeatures = () => {
  318. return get<SystemFeatures>('/system-features')
  319. }
  320. export const enableModel = (url: string, body: { model: string; model_type: ModelTypeEnum }) =>
  321. patch<CommonResponse>(url, { body })
  322. export const disableModel = (url: string, body: { model: string; model_type: ModelTypeEnum }) =>
  323. patch<CommonResponse>(url, { body })
  324. export const sendForgotPasswordEmail: Fetcher<CommonResponse & { data: string }, { url: string; body: { email: string } }> = ({ url, body }) =>
  325. post<CommonResponse & { data: string }>(url, { body })
  326. export const verifyForgotPasswordToken: Fetcher<CommonResponse & { is_valid: boolean; email: string }, { url: string; body: { token: string } }> = ({ url, body }) => {
  327. return post(url, { body }) as Promise<CommonResponse & { is_valid: boolean; email: string }>
  328. }
  329. export const changePasswordWithToken: Fetcher<CommonResponse, { url: string; body: { token: string; new_password: string; password_confirm: string } }> = ({ url, body }) =>
  330. post<CommonResponse>(url, { body })
  331. export const uploadRemoteFileInfo = (url: string, isPublic?: boolean) => {
  332. return post<{ id: string; name: string; size: number; mime_type: string; url: string }>('/remote-files/upload', { body: { url } }, { isPublicAPI: isPublic })
  333. }
  334. export const sendEMailLoginCode = (email: string, language = 'en-US') =>
  335. post<CommonResponse & { data: string }>('/email-code-login', { body: { email, language } })
  336. export const emailLoginWithCode = (data: { email: string; code: string; token: string }) =>
  337. post<LoginResponse>('/email-code-login/validity', { body: data })
  338. export const sendResetPasswordCode = (email: string, language = 'en-US') =>
  339. post<CommonResponse & { data: string; message?: string; code?: string }>('/forgot-password', { body: { email, language } })
  340. export const verifyResetPasswordCode = (body: { email: string; code: string; token: string }) =>
  341. post<CommonResponse & { is_valid: boolean }>('/forgot-password/validity', { body })
  342. export const sendDeleteAccountCode = () =>
  343. get<CommonResponse & { data: string }>('/account/delete/verify')
  344. export const verifyDeleteAccountCode = (body: { code: string; token: string }) =>
  345. post<CommonResponse & { is_valid: boolean }>('/account/delete', { body })
  346. export const submitDeleteAccountFeedback = (body: { feedback: string; email: string }) =>
  347. post<CommonResponse>('/account/delete/feedback', { body })
  348. export const getDocDownloadUrl = (doc_name: string) =>
  349. get<{ url: string }>('/compliance/download', { params: { doc_name } }, { silent: true })
  350. export const fetchStatistic = ({ url, params }: any) => {
  351. console.log('查询知识总览', url, params)
  352. return get(url, { params })
  353. }
  354. export const fetchLog = ({ url, params }: any) => {
  355. console.log('查询训练日志列表', url, params)
  356. // return get(url, { params })
  357. return new Promise((resolve) => {
  358. setTimeout(() => {
  359. const arr: any = []
  360. for (let i = 1; i < 10; i++) {
  361. arr.push({
  362. id: i,
  363. version: `${i}.${i}.${i}`,
  364. time: '2022-02-02 02:21:23',
  365. })
  366. }
  367. resolve({
  368. data: [],
  369. has_more: false,
  370. limit: 10,
  371. total: 0,
  372. page: 1,
  373. })
  374. }, 1000)
  375. })
  376. }
  377. export const fetchIntentType = ({ url, params }: any) => {
  378. console.log('查询意图类型', url, params)
  379. return get(url, { params })
  380. }
  381. export const addIntentType = ({ url, body }: any) => {
  382. console.log('新增意图类型', url, body)
  383. return post(url, { body })
  384. }
  385. export const editIntentType = ({ url, body }: any) => {
  386. console.log('编辑意图类型', url, body)
  387. return patch(url, { body })
  388. }
  389. export const delIntentType = ({ url, body }: any) => {
  390. console.log('删除意图类型', url, body)
  391. return del(url, { body })
  392. }
  393. export const fetchIntent = ({ url, params }: any) => {
  394. console.log('查询意图', url, params)
  395. return get(url, { params })
  396. }
  397. export const addIntent = ({ url, body }: any) => {
  398. console.log('新增意图', url, body)
  399. return post(url, { body })
  400. }
  401. export const editIntent = ({ url, body }: any) => {
  402. console.log('编辑意图', url, body)
  403. return patch(url, { body })
  404. }
  405. export const delIntent = ({ url, body }: any) => {
  406. console.log('删除意图', url, body)
  407. return del(url, { body })
  408. }
  409. export const getIntent = ({ url, body }: any) => {
  410. console.log('详情意图', url, body)
  411. return get(url, { body })
  412. }
  413. export const fetchIntentKeyword = ({ url, params }: any) => {
  414. console.log('查询意图关键词', url, params)
  415. return get(url, { params })
  416. }
  417. export const addIntentKeyword = ({ url, body }: any) => {
  418. console.log('新增意图关键词', url, body)
  419. return post(url, { body })
  420. }
  421. export const editIntentKeyword = ({ url, body }: any) => {
  422. console.log('编辑意图关键词', url, body)
  423. return patch(url, { body })
  424. }
  425. export const delBatchIntentKeyword = ({ url, body }: any) => {
  426. console.log('批量删除意图关键词', url, body)
  427. return post(url, { body })
  428. }
  429. export const fetchCorpus = ({ url, params }: any) => {
  430. console.log('查询训练语料列表', url, params)
  431. return get(url, { params })
  432. }
  433. export const addCorpus = ({ url, body }: any) => {
  434. console.log('新增训练语料', url, body)
  435. return post(url, { body })
  436. }
  437. export const editCorpus = ({ url, body }: any) => {
  438. console.log('编辑训练语料', url, body)
  439. return patch(url, { body })
  440. }
  441. export const delCorpus = ({ url, body }: any) => {
  442. console.log('删除训练语料', url, body)
  443. return del(url, { body })
  444. }
  445. export const getCorpus = ({ url, params }: any) => {
  446. console.log('查询训练语料', url, params)
  447. return get(url, { params })
  448. }
  449. export const fetchCorpusQuestion = ({ url, params }: any) => {
  450. console.log('查询训练语料-相似问题', url, params)
  451. return get(url, { params })
  452. }
  453. export const addCorpusQuestion = ({ url, body }: any) => {
  454. console.log('新增训练语料-相似问题', url, body)
  455. return post(url, { body })
  456. }
  457. export const editCorpusQuestion = ({ url, body }: any) => {
  458. console.log('编辑训练语料-相似问题', url, body)
  459. return patch(url, { body })
  460. }
  461. export const delBatchCorpusQuestion = ({ url, body }: any) => {
  462. console.log('批量删除训练语料-相似问题', url, body)
  463. return post(url, { body })
  464. }
  465. export const fetchDepts = ({ url, params }: any) => {
  466. console.log('查询部门列表', params, url)
  467. return get(url, { params })
  468. }
  469. export const addDept = ({ url, body }: any) => {
  470. console.log('新增部门', url, body)
  471. return post(url, { body })
  472. }
  473. export const editDept = ({ url, body }: any) => {
  474. console.log('编辑部门', url, body)
  475. return post(url, { body })
  476. }
  477. export const delDept = ({ url, body }: any) => {
  478. console.log('删除部门', url, body)
  479. return del(url, { body })
  480. }
  481. export const fetchDeptUsers = ({ url, params }: any) => {
  482. console.log('查询部门用户列表', params, url)
  483. return get(url, { params })
  484. }
  485. export const fetchNoDeptUsers = ({ url, params }: any) => {
  486. console.log('查询未绑定部门用户列表', params, url)
  487. return get(url, { params })
  488. }
  489. export const deptAddUsers = ({ url, body }: any) => {
  490. console.log('部门关联用户', url, body)
  491. return post(url, { body })
  492. }
  493. export const deptDelUsers = ({ url, body }: any) => {
  494. console.log('部门删除用户', url, body)
  495. return del(url, { body })
  496. }