client.ts 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. import { useFetch } from '@/hooks/useFetch';
  2. import { PageResult,PageMoreResult } from '@/utils/page';
  3. import {
  4. CategoryListParams,
  5. CategoryListResult,
  6. EmployeeSearchParams,
  7. EmployeeDetailParams,
  8. EmployeeSearchResult,
  9. UserLoginParams,
  10. UserLoginResult,
  11. UserPasswordParams,
  12. UserInfoResult,
  13. ChatSubmitParams,
  14. ChatSubmitResult,
  15. ChatMessageParams,
  16. ChatMessageResult,
  17. ChatSessionParams,
  18. ChatSessionResult
  19. } from '@/utils/clientsApis';
  20. import {Result} from '@/utils/result';
  21. /**
  22. * 获取分类列表
  23. */
  24. export const getCategoryList = (params: CategoryListParams): Promise<Result<PageResult<CategoryListResult[]>>> => {
  25. const fetchService = useFetch();
  26. return fetchService.post('/category/list', { body: params });
  27. };
  28. /**
  29. * 获取智能体列表
  30. */
  31. export const getEmployeeSearch = (params: EmployeeSearchParams): Promise<Result<PageResult<EmployeeSearchResult[]>>> => {
  32. const fetchService = useFetch();
  33. return fetchService.post('/employee/search', { body: params });
  34. };
  35. /**
  36. * 获取智能体详情
  37. */
  38. export const getEmployeeDetail = (params: EmployeeDetailParams): Promise<Result<EmployeeSearchResult>> => {
  39. const fetchService = useFetch();
  40. return fetchService.post('/employee/detail', { body: params });
  41. };
  42. /**
  43. * 前台用户登陆
  44. */
  45. export const userLogin = (params: UserLoginParams): Promise<Result<UserLoginResult>> => {
  46. const fetchService = useFetch();
  47. return fetchService.post('/gpts/user/login', { body: params });
  48. };
  49. /**
  50. * 前台用户修改密码
  51. */
  52. export const userPassword = (params: UserPasswordParams) => {
  53. const fetchService = useFetch();
  54. return fetchService.post('/gpts/user/password', { body: params });
  55. };
  56. /**
  57. * 查看用户信息
  58. */
  59. export const getUserInfo = (): Promise<Result<UserInfoResult>> => {
  60. const fetchService = useFetch();
  61. return fetchService.post('/gpts/user/info');
  62. };
  63. /**
  64. * 聊天提交内容
  65. */
  66. export const chatSubmit = (params: ChatSubmitParams) => {
  67. const fetchService = useFetch();
  68. return fetchService.post('/gpts/chat/submit', { body: params });
  69. };
  70. /**
  71. * 查询会话下的聊天历史
  72. */
  73. export const getChatMessage = (params: ChatMessageParams) : Promise<Result<PageMoreResult<ChatMessageResult[]>>> => {
  74. const fetchService = useFetch();
  75. return fetchService.post('/gpts/chat/message', { body: params });
  76. };
  77. /**
  78. * 聊天会话列表
  79. */
  80. export const getChatSession = (params: ChatSessionParams) : Promise<Result<PageMoreResult<ChatSessionResult[]>>> => {
  81. const fetchService = useFetch();
  82. return fetchService.post('/gpts/chat/session', { body: params });
  83. };