diff --git a/base/resource.go b/base/resource.go index 4881d29..212ca81 100644 --- a/base/resource.go +++ b/base/resource.go @@ -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, } }