平台内置参数(作为sql和mapper参数)


后端接口内置参数(全局参数)

//作为第三方开启的权限,全部小写
 dictionaryUrl["_fromOpenAuth"] = sqlConfig.ResponseFieldTemp.FromOpenAuth;
 //读取文件的配置数据
 dictionaryUrl["_dataFromType"] = sqlConfig.ResponseFieldTemp.DataFromType.ToString().ToLower();

namespace RG3.PF.Abstractions.Consts
{
    /// <summary>
    /// 系统 公共的参数信息
    /// </summary>
    public partial class SystemParamConst
    {

        /// <summary>
        /// 存储token KEY accessToken
        /// </summary>
        public const string TOKEN_KEY = "Authorization";

        #region  系统参数
        /// <summary>
        /// 星期几
        /// </summary>
        public const string CURRENT_DAY_WEEK = "_currentDayWeek";



        /// <summary>
        /// 当日 开始时间
        /// </summary>
        public const string CURRENT_DAY_S = "_currentDayS";
        public const string CURRENT_DAY_E = "_currentDayE";
        /// <summary>
        /// 近7日、近1周 开始时间
        /// </summary>
        public const string CURRENT_DAY7_S = "_currentDay7S";
        public const string CURRENT_DAY7_E = "_currentDay7E";

        /// <summary>
        /// 当周 开始时间
        /// </summary>
        public const string CURRENT_WEEK_S = "_currentWeekS";
        public const string CURRENT_WEEK_E = "_currentWeekE";

        /// <summary>
        /// 当月 开始时间
        /// </summary>
        public const string CURRENT_MONTH_S = "_currentMonthS";
        public const string CURRENT_MONTH_E = "_currentMonthE";
        /// <summary>
        /// 当年 开始时间
        /// </summary>
        public const string CURRENT_YEAR_S = "_currentYearS";
        public const string CURRENT_YEAR_E = "_currentYearE";
        /// <summary>
        ///当前 小时 开始时间
        /// </summary>
        public const string CURRENT_HOUR_S = "_currentHourS";
        public const string CURRENT_HOUR_E = "_currentHourE";
        /// <summary>
        /// 最近5分钟 开始时间
        /// </summary>
        public const string CURRENT_MINUTE5_S = "_currentMinute5S";
        public const string CURRENT_MINUTE5_E = "_currentMinute5E";
        /// <summary>
        /// 最近10分钟 开始时间
        /// </summary>
        public const string CURRENT_MINUTE10_S = "_currentMinute10S";
        public const string CURRENT_MINUTE10_E = "_currentMinute10E";
        /// <summary>
        /// 最近15分钟 开始时间
        /// </summary>
        public const string CURRENT_MINUTE15_S = "_currentMinute15S";
        public const string CURRENT_MINUTE15_E = "_currentMinute15E";
        /// <summary>
        /// 最近30分钟 开始时间
        /// </summary>
        public const string CURRENT_MINUTE30_S = "_currentMinute30S";
        public const string CURRENT_MINUTE30_E = "_currentMinute30E";
        /// <summary>
        /// 最近45分钟 开始时间
        /// </summary>
        public const string CURRENT_MINUTE45_S = "_currentMinute45S";
        public const string CURRENT_MINUTE45_E = "_currentMinute45E";
        /// <summary>
        /// 最近60分钟 开始时间
        /// </summary>
        public const string CURRENT_MINUTE60_S = "_currentMinute60S";
        /// <summary>
        /// 最近60分钟 结束时间
        /// </summary>
        public const string CURRENT_MINUTE60_E = "_currentMinute60E";
        #endregion

        #region 未来参数
        /// <summary>
        /// 当前月份  6
        /// </summary>
        public const string CURRENT_MONTH = "_currentMonth";
        /// <summary>
        /// 当前年 2021
        /// </summary>
        public const string CURRENT_YEAR = "_currentYear";

        /// <summary>
        /// 未来近1周 
        /// </summary>
        public const string FUTURE_WEEK01_S = "_futureWeek01S";
        /// <summary>
        /// 未来近1周
        /// </summary>
        public const string FUTURE_WEEK01_E = "_futureWeek01E";

