﻿#region Copyright and License
/* @Copyright JONVON(NetCreditHub.COM) 2017. All rights reserved. - 8502090@qq.com */
#endregion

namespace NetCreditHub.Modules
{
    using System;
    using Zero;

    [Serializable]
    public class ModuleObjectCacheItem 
    {
        public static string CacheStoreName = $"{HubZeroConsts.LocalizationSourceName}.ModuleCache";

        public static string ModuleBaseCacheKey = $"{CacheStoreName}.Module";
        public static string ModuleButtonBaseCacheKey = $"{CacheStoreName}.ModuleButton";
        public static string ModuleColumnBaseCacheKey = $"{CacheStoreName}.ModuleColumn";
        public static string ModuleServiceBaseCacheKey = $"{CacheStoreName}.ModuleService";

        #region Module

        /// <summary>
        /// Module.GetAllList.
        /// </summary>
        public static string GetModuleAllCacheKey = string.Concat(ModuleBaseCacheKey, ".GetAll.");

        /// <summary>
        /// Module.FindIdByCode.{0}
        /// {0}: Code
        /// </summary>
        public static string FindModuleIdByCodeCacheKey = string.Concat(ModuleBaseCacheKey, ".FindIdByCode.{0}");

        /// <summary>
        /// Module.GetSubRecursion.{0}
        /// {0}: ModuleId
        /// </summary>
        public static string GetModuleSubRecursionListCacheKey = string.Concat(ModuleBaseCacheKey, ".GetSubRecursion.{0}");

        #endregion

        #region ModuleButton

        /// <summary>
        /// ModuleButton.GetAllByModuleId.{0}
        /// {0}: ModuleId
        /// </summary>
        public static string GetModuleButtonAllCacheKey = string.Concat(ModuleButtonBaseCacheKey, ".GetAllByModuleId.{0}");

        #endregion

        #region ModuleColumn

        /// <summary>
        /// ModuleColumn.GetAllByModuleId.{0}
        /// {0}: ModuleId
        /// </summary>
        public static string GetModuleColumnAllCacheKey = string.Concat(ModuleColumnBaseCacheKey, ".GetAllByModuleId.{0}");

        #endregion

        #region ModuleService

        /// <summary>
        /// ModuleService.GetAllByModuleId.{0}
        /// {0}: ModuleId
        /// </summary>
        public static string GetModuleServiceAllCacheKey = string.Concat(ModuleServiceBaseCacheKey, ".GetAllByModuleId.{0}");

        #endregion

        /// <summary>
        /// 获取/设置缓存过期时间.
        /// 默认: 20 分钟.
        /// </summary>
        public static TimeSpan CacheExpireTime { get; private set; }

        public object CacheValue { get; set; }

        static ModuleObjectCacheItem()
        {
            CacheExpireTime = TimeSpan.FromMinutes(20);
        }

        public ModuleObjectCacheItem()
        {
            CacheValue = null;
        }
    }
}