import http from "@/utils/http";
import { AppDispatch } from "..";
/**
 * 获取 视频 / 海报 列表
 */
export const A1_APIgetList = (type: "video" | "poster") => {
  return async (dispatch: AppDispatch) => {
    const res = await http.get(`cms/poster/getList/${type}`);
    if (res.code === 0) {
      dispatch({
        type: type === "video" ? "A1/getList" : 'A2/getList',
        payload: res.data,
      });
    }
  };
};

/**
 * 排序 -上移 下移
 */
export const A1_APIsort = (id1: number, id2: number) => {
  return http.get(`cms/poster/sort/${id1}/${id2}`);
};

/**
 * 删除
 */
export const A1_APIdel = (id: number) => {
  return http.get(`cms/poster/remove/${id}`);
};

/**
 * 新增/编辑
 */
export const A1_APIsave = (data: any) => {
  return http.post("cms/poster/save", data);
};

/**
 * 通过id获取详情
 */
export const A1_APIgetInfo = (id: number) => {
  return http.get(`cms/poster/detail/${id}`);
};
