
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Com.FirmLib.UI
{
    public static class ProjectIdManager
    {
        public static string Prefix = "Pj";
        /// <summary>
        /// 获取系统使用id
        /// </summary>
        /// <param name="projectId"></param>
        /// <returns></returns>
        public static string GetSystemProjectId(string projectId)
        {
            if (string.IsNullOrEmpty(projectId))
                return projectId;
            if (!HasPrefix(projectId))
            {
                projectId = Prefix + projectId;
            }

            return projectId;
        }
        /// <summary>
        /// 获取前台展示id
        /// </summary>
        /// <param name="projectId"></param>
        /// <returns></returns>
        public static string GetForeSystemProjectId(string projectId)
        {
            if (string.IsNullOrEmpty(projectId))
                return projectId;
            if (HasPrefix(projectId))
            {
                projectId = projectId.Substring(2);
            }
            return projectId;
        }
        /// <summary>
        /// 存在前缀
        /// </summary>
        private static bool  HasPrefix(string projectId)
        {
            if (string.IsNullOrEmpty(projectId))
                return false;
            return projectId.StartsWith(Prefix);
        }
    }
}
