package com.microservices.cms.doc.service;

import com.microservices.cms.doc.domain.CmsDoc;
import com.microservices.cms.doc.domain.CmsDocDto;
import com.microservices.cms.doc.domain.gitlink.EntryDto;
import com.microservices.cms.doc.domain.gitlink.LastCommitDto;
import com.microservices.cms.project.domain.CmsProject;

import java.util.List;

/**
 * @author otto
 */
public interface ICmsAsyncService {
    void asyncSetSummary(Long id, String content);

    void asyncBatchUpdateDoc(List<EntryDto> entryDtoList, CmsProject cmsProject);

    void asyncUpdateDoc(EntryDto entryDto, CmsDoc cmsDoc);

    /**
     * 异步创建webhook
     * @param cmsProject
     */
    void asyncCreateWebhook(CmsProject cmsProject);

    /**
     * 异步进行GitLink代码库和本地数据库的同步逻辑
     *
     * @param cmsProject
     * @return
     */
    List<EntryDto> SyncDatabaseAndGitLinkDir(CmsProject cmsProject);

    /**
     * 同步创建栏目
     * @param name
     * @param entry
     * @param cmsProject
     * @param isCreateKeep
     */
    void syncCreateDir(String name, EntryDto entry, CmsProject cmsProject, boolean isCreateKeep);

    /**
     * 同步创建文章
     *
     * @param entry
     * @param name
     * @param deptId
     * @return
     */
    CmsDoc syncCreateDoc(EntryDto entry, String name, Long deptId, LastCommitDto lastCommitDto);

    /**
     * 同步文章数据
     *
     * @param deptId
     * @param bodyStr
     */
    void asyncDocData(Long deptId, String bodyStr);

    /**
     * 全量同步
     *
     * @param cmsProject
     * @return
     */
    void fullSyncDocData(CmsProject cmsProject);

    /**
     * 更新文章发布数据
     *
     * @param cmsProject
     * @param cmsDoc
     */
    void updateCmsPublishDataByGitLink(CmsProject cmsProject, CmsDoc cmsDoc, String branchName);

    void asyncCreateProtectedBranchSetting(String userName, String identifier, Long deptId);

    void asyncDeleteProtectedBranchSetting(String userName, String identifier, Long deptId);

    void asyncUpdateProtectedBranchSetting(String userName, String identifier, Long deptId);

    void asyncCreateBranchAndFileAndPR(CmsDoc cmsDoc, String message, String content);

    void asyncUpdateBranchAndFileAndCreatePR(CmsDoc cmsDoc, CmsDocDto cmsDocDto);

    CmsDoc updateCmsDocDatabaseAndUpdateForGitLink(CmsDoc oldCmsDoc, CmsDocDto cmsDocDto, String branchName);

    boolean deleteCmsDocForGitLink(CmsDoc cmsDoc, CmsProject cmsProject, String branchName);

    void asyncCreateBranchAndDeleteFileAndCreatePR(CmsDoc newDocWithAudit, CmsProject cmsProject);

    void asyncMoveFileToNewDir(CmsProject cmsProject, CmsDoc oldCmsDir, CmsDoc newCmsDir);

    /**
     * 推送文章数据到搜索引擎
     *
     * @param cmsDoc 文章
     */
    void pushDocDataSearchEngine(CmsDoc cmsDoc);
}
