[feat] 完善 NewVirtualResource 方法

This commit is contained in:
what 2024-11-25 15:28:19 +08:00
parent 6675dca359
commit a911a305e1

View File

@ -440,17 +440,25 @@ func (this Resource) onUserEvent(builder *db.Builder, user req.User) {
}
func NewVirtualResource(pRes req.Resource, code, name, sql string, fields []ResField) req.Resource {
fieldsCopy := make([]ResField, len(fields))
copy(fieldsCopy, fields)
for i := 0; i < len(fieldsCopy); i++ {
fieldsCopy[i].CodeResource = code
}
return &Resource{
Uuid: code,
PUuid: pRes.GetUuid(),
Code: code,
Name: name,
IsResVirtual: true,
Table: sql,
IsResSystem: pRes.IsSystem(),
Table: sql,
IsHistoryRecord: false,
HistoryCacheMax: 0,
Fields: fields,
Fields: fieldsCopy,
Roles: nil,
}
}