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

/**
 * 获取列表
 */
export const A3_APIgetList = (parentId: number) => {
  return async (dispatch: AppDispatch) => {
    const res = await http.get(`cms/screen/getList/${parentId}`);
    if (res.code === 0) {
      dispatch({ type: "A3/getList", payload: res.data });
    }
  };
};

/**
 * 获取配置
 */
export const A3_APIgetConfig = () => {
  return http.get("cms/screen/getConfig");
};

/**
 * 修改配置
 */
export const A3_APIupdateConfig = (content: string) => {
  return http.post("cms/screen/updateConfig", { moduleKey: "goods", content });
};

/**
 * 新增图片列表
 */
export const A3_APIaddTable = (data: unknown) => {
  return http.post("cms/screen/save", data);
};

/**
 * 是否显示
 */
export const A3_APIdisplay = (id: number, display: 0 | 1) => {
  return http.get(`cms/screen/display/${id}/${display}`);
};

/**
 * 排序
 */
export const A3_APIsort = (id1: number, id2: number) => {
  return http.get(`cms/screen/sort/${id1}/${id2}`);
};

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