diff --git a/backend/internal/entity/upstream/model.go b/backend/internal/entity/upstream/model.go index d1d189aa..588e23c3 100644 --- a/backend/internal/entity/upstream/model.go +++ b/backend/internal/entity/upstream/model.go @@ -8,6 +8,7 @@ import ( "npm/internal/database" "npm/internal/entity/nginxtemplate" "npm/internal/entity/upstreamserver" + "npm/internal/entity/user" "npm/internal/status" "npm/internal/types" "npm/internal/util" @@ -39,6 +40,7 @@ type Model struct { // Expansions Servers []upstreamserver.Model `json:"servers"` NginxTemplate *nginxtemplate.Model `json:"nginx_template,omitempty"` + User *user.Model `json:"user,omitempty"` } func (m *Model) getByQuery(query string, params []interface{}) error { @@ -121,6 +123,12 @@ func (m *Model) Expand(items []string) error { m.Servers, err = upstreamserver.GetByUpstreamID(m.ID) } + if util.SliceContainsItem(items, "user") && m.ID > 0 { + var usr user.Model + usr, err = user.GetByID(m.UserID) + m.User = &usr + } + if util.SliceContainsItem(items, "nginxtemplate") && m.NginxTemplateID > 0 { var templ nginxtemplate.Model templ, err = nginxtemplate.GetByID(m.NginxTemplateID)