网站首页 网站源码
website
站点相关全部源代码,隐藏了一些关于服务器的信息
using Dpz.Core.Public.ViewModel.Response;

namespace Dpz.Core.Service.V4.Services;

public interface IArticleService
{
    /// <summary>
    /// 获取一定时间内,阅读量靠前的文章
    /// </summary>
    /// <param name="days"></param>
    /// <param name="count"></param>
    /// <returns></returns>
    [CacheModule(Expiration = ExpirationTime.Hour * 3, PrefixKey = "IArticleService:Tops")]
    Task<ICollection<VmArticleMini>> GetTopArticlesAsync(int days = -7, uint count = 15);

    /// <summary>
    /// 随机获取文章
    /// </summary>
    /// <returns></returns>
    [CacheModule(Expiration = ExpirationTime.Hour * 3, PrefixKey = "IArticleService:Random")]
    Task<ICollection<VmArticleMini>> GetRandomArticlesAsync(int sample = 8);

    /// <summary>
    /// 获取用户发表的文章
    /// </summary>
    /// <returns></returns>
    Task<IList<VmArticleMini>> GetPublishArticlesAsync();

    /// <summary>
    /// 获取文章
    /// </summary>
    /// <param name="pageIndex">页码</param>
    /// <param name="pageSize">大小</param>
    /// <param name="title">标题</param>
    /// <param name="account">账号</param>
    /// <param name="tags">标签</param>
    /// <returns></returns>
    [CacheModule(Expiration = ExpirationTime.Hour * 3, PrefixKey = "IArticleService:Page")]
    Task<IPagedList<VmArticleMini>> GetPagesAsync(
        int pageIndex = 1,
        int pageSize = 20,
        string? title = "",
        string? account = "",
        params string?[]? tags
    );

    /// <summary>
    /// 获取所有标签
    /// </summary>
    /// <returns></returns>
    [CacheModule(Expiration = ExpirationTime.Month, PrefixKey = "IArticleService:All:Tags")]
    Task<ICollection<string>> GetAllTagsAsync();

    /// <summary>
    /// 获取文章详情
    /// </summary>
    /// <param name="id"></param>
    /// <returns></returns>
    [CacheModule(Expiration = ExpirationTime.Month, PrefixKey = "IArticleService:Detail")]
    Task<VmArticle?> GetArticleAsync(string id);

    /// <summary>
    /// 查看文章
    /// </summary>
    /// <param name="id"></param>
    /// <returns></returns>
    Task ViewAsync(string id);

    /// <summary>
    /// 获取最新文章
    /// </summary>
    /// <param name="range"></param>
    /// <returns></returns>
    [CacheModule(Expiration = ExpirationTime.Hour * 3, PrefixKey = "IArticleService:News")]
    Task<ICollection<VmArticleMini>> GetLatestAsync(int range = 5);

    /// <summary>
    /// 标题是否存在
    /// </summary>
    /// <param name="title"></param>
    /// <returns></returns>
    Task<bool> IsExistsAsync(string title);

    /// <summary>
    /// 由From 比对 不存在的
    /// </summary>
    /// <returns></returns>
    Task<IReadOnlyCollection<string>> NoExistsByFromAsync(IReadOnlyCollection<string> feeds);

    /// <summary>
    /// 删除文章
    /// </summary>
    /// <param name="id"></param>
    /// <returns></returns>
    Task DeleteAsync(string id);

    /// <summary>
    /// 删除旧的CnBeta数据
    /// </summary>
    /// <param name="month">最多删除几个月前的</param>
    /// <param name="limit">按时间倒序,删除的条数</param>
    /// <returns></returns>
    Task DeleteOldCnBetaAsync(int month, int limit);

    /// <summary>
    /// 创建文章
    /// </summary>
    /// <param name="article">文章</param>
    /// <param name="creator">创建人</param>
    /// <returns></returns>
    Task<VmArticle> CreateArticleAsync(VmCreateArticleV4 article, VmUserInfo creator);

    /// <summary>
    /// 修改文章
    /// </summary>
    /// <param name="article">文章</param>
    /// <param name="editor">修改人</param>
    /// <returns></returns>
    Task EditArticleAsync(VmEditArticleV4 article, VmUserInfo editor);

    /// <summary>
    /// 获取文章总数
    /// </summary>
    /// <returns></returns>
    Task<int> GetTotalCountAsync();

    /// <summary>
    /// 获取今日文章总数
    /// </summary>
    /// <returns></returns>
    Task<int> GetTodayCountAsync();

    /// <summary>
    /// 清除缓存
    /// </summary>
    [CacheModule(
        Clear = true,
        RemovePrefixKeys = [
            "IArticleService:Tops",
            "IArticleService:Page",
            "IArticleService:All:Tags",
            "IArticleService:News",
            "IArticleService:Search"
        ]
    )]
    ValueTask ClearCacheAsync();

    /// <summary>
    /// 搜索
    /// </summary>
    /// <param name="keyword"></param>
    /// <returns></returns>
    [CacheModule(Expiration = ExpirationTime.Hour * 3, PrefixKey = "IArticleService:Search")]
    Task<List<ArticleSearchResultResponse>> SearchAsync(string keyword);
}
loading