        /// <summary>
        /// 未来近1个月份 
        /// </summary>
        public const string FUTURE_MONTH01_S = "_futureMonth01S";
        /// <summary>
        /// 未来近1个月份
        /// </summary>
        public const string FUTURE_MONTH01_E = "_futureMonth01E";
        /// <summary>
        /// 未来近3个月份 
        /// </summary>
        public const string FUTURE_MONTH03_S = "_futureMonth03S";
        /// <summary>
        /// 未来近3个月份
        /// </summary>
        public const string FUTURE_MONTH03_E = "_futureMonth03E";
        /// <summary>
        /// 未来近6个月份 
        /// </summary>
        public const string FUTURE_MONTH06_S = "_futureMonth06S";
        /// <summary>
        /// 未来近6个月份
        /// </summary>
        public const string FUTURE_MONTH06_E = "_futureMonth06E";

        /// <summary>
        /// 未来近12个月份 
        /// </summary>
        public const string FUTURE_MONTH12_S = "_futureMonth12S";
        /// <summary>
        /// 未来近12个月份
        /// </summary>
        public const string FUTURE_MONTH012_E = "_futureMonth12E";
        #endregion

        #region  当前公共参数  存储到缓存

        /// <summary>
        ///当前时间   常用  开始时间结尾   00:00:00
        /// </summary>
        public const string FILTER_DATE_S = "_filterDateS";

        /// <summary>
        ///当前时间   常用  开始时间结尾   23:59:59
        /// </summary>
        public const string FILTER_DATE_E = "_filterDateE";

        /// <summary>
        ///当前时间   常用
        /// </summary>
        public const string CURRENT_DATE = "_currentDate";

        /// <summary>
        /// 当前用户 id  常用
        /// </summary>
        public const string CURRENT_USER_ID = "_userId";

        /// <summary>
        /// 平台默认密码 md加密的结果
        /// </summary>
        public const string CURRENT_DEF_PWSD = "_defaultPwsd";

        /// <summary>
        /// 当前用户手机号  常用
        /// </summary>
        public const string CURRENT_TELEPHONE = "_telephone";

        /// <summary>
        /// 当前 登录账号名
        /// </summary>
        public const string CURRENT_USER_NAME = "_userName";



        public const string DEFAULT_ROLE_ID = "_defaultRoleId";
        public const string DEFALUE_AREA_CODE = "_defaultAreaCode";
        public const string DEFAULT_DEP_ID = "_defaultDepId";
        public const string DEFAULT_JOB_ID = "_defaultJobId";
        public const string DEFAULT_SYS_ID = "_defaultSysId";



        /// <summary>
        /// 开发者
        /// </summary>
        public const string CURRENT_USER_DEVELOPER = "_developer";

        /// <summary>
        ///当前系统ID
        /// </summary>
        public const string CURRENT_SYS_ID = "_sysId";

        /// <summary>
        ///当前所属部门 depId  数组
        /// </summary>
        public const string CURRENT_DEP_ID = "_depId";


        /// <summary>
        ///当前用户拥有的其它用户id
        /// </summary>
        public const string CURRENT_MERGE_USER_ID = "_mergeUserId";

        /// <summary>
        ///当前职位 depId  数组
        /// </summary>
        public const string CURRENT_JOB_ID = "_jobId";

        /// <summary>
        ///当前用户拥有查看的行政区划  数组
        /// </summary>
        public const string CURRENT_AREA_CODE = "_areaCode";


        /// <summary>
        ///当前过滤的行政区
        /// </summary>
        public const string CURRENT_FILTER_AREA_CODE = "_filterAreaCode";

        /// <summary>
        /// 特殊权限的用户ID
        /// </summary>
        public const string FILTER_USER_ID = "_filterUser";

        /// <summary>
        ///当前角色 roleId  存储数组
        /// </summary>
        public const string CURRENT_ROLE_ID = "_roleId";

