liveCode.ts 2.19 KB
/**
 * 一客一码 / 一客一群 —— 源 src/api/usedCarManagement.js 的同名接口,路径 / method 逐字保留。
 *
 * 请求统一经 ../core/client 的 @uj/api-core 装配后由主壳 props.request 代发;
 * 源系统没有 DTO 定义,这里不臆造结构:参数是一层平铺对象,返回类型由调用方泛型指定。
 */
import { usedcarClient } from '../core/client';
import type { UsedcarParams } from '../core/types';


/**
 * 一客一码分页列表
 */
export function getLiveCodePage<T = unknown>(data: UsedcarParams = {}) {
  return usedcarClient.post<T>('/liveCode/page', data);
}

/**
 * 一客一群 - 获取企微群列表
 */
export function getGroupChatList<T = unknown>(data: UsedcarParams = {}) {
  return usedcarClient.post<T>('/liveCode/group/list', data);
}

/**
 * 一客一群 - 获取开通二手车场景的4S店列表
 */
export function getCarDealerList<T = unknown>(data: UsedcarParams = {}) {
  return usedcarClient.post<T>('/merchant/carDealer/list', data);
}

/**
 * 一客一群 - 活码配置新增
 */
export function addLiveCode<T = unknown>(data: UsedcarParams = {}) {
  return usedcarClient.post<T>('/liveCode/add', data, { returnAll: true });
}

/**
 * 一客一群 - 活码配置编辑
 */
export function updateLiveCode<T = unknown>(data: UsedcarParams = {}) {
  return usedcarClient.post<T>('/liveCode/update', data, { returnAll: true });
}

/**
 * 一客一群 - 活码配置删除
 */
export function deleteLiveCode<T = unknown>(data: UsedcarParams = {}) {
  return usedcarClient.post<T>('/liveCode/delete', data, { returnAll: true });
}

/**
 * 一客一群 - 活码配置详情
 */
export const getLiveCodeDetail = Object.assign(
  <T = unknown>(data: UsedcarParams = {}) => usedcarClient.post<T>('/liveCode/details', data),
  {
    // 编辑群池时需读取最新详情,不使用子应用默认的30秒查询缓存。
    queryOptions: { staleTime: 0, refetchOnMount: 'always' as const },
  },
);

/** 模块单例出口,与 dashboardApi 同一调用面;实现与上方具名函数完全同源。 */
export const liveCodeApi = {
  getLiveCodePage,
  getGroupChatList,
  getCarDealerList,
  addLiveCode,
  updateLiveCode,
  deleteLiveCode,
  getLiveCodeDetail,
};