Skip to content

Commit

Permalink
fix: 修改modelserter
Browse files Browse the repository at this point in the history
  • Loading branch information
2637309949 committed Jul 15, 2021
1 parent 1c12396 commit cd0c259
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 1 deletion.
2 changes: 1 addition & 1 deletion platform/api/app.dolphin.go
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ func (dol *Dolphin) Reflesh() error {
dol.Manager.AddBusinessDB(domain.Domain.String, db)
}

platBindModelNames := dol.Manager.ModelSet().ByNotName(Name)
platBindModelNames := dol.Manager.ModelSet().NameSpaces(Name)
filtedDomains := funk.Filter(domains, func(domain types.SysDomain) bool { return domain.IsSync.Int64 != 1 }).([]types.SysDomain)
for i := range filtedDomains {
asyncOnce.Do(func() {
Expand Down
13 changes: 13 additions & 0 deletions platform/api/app.model.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ package api
import (
"sync"

"github.com/2637309949/dolphin/platform/util/slice"
"github.com/spf13/viper"
)

Expand All @@ -20,6 +21,7 @@ type ModelSetter interface {
Add(Table, ...string)
ByName(string) []Table
ByNotName(string) []Table
NameSpaces(...string) (names []string)
Release()
}

Expand All @@ -29,6 +31,17 @@ type defaultModelSetter struct {
m map[string][]Table
}

// Add defined add models
func (s *defaultModelSetter) NameSpaces(n ...string) (names []string) {
for k := range s.m {
if slice.StrSliceContains(n, k) {
continue
}
names = append(names, k)
}
return
}

// Add defined add models
func (s *defaultModelSetter) Add(m Table, n ...string) {
s.lock.Lock()
Expand Down
Binary file modified platform/x_test.db
Binary file not shown.
Binary file modified platform/x_test_localhost.db
Binary file not shown.

0 comments on commit cd0c259

Please sign in to comment.