Skip to content

Commit 610dc4f

Browse files
committed
docs: synced via GitHub Actions
1 parent 5f7e2e4 commit 610dc4f

File tree

4 files changed

+354
-36
lines changed

4 files changed

+354
-36
lines changed

src/dev-guide/orm/file-field.md

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# 附件和附件列表字段
2+
3+
## 实现原理
4+
5+
1.`orm.xml`模型中为字段设置【标准域】为file,也就是`stdDomain="file"`
6+
2.`orm.xml``x:post-extends`段中引入`<orm-gen:DefaultPostExtends/>`标签
7+
3. DefaultPostExtends标签中会调用FileComponentSupport标签,在这个标签中会遍历所有`stdDomain=file`的字段,并为它们生成对应的FileComponent字段定义。
8+
9+
![](images/file-component.png)
10+
11+
```xml
12+
13+
<orm>
14+
<x:post-extends>
15+
<orm-gen:DefaultPostExtends xpl:lib="/nop/orm/xlib/orm-gen.xlib"/>
16+
</x:post-extends>
17+
18+
<entities>
19+
<entity className="io.nop.auth.dao.entity.NopAuthUser" attrs="...">
20+
<columns>
21+
<column code="AVATAR" displayName="头像" domain="image" name="avatar" precision="100" propId="10"
22+
stdDataType="string" stdDomain="file" stdSqlType="VARCHAR" i18n-en:displayName="Avatar"
23+
ui:show="X"/>
24+
</columns>
25+
</entity>
26+
</entities>
27+
</orm>
28+
```
29+
30+
4.`OrmSession.flush`的时候会调用所有实体的所有Component属性上的onEntityFlush回调函数。`OrmFileComponent.onEntityFlush`会将上传的临时文件和当前实体属性进行关联。如果实体属性此前已经关联了其他文件,则会自动删除上一次上传的文件。
31+
32+
85.3 KB
Loading

src/theory/nop/uiotos.webp

60.8 KB
Loading

0 commit comments

Comments
 (0)