import {
    IdParam,
    AdQueryParam,
    AdPageResult,
    AdFormData,
    AdItem,
    HelpQueryParam,
    HelpPageResult,
    HelpFormData,
    HelpItem,
    HelpCategoryItem,
    HelpCategoryFormData,
    AnnounceQueryParam,
    AnnouncePageResult,
    AnnounceFormData,
    AnnounceItem,
    BannerQueryParam,
    BannerPageResult,
    BannerFormData,
    BannerItem,
    HeaderQueryParam,
    HeaderPageResult,
    HeaderFormData,
    HeaderItem,
} from "@/types/api/cms";
import request from "@/utils/request";
import { AxiosPromise } from "axios";

/**
 * "内容管理" => "广告管理"
 * @param data
 */
export function manageAd(data: AdQueryParam): AxiosPromise<AdPageResult> {
    return request({
        url: "admin/cms/system-advertise/page-query",
        method: "post",
        params: data,
    });
}

/**
 * "内容管理" => "添加广告"
 * @param data
 */
export function createAd(data: AdFormData): any {
    return request({
        url: "admin/cms/system-advertise/create",
        method: "post",
        params: data,
    });
}

/**
 * "内容管理" => "更新广告"
 * @param data
 */
export function updateAd(data: AdFormData): any {
    return request({
        url: "admin/cms/system-advertise/update",
        method: "post",
        params: data,
    });
}

/**
 * "内容管理" => "删除广告"
 * @param data
 */
export function deleteAd(ids: any): any {
    return request({
        url: "admin/cms/system-advertise/deletes",
        method: "post",
        params: ids,
    });
}

/**
 * "内容管理" => "广告详情"
 * @param data
 */
export function adDetail(data: AdQueryParam): AxiosPromise<AdItem> {
    return request({
        url: "admin/cms/system-advertise/detail",
        method: "post",
        params: data,
    });
}

/**
 * "内容管理" => "帮助分类" => 下拉列表
 */
export function helpCategoryList(scene?: string): AxiosPromise<HelpCategoryItem[]> {
    return request({
        url: "admin/cms/help-category/list",
        method: "get",
        params: scene ? { scene } : {},
    });
}

/**
 * "内容管理" => "帮助分类" => 分页查询
 */
export function helpCategoryPageQuery(data: any): any {
    return request({
        url: "admin/cms/help-category/page-query",
        method: "post",
        params: data,
    });
}

/**
 * "内容管理" => "帮助分类" => 新增
 */
export function createHelpCategory(data: HelpCategoryFormData): any {
    return request({
        url: "admin/cms/help-category/create",
        method: "post",
        params: data,
    });
}

/**
 * "内容管理" => "帮助分类" => 修改
 */
export function updateHelpCategory(data: HelpCategoryFormData): any {
    return request({
        url: "admin/cms/help-category/update",
        method: "post",
        params: data,
    });
}

/**
 * "内容管理" => "帮助分类" => 批量删除
 */
export function deleteHelpCategory(ids: any): any {
    return request({
        url: "admin/cms/help-category/deletes",
        method: "post",
        params: ids,
    });
}

/**
 * "内容管理" => "帮助管理"
 * @param data
 */
export function helpManage(data: HelpQueryParam): AxiosPromise<HelpPageResult> {
    return request({
        url: "admin/cms/system-help/page-query",
        method: "post",
        params: data,
    });
}

/**
 * "内容管理" => "添加帮助管理"
 * @param data
 */
export function addHelpManage(data: HelpFormData): any {
    return request({
        url: "admin/cms/system-help/create",
        method: "post",
        data: data,
        headers: { "Content-Type": "multipart/form-data" },
    });
}

/**
 * "内容管理" => "更新帮助管理"
 * @param data
 */
export function updateHelpManage(data: HelpFormData): any {
    return request({
        url: "admin/cms/system-help/update",
        method: "post",
        data: data,
        headers: { "Content-Type": "multipart/form-data" },
    });
}

/**
 * "内容管理" => "删除帮助管理"
 * @param data
 */
export function delHelpManage(ids: any): any {
    return request({
        url: "admin/cms/system-help/deletes",
        method: "post",
        params: ids,
    });
}

/**
 * "内容管理" => "查看帮助管理"
 * @param data
 */
export function helpManageDetail(data: IdParam): AxiosPromise<HelpItem> {
    return request({
        url: "admin/cms/system-help/detail",
        method: "post",
        params: data,
    });
}

/**
 * "内容管理" => "帮助管理" => "置顶"
 * @param data
 */
export function stickTopHelp(data: IdParam): any {
    return request({
        url: "admin/cms/system-help/top",
        method: "post",
        params: data,
    });
}

/**
 * "内容管理" => 帮助管理 => "取消置顶"
 * @param data
 */
export function helpDown(data: IdParam): any {
    return request({
        url: "admin/cms/system-help/down",
        method: "post",
        params: data,
    });
}

// , , , , ,

/**
 * "内容管理" => "公告管理"
 * @param data
 */
