Skip to content

Commit aae9579

Browse files
committed
Refactor some reflection
1 parent d437c6b commit aae9579

File tree

20 files changed

+287
-300
lines changed

20 files changed

+287
-300
lines changed

backend/internal/api/middleware/list_query.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import (
99

1010
c "npm/internal/api/context"
1111
h "npm/internal/api/http"
12-
"npm/internal/entity"
1312
"npm/internal/model"
1413
"npm/internal/tags"
1514
"npm/internal/util"
@@ -23,7 +22,7 @@ import (
2322
// After we have determined what the Filters are to be, they are saved on the Context
2423
// to be used later in other endpoints.
2524
func ListQuery(obj interface{}) func(http.Handler) http.Handler {
26-
schemaData := entity.GetFilterSchema(obj, true)
25+
schemaData := tags.GetFilterSchema(obj)
2726
filterMap := tags.GetFilterMap(obj)
2827

2928
return func(next http.Handler) http.Handler {

backend/internal/entity/accesslist/model.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,16 @@ package accesslist
22

33
import (
44
"npm/internal/database"
5-
"npm/internal/entity"
65
"npm/internal/entity/user"
6+
"npm/internal/model"
77
"npm/internal/types"
88

99
"github.com/rotisserie/eris"
1010
)
1111

1212
// Model is the model
1313
type Model struct {
14-
entity.ModelBase
14+
model.ModelBase
1515
UserID uint `json:"user_id" gorm:"column:user_id" filter:"user_id,integer"`
1616
Name string `json:"name" gorm:"column:name" filter:"name,string"`
1717
Meta types.JSONB `json:"meta" gorm:"column:meta"`

backend/internal/entity/auth/model.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ package auth
22

33
import (
44
"npm/internal/database"
5-
"npm/internal/entity"
5+
"npm/internal/model"
66

77
"github.com/rotisserie/eris"
88
"golang.org/x/crypto/bcrypt"
@@ -15,7 +15,7 @@ const (
1515

1616
// Model is the model
1717
type Model struct {
18-
entity.ModelBase
18+
model.ModelBase
1919
UserID uint `json:"user_id" gorm:"column:user_id"`
2020
Type string `json:"type" gorm:"column:type;default:password"`
2121
Secret string `json:"secret,omitempty" gorm:"column:secret"`

backend/internal/entity/certificate/model.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,11 @@ import (
1010
"npm/internal/acme"
1111
"npm/internal/config"
1212
"npm/internal/database"
13-
"npm/internal/entity"
1413
"npm/internal/entity/certificateauthority"
1514
"npm/internal/entity/dnsprovider"
1615
"npm/internal/entity/user"
1716
"npm/internal/logger"
17+
"npm/internal/model"
1818
"npm/internal/serverevents"
1919
"npm/internal/types"
2020
"npm/internal/util"
@@ -44,7 +44,7 @@ const (
4444

4545
// Model is the model
4646
type Model struct {
47-
entity.ModelBase
47+
model.ModelBase
4848
UserID uint `json:"user_id" gorm:"column:user_id" filter:"user_id,integer"`
4949
Type string `json:"type" gorm:"column:type" filter:"type,string"`
5050
CertificateAuthorityID types.NullableDBUint `json:"certificate_authority_id" gorm:"column:certificate_authority_id" filter:"certificate_authority_id,integer"`

backend/internal/entity/certificateauthority/model.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,15 @@ import (
55
"path/filepath"
66

77
"npm/internal/database"
8-
"npm/internal/entity"
98
"npm/internal/errors"
9+
"npm/internal/model"
1010

1111
"github.com/rotisserie/eris"
1212
)
1313

1414
// Model is the model
1515
type Model struct {
16-
entity.ModelBase
16+
model.ModelBase
1717
Name string `json:"name" gorm:"column:name" filter:"name,string"`
1818
AcmeshServer string `json:"acmesh_server" gorm:"column:acmesh_server" filter:"acmesh_server,string"`
1919
CABundle string `json:"ca_bundle" gorm:"column:ca_bundle" filter:"ca_bundle,string"`

backend/internal/entity/dnsprovider/model.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,16 @@ import (
55

66
"npm/internal/database"
77
"npm/internal/dnsproviders"
8-
"npm/internal/entity"
98
"npm/internal/logger"
9+
"npm/internal/model"
1010
"npm/internal/types"
1111

1212
"github.com/rotisserie/eris"
1313
)
1414

1515
// Model is the model
1616
type Model struct {
17-
entity.ModelBase
17+
model.ModelBase
1818
UserID uint `json:"user_id" gorm:"column:user_id" filter:"user_id,integer"`
1919
Name string `json:"name" gorm:"column:name" filter:"name,string"`
2020
AcmeshName string `json:"acmesh_name" gorm:"column:acmesh_name" filter:"acmesh_name,string"`

backend/internal/entity/filters.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import (
99
func GetFilterMap(m interface{}, includeBaseEntity bool) map[string]model.FilterMapValue {
1010
filterMap := tags.GetFilterMap(m)
1111
if includeBaseEntity {
12-
return mergeFilterMaps(tags.GetFilterMap(ModelBase{}), filterMap)
12+
return mergeFilterMaps(tags.GetFilterMap(model.ModelBase{}), filterMap)
1313
}
1414

1515
return filterMap

backend/internal/entity/filters_schema.go

Lines changed: 0 additions & 252 deletions
This file was deleted.

backend/internal/entity/host/model.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@ package host
33
import (
44
"fmt"
55
"npm/internal/database"
6-
"npm/internal/entity"
76
"npm/internal/entity/certificate"
87
"npm/internal/entity/nginxtemplate"
98
"npm/internal/entity/upstream"
109
"npm/internal/entity/user"
10+
"npm/internal/model"
1111
"npm/internal/status"
1212
"npm/internal/types"
1313
"npm/internal/util"
@@ -26,7 +26,7 @@ const (
2626

2727
// Model is the model
2828
type Model struct {
29-
entity.ModelBase
29+
model.ModelBase
3030
UserID uint `json:"user_id" gorm:"column:user_id" filter:"user_id,integer"`
3131
Type string `json:"type" gorm:"column:type" filter:"type,string"`
3232
NginxTemplateID uint `json:"nginx_template_id" gorm:"column:nginx_template_id" filter:"nginx_template_id,integer"`

0 commit comments

Comments
 (0)