File tree Expand file tree Collapse file tree 4 files changed +354
-36
lines changed
Expand file tree Collapse file tree 4 files changed +354
-36
lines changed Original file line number Diff line number Diff line change 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+
You can’t perform that action at this time.
0 commit comments