        /// <summary>
        ///当前系统 参数全部信息   _sysParam
        ///RG3.PF  缓存里面需要设置
        /// </summary>
        public const string CURRENT_SYS_PARAM = "_sysParam";

        #endregion

        #region 头部参数
        /// <summary>
        ///  API有效性验证  值存储在 header里面  _verifyApi
        /// </summary>
        public const string VERIFY_API = "_verifyApi";

        /// <summary>
        ///  短信验证  验证码等 存储表示key的名称
        /// </summary>
        public const string VERIFY_GUID = "verifyGuid";
        /// <summary>
        ///  短信验证  验证码等 存储表示值的名称
        /// </summary>
        public const string VERIFY_CODE = "verifyCode";

        /// <summary>
        ///  //当前经度  GC102  _userLng
        /// </summary>
        public const string USER_LNG = "_userLng";

        /// <summary>
        ///  当前纬度  GC102  _userLat
        /// </summary>
        public const string USER_LAT = "_userLat";

        /// <summary>
        ///  当前 行政编码
        /// </summary>
        public const string USER_AREA_CODE = "_userAreaCode";

        /// <summary>
        ///  来源应用 
        /// </summary>
        public const string FROM_APP_ID = "_fromAppId";

        /// <summary>
        ///  项目
        /// </summary>
        public const string OWNER_ID = "_ownerId";

        /// <summary>
        ///  项目 URL 传递
        /// </summary>
        public const string PARAM_OWNER_ID = "ownerId";

        /// <summary>
        ///  头前缀
        /// </summary>
        public const string HEADER_BEFORE_SUFFIX = "X";

        /// <summary>
        /// 来至用户分享的id
        /// </summary>
        public const string USER_FROM_FIRST_SHARE_ID = "_userFromFirstShareId";
        /// <summary>
        /// 来至用户分享的二级ID
        /// </summary>
        public const string USER_FROM_SECOND_SHARE_ID = "_userFromSecondShareId";
        #endregion
    }
}

后端接口内置参数(全局参数)源码刨析


