import { http } from "@/utils/http";

export interface Ab98UserTagDTO {
  /** 标签ID */
  tagId?: number;
  /** 关联用户ID */
  ab98UserId?: number;
  /** 标签名称 */
  tagName?: string;
  /** 创建时间 */
  createTime?: string;
}

export interface Ab98UserTagQuery extends BasePageQuery {
  /** 关联用户ID */
  ab98UserId?: number;
  /** 标签名称 */
  tagName?: string;
  /** 开始时间 */
  startTime?: string;
  /** 结束时间 */
  endTime?: string;
}

export interface AddAb98UserTagCommand {
  /** 关联用户ID */
  ab98UserId: number;
  /** 标签名称 */
  tagName: string;
}

export interface UpdateAb98UserTagCommand extends AddAb98UserTagCommand {
  /** 标签ID */
  tagId: number;
}

export const getAb98UserTagListApi = (params: Ab98UserTagQuery) => {
  return http.request<ResponseData<PageDTO<Ab98UserTagDTO>>>("get", "/ab98/userTags", { params });
};

export const addAb98UserTagApi = (data: AddAb98UserTagCommand) => {
  return http.request<ResponseData<void>>("post", "/ab98/userTags", { data });
};

export const updateAb98UserTagApi = (id: number, data: UpdateAb98UserTagCommand) => {
  return http.request<ResponseData<void>>("put", `/ab98/userTags/${id}`, { data });
};

export const deleteAb98UserTagApi = (ids: number[]) => {
  return http.request<ResponseData<void>>("delete", `/ab98/userTags/${ids.join(',')}`);
};

export const deleteAb98UserTagConfirmApi = (tagId: number) => {
  return http.request<ResponseData<void>>("delete", `/ab98/userTags/${tagId}`);
};

export const getAb98UserTagNamesApi = () => {
  return http.request<ResponseData<string[]>>("get", "/ab98/userTags/names");
};