import http from "@/utils/http";
import { AppDispatch } from "..";
/**
 * 获取列表数据
 */
export const getBarrageListAPI = (data: any) => {
  return async (dispatch: AppDispatch) => {
    const res = await http.post("cms/barrage/pageList", data);
    dispatch({
      type: "barrage/getList",
      payload: { list: res.data.records, total: res.data.total },
    });
  };
};

/**
 * 审核弹幕
 */
export const barrageAuditAPI = (id: number, display: number) => {
  return http.get(`cms/barrage/audit/${id}/${display}`);
};

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

/**
 * 弹幕功能设置修改
 */
export const barrageSetConfigAPI = (data: { content: string }) => {
  return http.post("cms/barrage/setConfig", data);
};

/**
 * 弹幕功能设置获取
 */
export const barrageGetConfigAPI = () => {
  return http.get("cms/barrage/getConfig");
};

/**
 * 获取弹幕未审核个数
 */
export const barrageGetUnauditedAPI = () => {
  return async (dispatch: AppDispatch) => {
    const res = await http.get("cms/barrage/getUnaudited");
    dispatch({ type: "barrage/stateNum", payload: res.data });
  };
};
