package me.qwq.doghouse.cache;

import me.qwq.doghouse.annotation.CacheEvictTags;
import me.qwq.doghouse.annotation.CacheEvictTags.Tag;

public class CacheConstants {

    public static class Statistics {
        /** 每日更新、更新 Post 和 Comment 时更新 */
        @CacheEvictTags({Tag.Posts, Tag.Comments, Tag.Daily})
        public static final String DAILY_POST_AND_COMMENT_COUNTS = "StatisticsService::getPostAndCommentCountsWithDate";
        /** 每日更新 */
        @CacheEvictTags(Tag.Daily)
        public static final String DAY_SINCE = "StatisticsService::daySince";
        /** 更新 Post 时更新 */
        @CacheEvictTags(Tag.Posts)
        public static final String TOTAL_RELEASE_POSTS_COUNT = "StatisticsService::totalReleasedPostsCount";
        /** 更新 Post 和 Comment 时更新 */
        @CacheEvictTags({Tag.Posts, Tag.Comments})
        public static final String TOTAL_COMMENTS_COUNT = "StatisticsService::totalCommentsCount";
    }

    public static class Posts {
        static final String ID = "Posts::";

        // Markdown
        @CacheEvictTags(Tag.PostId)
        public static final String MARKDOWN_CONTENT_RENDERING = ID + "Markdown::renderPostContent";
        
        @CacheEvictTags(Tag.PostId)
        public static final String MARKDOWN_PREFACE_RENDERING = ID + "Markdown::renderPostPreface";
        
        @CacheEvictTags(Tag.PostId)
        public static final String GET_CONTENT_TEXT = ID + "Markdown::getPostContentText";

        @CacheEvictTags(Tag.PostId)
        public static final String GET_PREFACE_TEXT = ID + "Markdown::getPostPrefaceText";

        // Statistic
        public static final String POST_STATISTIC = ID + "PostStatistic::getPostStatistic";

        // CondictionPage
        /** 更新 Post/Meta 时更新 */
        @CacheEvictTags(Tag.Posts)
        public static final String CONDITION_PAGE = ID + "ConditionPage::conditionPage";

        // PostService
        /// 与 ID 或 Name 有关（指定）
        @CacheEvictTags(Tag.PostId)
        public static final String GET_BY_ID = ID + "PostService::getById";
        
        @CacheEvictTags(Tag.PostId)
        public static final String GET_BY_ID_LOGINED = ID + "PostService::getByIdLogined";
        
        @CacheEvictTags(Tag.PostId)
        public static final String GET_BY_ID_UNLOGINED = ID + "PostService::getByIdUnlogined";

        @CacheEvictTags(Tag.PostName)
        public static final String GET_BY_NAME_LOGINED = ID + "PostService::getByNameLogined";

        @CacheEvictTags(Tag.PostName)
        public static final String GET_BY_NAME_UNLOGINED = ID + "PostService::getByNameUnlogined";

        @CacheEvictTags(Tag.PostId)
        public static final String GET_SEO_DESCRIPTION = ID + "PostService::getSeoDescription";

        /** 更新 Post 时更新(指定 PostID 的 Next 的 PostID) */
        @CacheEvictTags(Tag.Next)
        public static final String GET_PREVIOUS_LOGINED = ID + "PostService::getPreviousLogined";
        
        /** 更新 Post 时更新(指定 PostID 的 Next 的 PostID) */
        @CacheEvictTags(Tag.Next)
        public static final String GET_PREVIOUS_UNLOGINED = ID + "PostService::getPreviousUnlogined";
        
        /** 更新 Post 时更新(指定 PostID 的 Previous 的 PostID) */
        @CacheEvictTags(Tag.Prev)
        public static final String GET_NEXT_LOGINED = ID + "PostService::getNextLogined";
        
        /** 更新 Post 时更新(指定 PostID 的 Previous 的 PostID) */
        @CacheEvictTags(Tag.Prev)
        public static final String GET_NEXT_UNLOGINED = ID + "PostService::getNextUnlogined";
        
        /** 仅在更新 Post 浏览数时更新 **/
        @CacheEvictTags(Tag.PostId)
        public static final String GET_POST_VIEWS = ID + "PostService::getPostViews";

        /// 与 ID 或 Name 无关(批量)
        
        @CacheEvictTags(Tag.Posts)
        public static final String GET_LATEST_POSTS_LOGINED = ID + "PostService::getLatestPostsLogined";
        
        @CacheEvictTags(Tag.Posts)
        public static final String GET_LATEST_POSTS_UNLOGINED = ID + "PostService::getLatestPostsUnlogined";
        
        @CacheEvictTags({Tag.Posts, Tag.Comments})
        public static final String GET_POPULAR_POSTS_LOGINED = ID + "PostService::getPopularPostsLogined";

        @CacheEvictTags({Tag.Posts, Tag.Comments})
        public static final String GET_POPULAR_POSTS_UNLOGINED = ID + "PostService::getPopularPostsUnlogined";

        @CacheEvictTags(Tag.Posts)
        public static final String GET_JUMP_TO_PAGES_URL = ID + "PostService::getJumpToPagesUrl";

    }

    public static class Comments {
        static final String ID = "Comments::";

        // Markdown
        @CacheEvictTags(Tag.Comments)
        public static final String MARKDOWN_CONTENT_RENDERING = ID + "Markdown::renderCommentContent";

        @CacheEvictTags(Tag.Comments)
        public static final String GET_CONTENT_TEXT = ID + "Markdown::getCommentContentText";

        // CommentService
        @CacheEvictTags({Tag.Posts, Tag.Comments})
        public static final String GET_BY_ID = ID + "CommentService::getById";

        @CacheEvictTags({Tag.Posts, Tag.Comments})
        public static final String GET_LATEST_COMMENTS = ID + "CommentService::getLatestComments";

        @CacheEvictTags({Tag.Posts, Tag.Comments})
        public static final String GET_LATEST_COMMENTS_WITH_LEVEL = ID + "CommentService::getLatestCommentsWithLevel";

        @CacheEvictTags({Tag.Posts, Tag.Comments})
        public static final String LIST_FROM_CHILD_TO_PARENT = ID + "CommentService::listFromChildToParent";

        @CacheEvictTags({Tag.Posts, Tag.Comments})
        public static final String GET_JUMP_TO_URL = ID + "CommentService::getJumpToUrl";

        // Other
        @CacheEvictTags(Tag.Comments)
        public static final String GET_POST_COMMENT_COUNT = ID + "CommentService::getPostCommentCount";
    }

    public static class Metas {
        static final String ID = "Metas::";

        // MetaService
        /** 更新 Post 和 Meta 时更新(批量) */
        @CacheEvictTags({Tag.Posts, Tag.Metas})
        public static final String LIST_META_COUNT = ID + "MetaService::listMetaCount";
    }

}
