Skip to content

Commit

Permalink
feat: add planKey
Browse files Browse the repository at this point in the history
  • Loading branch information
goxiaoy committed Nov 1, 2023
1 parent b40f16d commit fff8140
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 12 deletions.
2 changes: 1 addition & 1 deletion examples/ent/tenant_store.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ func (t *TenantStore) GetByNameOrId(ctx context.Context, nameOrId string) (*saas
return nil, err
}
}
ret := saas.NewTenantConfig(strconv.Itoa(te.ID), te.Name, te.Region)
ret := saas.NewTenantConfig(strconv.Itoa(te.ID), te.Name, te.Region, "")
conns, err := te.QueryConn().All(ctx)
if err != nil {
return nil, err
Expand Down
2 changes: 1 addition & 1 deletion examples/gorm/tenant.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ func (t *TenantStore) GetByNameOrId(ctx context.Context, nameOrId string) (*saas
return nil, err
}
}
ret := saas.NewTenantConfig(tenant.ID, tenant.Name, tenant.Region)
ret := saas.NewTenantConfig(tenant.ID, tenant.Name, tenant.Region, "")
for _, conn := range tenant.Conn {
ret.Conn[conn.Key] = conn.Value
}
Expand Down
20 changes: 11 additions & 9 deletions tenant_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,19 @@ package saas
import "github.com/go-saas/saas/data"

type TenantConfig struct {
ID string `json:"id"`
Name string `json:"name"`
Region string `json:"region"`
Conn data.ConnStrings `json:"conn"`
ID string `json:"id"`
Name string `json:"name"`
Region string `json:"region"`
PlanKey string `json:"planKey"`
Conn data.ConnStrings `json:"conn"`
}

func NewTenantConfig(id string, name string, region string) *TenantConfig {
func NewTenantConfig(id, name, region, planKey string) *TenantConfig {
return &TenantConfig{
ID: id,
Name: name,
Region: region,
Conn: make(data.ConnStrings),
ID: id,
Name: name,
Region: region,
PlanKey: planKey,
Conn: make(data.ConnStrings),
}
}
2 changes: 1 addition & 1 deletion tenant_config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
)

func TestTenantConfig(t *testing.T) {
in := []byte(`{"id":"1","name":"1","region":"1","conn":{"a":"a","b":"b"}}`)
in := []byte(`{"id":"1","name":"1","region":"1","planKey":"","conn":{"a":"a","b":"b"}}`)
conf := &TenantConfig{}
err := json.Unmarshal(in, &conf)
assert.NoError(t, err)
Expand Down

0 comments on commit fff8140

Please sign in to comment.