import service from "./../../utils/request"

/**
 * 获取story列表
 * @param {*} page 
 * @param {*} size 
 * @returns 
 */
export function getStoryList(page, size, type, content) {
    return service.request({
        method: "post",
        url: "apingtxt/admin/story/list",
        data: {
            page: page,
            size: size,
            type: type,
            content: content
        }
    })
}

/**
 * 编辑小说
 * @returns
 */
export function editStory(type, book_id, content) {
    return service.request({
        method: "post",
        url: "apingtxt/admin/story/edit",
        data: {
            type: type,
            book_id: book_id,
            content: content
        }
    })
}

/**
 * 小说编辑历史
 * @returns
 */
export function getStoryEditHistoryList(book_id) {
    return service.request({
        method: "post",
        url: "apingtxt/admin/story/edit/history",
        data: {
            book_id: book_id
        }
    })
}

/**
 * 获取章节列表
 * @returns
 */
export function getStoryChapterList(book_id, page, size) {
    return service.request({
        method: "post",
        url: "apingtxt/admin/story/chapter/list",
        data: {
            book_id: book_id,
            page: page,
            size: size
        }
    })
}

/**
 * 获取章节详情
 * @returns
 */
export function getStoryChapterDetails(chapterId) {
    return service.request({
        method: "post",
        url: "apingtxt/admin/story/chapter/details",
        data: {
            chapterId: chapterId
        }
    })
}

/**
 * 保存章节内容信息
 * @returns
 */
export function saveStoryChapterContent(chapterId, content) {
    return service.request({
        method: "post",
        url: "apingtxt/admin/story/chapter/details/save",
        data: {
            chapterId: chapterId,
            content: content
        }
    })
}

/**
 * 保存章节内容信息
 * @returns
 */
export function getStoryDetails(bookId) {
    return service.request({
        method: "post",
        url: "apingtxt/admin/story/details",
        data: {
            bookId: bookId
        }
    })
}

/**
 * 保存章节内容信息
 * @returns
 */
export function updateStoryCover(bookId, cover) {
    return service.request({
        method: "post",
        url: "apingtxt/admin/story/details/cover/convert",
        data: {
            bookId: bookId,
            cover: cover
        }
    })
}

/**
 * 删除小说
 * @returns
 */
export function deleteStory(bookId) {
    return service.request({
        method: "post",
        url: "apingtxt/admin/story/delete",
        data: {
            book_id: bookId
        }
    })
}

/**
 * 获取搜索列表
 * @returns
 */
export function getSearchList(selectType, orderType) {
    return service.request({
        method: "post",
        url: "apingtxt/admin/story/search/list",
        data: {
            selectType: selectType,
            orderType: orderType
        }
    })
}

/**
 * 审核通过
 * @returns
 */
export function auditPass(book_id) {
    return service.request({
        method: "post",
        url: "apingtxt/admin/story/audit/pass",
        data: {
            book_id: book_id
        }
    })
}

/**
 * 获取未审核下一部小说
 * @returns
 */
export function nextUnAuditStory(book_id) {
    return service.request({
        method: "post",
        url: "apingtxt/admin/story/unaudit/next",
        data: {
            book_id: book_id
        }
    })
}

/**
 * 添加小说章节
 * @returns
 */
export function addNewChapter(chapterIndex, bookId, content, chapterName) {
    return service.request({
        method: "post",
        url: "apingtxt/admin/story/chapter/add",
        data: {
            chapterIndex: chapterIndex,
            bookId: bookId,
            content: content,
            chapterName: chapterName
        }
    })
}


/**
 * 删除小说章节
 * @returns
 */
export function deleteNewChapter(chapterId, bookId) {
    return service.request({
        method: "post",
        url: "apingtxt/admin/story/chapter/delete",
        data: {
            chapterId: chapterId,
            bookId: bookId
        }
    })
}