Example #1
0
        /// <summary>
        /// 转成Api资源参数
        /// </summary>
        public static ApiResourceDto ToApiResourceDto(this ResourcePo po)
        {
            if (po == null)
            {
                return(null);
            }
            var result = po.MapTo <ApiResourceDto>();
            var extend = Json.ToObject <ApiResourceExtend>(po.Extend);

            extend.MapTo(result);
            return(result);
        }
Example #2
0
        /// <summary>
        /// 转换为身份资源实体
        /// </summary>
        public static IdentityResource ToIdentityResource(this ResourcePo po)
        {
            if (po == null)
            {
                return(null);
            }
            var result = po.MapTo(new IdentityResource(po.Id));
            var extend = Json.ToObject <IdentityResourceExtend>(po.Extend);

            extend.MapTo(result);
            return(result);
        }
        /// <summary>
        /// 转成模块参数
        /// </summary>
        public static ModuleDto ToModuleDto(this ResourcePo po)
        {
            if (po == null)
            {
                return(null);
            }
            var result = po.MapTo <ModuleDto>();

            result.Url = po.Uri;
            var extend = Json.ToObject <ModuleExtend>(po.Extend);

            extend.MapTo(result);
            return(result);
        }
        /// <summary>
        /// 转换为模块
        /// </summary>
        /// <param name="po">资源持久化对象</param>
        public static Module ToModule(this ResourcePo po)
        {
            if (po == null)
            {
                return(null);
            }
            if (po.Type != ResourceType.Module)
            {
                return(null);
            }
            var result = po.MapTo(new Module(po.Id, po.Path, po.Level));

            result.Url = po.Uri;
            var extend = JsonHelper.ToObject <ModuleExtend>(po.Extend);

            extend.MapTo(result);
            return(result);
        }
        /// <summary>
        /// 转换为操作
        /// </summary>
        /// <param name="po">资源持久化对象</param>
        public static Operation ToOperation(this ResourcePo po)
        {
            if (po == null)
            {
                return(null);
            }
            if (po.Type != ResourceType.Operation)
            {
                return(null);
            }
            var result = po.MapTo(new Operation(po.Id));

            result.ModuleId = po.ParentId.SafeValue();
            result.Code     = po.Uri;
            var extend = JsonHelper.ToObject <OperationExtend>(po.Extend);

            extend.MapTo(result);
            return(result);
        }
        /// <summary>
        /// 转成模块参数
        /// </summary>
        public static ModuleDto ToModuleDto(this ResourcePo po)
        {
            if (po == null)
            {
                return(null);
            }
            var result = po.MapTo <ModuleDto>();

            result.Url = po.Uri;
            var extend = Json.ToObject <ModuleExtend>(po.Extend);

            result.Icon     = extend?.Icon;
            result.Expanded = extend?.Expanded;
            if (po.Parent != null)
            {
                result.ParentName = po.Parent.Name;
            }
            if (po.Application != null)
            {
                result.ApplicationName = po.Application.Name;
            }
            return(result);
        }