export function announceManage(
    data: AnnounceQueryParam
): AxiosPromise<AnnouncePageResult> {
    return request({
        url: "admin/system/announcement/page-query",
        method: "get",
        params: data,
    });
}

/**
 * "内容管理" => "添加公告管理"
 * @param data
 */
export function addAnnounce(data: AnnounceFormData): any {
    return request({
        url: "admin/system/announcement/create",
        method: "post",
        data: data,
        headers: { "Content-Type": "multipart/form-data" },
    });
}

/**
 * "内容管理" => "更新公告管理"
 * @param data
 */
export function updateAnnounce(urlID: any, data: AnnounceFormData): any {
    return request({
        url: `admin/system/announcement/${urlID}/update`,
        method: "put",
        data: data,
        headers: { "Content-Type": "multipart/form-data" },
    });
}

/**
 * "内容管理" => "删除公告管理"
 * @param data
 */
export function delAnnounce(ids: any): any {
    return request({
        url: "admin/system/announcement/deletes",
        method: "patch",
        params: ids,
    });
}

/**
 * "内容管理" => "查看公告管理"
 * @param data
 */
export function announceDetail(id: any): AxiosPromise<AnnounceItem> {
    return request({
        url: `admin/system/announcement/${id}/detail`,
        method: "get",
    });
}

/**
 * "内容管理" => "公告管理" => "置顶"
 * @param data
 */
export function stickTopAnnounce(data: IdParam): any {
    return request({
        url: "admin/system/announcement/top",
        method: "post",
        params: data,
    });
}

/**
 * "内容管理" => 公告管理 => "取消置顶"
 * @param data
 */
export function announceDown(data: IdParam): any {
    return request({
        url: "admin/system/announcement/down",
        method: "post",
        params: data,
    });
}

/**
 * "内容管理" => 公告管理 => "开启弹窗"
 */
export function announcePopupOn(id: number | string): any {
    return request({
        url: `admin/system/announcement/${id}/popup-on`,
        method: "patch",
    });
}

/**
 * "内容管理" => 公告管理 => "关闭弹窗"
 */
export function announcePopupOff(id: number | string): any {
    return request({
        url: `admin/system/announcement/${id}/popup-off`,
        method: "patch",
    });
}

/**
 * "内容管理" => "Banner管理" => 分页列表
 */
export function bannerList(data: BannerQueryParam): AxiosPromise<BannerPageResult> {
    return request({
        url: "admin/cms/app-banner/page-query",
        method: "post",
        params: data,
    });
}

/**
 * "内容管理" => "Banner管理" => 创建
 */
export function createBanner(data: BannerFormData): any {
    return request({
        url: "admin/cms/app-banner/create",
        method: "post",
        params: data,
    });
}

/**
 * "内容管理" => "Banner管理" => 更新
 */
export function updateBanner(data: BannerFormData): any {
    return request({
        url: "admin/cms/app-banner/update",
        method: "post",
        params: data,
    });
}

/**
 * "内容管理" => "Banner管理" => 批量删除
 */
export function deleteBanner(ids: any): any {
    return request({
        url: "admin/cms/app-banner/deletes",
        method: "post",
        params: ids,
    });
}

/**
 * "内容管理" => "Banner管理" => 启用
 */
export function enableBanner(data: IdParam): any {
    return request({
        url: "admin/cms/app-banner/enable",
        method: "post",
        params: data,
    });
}

/**
 * "内容管理" => "Banner管理" => 禁用
 */
export function disableBanner(data: IdParam): any {
    return request({
        url: "admin/cms/app-banner/disable",
        method: "post",
        params: data,
    });
}

/**
 * "内容管理" => "Header管理" => 分页列表
 */
export function headerList(data: HeaderQueryParam): AxiosPromise<HeaderPageResult> {
    return request({
        url: "admin/cms/app-header/page-query",
        method: "post",
        params: data,
    });
}

/**
 * "内容管理" => "Header管理" => 创建
 */
export function createHeader(data: HeaderFormData): any {
    return request({
        url: "admin/cms/app-header/create",
        method: "post",
        params: data,
    });
}

/**
 * "内容管理" => "Header管理" => 更新
 */
export function updateHeader(data: HeaderFormData): any {
    return request({
        url: "admin/cms/app-header/update",
        method: "post",
        params: data,
    });
}

/**
 * "内容管理" => "Header管理" => 批量删除
 */
export function deleteHeader(ids: any): any {
    return request({
        url: "admin/cms/app-header/deletes",
        method: "post",
        params: ids,
    });
}

/**
 * "内容管理" => "Header管理" => 启用
 */
export function enableHeader(data: IdParam): any {
    return request({
        url: "admin/cms/app-header/enable",
        method: "post",
        params: data,
    });
}

/**
 * "内容管理" => "Header管理" => 禁用
 */
export function disableHeader(data: IdParam): any {
    return request({
        url: "admin/cms/app-header/disable",
        method: "post",
        params: data,
    });
}
