Giter Club home page Giter Club logo

abp.datadictionary's People

Contributors

as260405901 avatar dhssingle avatar gdlcf88 avatar mvanrooyen avatar real-zony avatar seventh88 avatar slarkerino avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

abp.datadictionary's Issues

能否将找不到字典数据时的异常处理交给用户决定

CacheDataDictionaryValueProvider 在找不到字典数据时直接抛出了404
但个人感觉其实这种情况下,直接返回null,不渲染或者fallback就行了。

能否根据用户的配置进行异常处理?

throw new EntityNotFoundException(StringLocalizer["DataDictionary:CacheItemNotFound"]);

能否支持自动渲染复杂对象

很常见地,数据对象会有一些非简单类型的成员、列表等也可能含有需要渲染的字典字段。
以目前的方式,只能逐个去手动处理,在试着手动渲染了几处之后,发现非常的麻烦且冗余。

希望能加上自动渲染复杂对象的功能。

我尝试自己扩展,临时实现了一下,方式可能不是太好,供参考。

加了一个特性:DictionaryChildFieldAttribute,用来标记需要进一步渲染的字段。

扩展了DataDictionaryLoaderScanRules方法:
把标记了DictionaryChildField的字段记录下来,并且判断一下是否是IEnumerable,也记录下来
这里借用了 DataDictionaryRule ,临时用自己的方式保存了规则信息

               var properties = type
                    .GetProperties()
                    .Where(p => p.IsDefined(typeof(DictionaryChildFieldAttribute)))
                    .ToList();

                rules.AddRange(properties.Select(property => new DataDictionaryRule
                {
                    DictionaryCode = property.PropertyType.IsAssignableTo(typeof(IEnumerable)) ? "IEnumerable" : "",
                    DtoType = type, 
                    RenderFieldProperty = property, 
                    DictionaryCodeProperty = null
                }));

在需要的字段加上这个特性作为标记:

public class PlanDto {

        [DictionaryCodeField(“Category")]
        public string Category { get; set; }

        [DictionaryRenderField(“Category")]
        public string CategoryName { get; set; }

        [DictionaryChildField] 
        public List<TeamDto> Teams {get;set;}
 
        [DictionaryChildField]
        public User Manager {get;set;}
}

扩展了一个非泛型的Render方法,将 Type 作为参数传入: Task RenderAsync(object sourceDto, Type dtoType)

渲染时,增加了对”新规则“的处理:

               if (rule.DictionaryCodeProperty == null)
                {
                    var childDto = rule.RenderFieldProperty.GetValue(sourceDto);
                    if (rule.DictionaryCode == "IEnumerable" && childDto != null)
                    {
                        var type = rule.RenderFieldProperty.PropertyType.GenericTypeArguments.FirstOrDefault();
                        foreach (var item in (IEnumerable) childDto)
                        {
                            await RenderAsync(item, type);
                        }
                    }
                    else
                    {
                        await RenderAsync(childDto, rule.RenderFieldProperty.PropertyType);    
                    }
                    
                    continue;
                }

目前使用暂无问题,但还是希望用上原生功能

能否支持 CodeField -> RenderField 一对多的关系?

有时候一个 code ,可能会用来渲染多个不同的字段:
比如:

[
 {code:1,name:'一级',color:'红色'},
 {code:2,name:'二级',color:'蓝色'}
]

根据以上数据分别定义了字典LevelNameLevelColor ,略...

[DictionaryCodeField("LevelName")] // <-- Color 怎么办
public string Code {get;set;}

[DictionaryCodeField("LevelName")]
public string Name {get;set;}

[DictionaryCodeField("LevelColor")]
public string Color {get;set;}

现在的版本是否能在ABP4.4.4上运行

我在4.4.4版本上安装并参考说明文档配置了1.1.2版本的包

使用时遇到没有任何报错 ,但是始终没有渲染字典项中的中文描述

现在找不到原因,求助一下

image

image

image

image

Data dictionary purpose

Hi

Can you tell me more about the intent of the data dictionary module?

Will it be possible to use it to document the domain layer, or is it to document the data transfer objects?

Or, am I missing the point.

Thanks
Jamie

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.