【更新】 更新readme 更新关于可空数据的介绍

【调整】 增加类型名作为可空非多态bean的非空标识(与多态一致)
main
walon 2021-07-01 10:16:54 +08:00
parent bf3cae5d1a
commit 1a9547769d
5 changed files with 37 additions and 21 deletions

View File

@ -1,5 +1,3 @@
[//]: # "Author: bug"
[//]: # "Date: 2020-10-20 20:24:07"
# Luban
@ -26,6 +24,14 @@ Luban适合有以下需求的开发者
3. 希望做其他自定义生成或者缓存
## 支持和联系
有使用上的疑问请即时加QQ群询问随时帮助解决。
- QQ 群: 692890842
- 邮箱: taojingjian#gmail.com
## 文档
- [主页](https://focus-creative-games.github.io/luban/index.html)
@ -115,9 +121,9 @@ Luban适合有以下需求的开发者
![ex_2](docs/images/examples/ex_2.png)
- name="TbDemoPrivitive" 表示数据表名为TbDemoPrivitive生成table的代码时使用这个类名。
- name="TbDemoPrimitive" 表示数据表名为TbDemoPrimitive生成table的代码时使用这个类名。
- value="DemoPrimitiveTypesTable" 表示数据表每行记录(即KV中的V)的类型为DemoPrimitiveTypesTable。
- index="x4" 表示数据表以 <value>类型的x4字段为key。
- index="x4" 表示数据表以 <value>类型的x4字段为key。可不填,**默认为第一个字段**。
- input="demo_primitive.xlsx" 表示数据表的数据文件为 demo_primitives.xlsx
### 枚举
@ -194,16 +200,31 @@ Luban适合有以下需求的开发者
![ex_32](docs/images/examples/ex_32.png)
### 可空数据类型
配置数据中经常有空值的语义需求实际项目中往往混杂地使用0或-1表达空值既不自然清晰也不统一。luban借鉴了c#中的可空变量的概念特地提供可空数据支持。除了string外的所有原生数据类型以及enum类型都有相应的可空数据类型。定义方式为 <类型名>?与c#里的Nullable类型定义方式相同。例如 bool?,int?,long?,double?, EColor?
配置数据中经常有空值的语义需求实际项目中往往混杂地使用0或-1表达空值既不自然清晰也不统一。luban借鉴了c#中的可空变量的概念特地提供可空数据支持。除了string外的所有原生数据类型以及enum、bean、和多态bean类型都有相应的可空数据类型。定义方式为 <类型名>?与c#里的Nullable类型定义方式相同。例如 bool?,int?,long?,double?, EColor?, DemoType?
```xml
<bean name="NullableTable">
<var name="id" type="int"/>
<var name="min_level" type="int?"/>
<var name="color" type="DemoEnum?"/>
</bean>
<bean name="DemoType1">
<var name="x1" type="int"/>
</bean>
<bean name="DemoDynamic"> 多态数据结构
<var name="x1" type="int"/>
<table name="TbNullable" value="NullableTable" input="nullable.xlsx">
<bean name="DemoD2" alias="测试别名">
<var name="x2" type="int"/>
</bean>
<bean name="DemoD3">
<var name="x3" type="int"/>
</bean>
</bean>
<bean name="TestNull">
<var name="id" type="int"/>
<var name="x1" type="int?"/>
<var name="x2" type="DemoEnum?"/>
<var name="x3" type="DemoType1?"/>
<var name="x4" type="DemoDynamic?"/>
</bean>
<table name="TbTestNull" value="TestNull" input="test/test_null.xlsx"/>
```
![ex_42](docs/images/examples/ex_42.png)
@ -771,12 +792,7 @@ return
- [.NET Core source index](https://source.dot.net)
## 支持和联系
```
QQ 群: 692890842
邮箱: taojingjian#gmail.com
```
## License

Binary file not shown.

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.4 KiB

After

Width:  |  Height:  |  Size: 10 KiB

View File

@ -352,9 +352,9 @@ namespace Luban.Job.Cfg.DataCreators
{
return null;
}
else if (subType != DefBean.BEAN_NOT_NULL_STR)
else if (subType != DefBean.BEAN_NOT_NULL_STR && subType != originBean.Name)
{
throw new Exception($"type:{type.Bean.FullName} 可空标识:{subType} 不合法(只能为{DefBean.BEAN_NOT_NULL_STR}或{DefBean.BEAN_NULL_STR})");
throw new Exception($"type:{type.Bean.FullName} 可空标识:{subType} 不合法(只能为{DefBean.BEAN_NOT_NULL_STR}或{DefBean.BEAN_NULL_STR}或{originBean.Name})");
}
}
return new DBean(originBean, originBean, CreateBeanFields(originBean, x, ass));

View File

@ -208,9 +208,9 @@ namespace Luban.Job.Cfg.DataCreators
{
return null;
}
else if (subType != DefBean.BEAN_NOT_NULL_STR)
else if (subType != DefBean.BEAN_NOT_NULL_STR && subType != originBean.Name)
{
throw new Exception($"type:{type.Bean.FullName} {DefBean.TYPE_NAME_KEY}:{subType} 不合法(只能为{DefBean.BEAN_NOT_NULL_STR}或{DefBean.BEAN_NULL_STR})");
throw new Exception($"type:{type.Bean.FullName} 可空标识:{subType} 不合法(只能为{DefBean.BEAN_NOT_NULL_STR}或{DefBean.BEAN_NULL_STR}或{originBean.Name})");
}
}