From a911a305e1c2ef48d1224c6a598b6de7cc908969 Mon Sep 17 00:00:00 2001 From: what Date: Mon, 25 Nov 2024 15:28:19 +0800 Subject: [PATCH] =?UTF-8?q?[feat]=20=E5=AE=8C=E5=96=84=20NewVirtualResourc?= =?UTF-8?q?e=20=E6=96=B9=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- base/resource.go | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) 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, } }