
import request from "@/utils/request";
const { api } = process.env.CONFIG;

export interface GetCorpAutoLinkListProps {
    pageNum: number,
    pageSize: number,
    platform?: string,
    mpAccountId?: number
    linkType?: number
    channelName?: string
    channelType?: number
    createTimeStart?: string
    createTimeEnd?: string
}

/**
 * 书城链接列表
 * @param data 
 * @returns 
 */
export function getCorpAutoLinkListApi(data: GetCorpAutoLinkListProps) {
    return request({
        url: api + `/corpOperation/corp/autoLink/listOfPage`,
        method: 'POST',
        data
    })
}

/**
 * 详情
 * @param data 
 * @returns 
 */
export function getAutoLinkInfoApi(data: { mpAccountId: number, platform: string, links?: string[], miniapps?: {miniappId: string, miniappName: string }[] }) {
    return request({
        url: api + `/corpOperation/corp/autoLink/getInfo`,
        method: 'POST',
        data
    })
}

export interface AddCorpAutoLinkProps {
    mpAccountIds: number[],
    platform: string,
    yueWenCreateLinkDTOList: { [x: string]: any }
}

/**
 * 新增书城链接生成
 * @param data 
 * @returns 
 */
export function addCorpAutoLinkApi(data: AddCorpAutoLinkProps) {
    return request({
        url: api + `/corpOperation/corp/autoLink/add`,
        method: 'POST',
        data
    })
}

interface GetFreeChapterListProps {
    bookId: number
    mpAccountIds: number[]
    platform: string
}
/**
 * 获取免费章节
 * @param data 
 * @returns 
 */
export function getFreeChapterListApi(data: GetFreeChapterListProps) {
    return request({
        url: api + `/corpOperation/corp/autoLink/freeChapterList`,
        method: 'POST',
        data
    })
}

export interface GetAutoLinkBookListProps {
    pageNum: number
    pageSize: number
    bookName?: string,
    bookId?: string,
    platformKey?: string
}

/**
 * 书籍列表
 * @param data 
 * @returns 
 */
export function getAutoLinkBookListApi(data: GetAutoLinkBookListProps) {
    return request({
        url: api + `/corpOperation/corp/autoLink/bookList`,
        method: 'POST',
        data
    })
}

/**
 * 删除链接
 * @param data 
 * @returns 
 */
export function delAutoLinkApi(data: { linkIds: number[] }) {
    return request({
        url: api + `/corpOperation/corp/autoLink/batchDelByIds`,
        method: 'POST',
        data: data.linkIds
    })
}