public void SetFilterPopedomUserToDicByAppConfig(string ownerId, string sysId, Dictionary<string, object> dictionaryUrl, string path = "~/Config", HttpContext accessor = null)
{
    if (dictionaryUrl == null) dictionaryUrl = new Dictionary<string, object>();
    IConfigurationRoot configurationRoot = GetConfigurationAppConfig(ownerId, sysId, path, accessor);
    //设置默认没有用户时候,需要用户变量问题 20190916 cbg
    if (!dictionaryUrl.ContainsKey("_userId"))
    {
        dictionaryUrl["_userId"] = configurationRoot.GetValue<string>("default:userId") ?? "0";
    }

    DateTime currentDate = DateTime.Now;
    //设置时间条件 当年  _currentYearS  _currentYearE
    dictionaryUrl["_currentYearS"] = DateTimeUtil.GetTimeStartByType(DataTimeType.Year, currentDate);
    dictionaryUrl["_currentYearE"] = DateTimeUtil.GetTimeEndByType(DataTimeType.Year, currentDate);
    //设置时间条件 当季  _currentSeasonS _currentSeasonE
    dictionaryUrl["_currentSeasonS"] = DateTimeUtil.GetTimeStartByType(DataTimeType.Season, currentDate);
    dictionaryUrl["_currentSeasonE"] = DateTimeUtil.GetTimeEndByType(DataTimeType.Season, currentDate);

    //设置时间条件 当月  _currentMonthS _currentMonthE
    dictionaryUrl["_currentMonthS"] = DateTimeUtil.GetTimeStartByType(DataTimeType.Month, currentDate);
    dictionaryUrl["_currentMonthE"] = DateTimeUtil.GetTimeEndByType(DataTimeType.Month, currentDate);
    //设置时间条件 当周  _currentWeekS _currentWeekE

    dictionaryUrl["_currentWeekS"] = DateTimeUtil.GetTimeStartByType(DataTimeType.Week, currentDate);
    dictionaryUrl["_currentWeekE"] = DateTimeUtil.GetTimeEndByType(DataTimeType.Week, currentDate);
    //设置时间条件 当日  _currentDayS _currentDayE
    dictionaryUrl["_currentDayS"] = DateTimeUtil.GetTimeStartByType(DataTimeType.Day, currentDate);
    dictionaryUrl["_currentDayE"] = DateTimeUtil.GetTimeEndByType(DataTimeType.Day, currentDate);
    //设置时间条件 当时  _currentHourS  _currentHourE
    dictionaryUrl["_currentHourS"] = DateTimeUtil.GetTimeStartByType(DataTimeType.Hour, currentDate);
    dictionaryUrl["_currentHourE"] = DateTimeUtil.GetTimeEndByType(DataTimeType.Hour, currentDate);

    Dictionary<string, string> dicDefaultValues = new Dictionary<string, string>();
    _configuration.GetSection("defauleValues").Bind(dicDefaultValues);

    #region  设置新增初始化值
    if (dicDefaultValues != null && dicDefaultValues.Count > 0)
    {
        object _defaultSysId = dicDefaultValues.ContainsKey("_defaultSysId") ? dicDefaultValues["_defaultSysId"] : null;
        object _defaultRole = dicDefaultValues.ContainsKey("_defaultRoleId") ? dicDefaultValues["_defaultRoleId"] : null;
        object _defaultAreaCode = dicDefaultValues.ContainsKey("_defaultAreaCode") ? dicDefaultValues["_defaultAreaCode"] : null;
        object _defaultDepId = dicDefaultValues.ContainsKey("_defaultDepId") ? dicDefaultValues["_defaultDepId"] : null;
        dictionaryUrl["_defaultRoleId"] = _defaultRole;
        dictionaryUrl["_defaultAreaCode"] = _defaultAreaCode;
        dictionaryUrl["_defaultDepId"] = _defaultDepId;
        dictionaryUrl["_defaultSysId"] = _defaultSysId;
        foreach (var key in dicDefaultValues.Keys)
        {
            if (dictionaryUrl.ContainsKey(key)) continue;
            dictionaryUrl[key] = dicDefaultValues[key];
        }
    }
    #endregion

    //设置当前用户拥有的特殊信息
    object userId = null;
    if (dictionaryUrl.ContainsKey(SystemParamConst.CURRENT_USER_ID))
    {
        userId = dictionaryUrl[SystemParamConst.CURRENT_USER_ID];
    }
    PopedomUser puTemp = GetPopedomUserByAppConfig(ownerId, sysId, userId, path, accessor, configurationRoot);

    dictionaryUrl["_filterUser"] = puTemp.User;
    dictionaryUrl["_filterRole"] = puTemp.Role;
    dictionaryUrl["_filterEnum"] = puTemp.Enum;
    dictionaryUrl["_filterAction"] = puTemp.Action;
    dictionaryUrl["_filterMenu"] = puTemp.Menu;
    dictionaryUrl["_filterDepartment"] = puTemp.Department;
    dictionaryUrl["_filterArea"] = puTemp.Area;
    dictionaryUrl["_filterSystem"] = puTemp.System;
    dictionaryUrl["_filterProject"] = puTemp.Project;
    //设置扩展的参数信息
    if (puTemp != null && puTemp.Extand != null)
    {
        foreach (var key in puTemp.Extand.Keys)
        {
            dictionaryUrl[$"_filter{key}"] = puTemp.Extand[key];
        }
    }
    //唯一主键信息,用于外部扩展
    string machineIdI = _configuration.GetValue<string>($"snowflake:{ownerId}:machine") ?? "1";
    string datacenterId = _configuration.GetValue<string>($"snowflake:{ownerId}:{sysId}") ?? "-1";
    GidSnowflakeUtil GidSnowflakeUtil = new GidSnowflakeUtil(Convert.ToInt32(machineIdI), Convert.ToInt32(datacenterId));
    dictionaryUrl["_primaryIdV"] = GidSnowflakeUtil.GetId().ToString();
}





文档更新时间: 2021-10-17 20:06   作者:admin