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

/**
 * 获取宁博动态列表
 */

export const A2_APIgetList = (data: any): any => {
  return async (dispatch: AppDispatch) => {
    const res = await http.post("cms/news/pageList", data);
    if (res.code === 0) {
      const obj = {
        list: res.data.records,
        total: res.data.total,
      };
      dispatch({ type: "A2/getList", payload: obj });
    }
  };
};

/**
 * 宁博动态删除
 */
export const A2_APIdel = (id: number) => {
  return http.get(`cms/news/removes/${id}`);
};

/**
 * 宁博动态-获取详情
 */
export const A2_APIgetInfo = (id: number) => {
  return http.get(`cms/news/detail/${id}`);
};

/**
 * 宁博动态-新增、编辑
 */
export const A2_APIsave = (data: any) => {
  return http.post("cms/news/save", data);
};
