From fff81406222f336cc93a46ff408825dee027c753 Mon Sep 17 00:00:00 2001 From: Goxiaoy Date: Wed, 1 Nov 2023 18:57:07 +0800 Subject: [PATCH] feat: add planKey --- examples/ent/tenant_store.go | 2 +- examples/gorm/tenant.go | 2 +- tenant_config.go | 20 +++++++++++--------- tenant_config_test.go | 2 +- 4 files changed, 14 insertions(+), 12 deletions(-) diff --git a/examples/ent/tenant_store.go b/examples/ent/tenant_store.go index 980aef1..8adc9ab 100644 --- a/examples/ent/tenant_store.go +++ b/examples/ent/tenant_store.go @@ -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 diff --git a/examples/gorm/tenant.go b/examples/gorm/tenant.go index 703a339..c901c46 100644 --- a/examples/gorm/tenant.go +++ b/examples/gorm/tenant.go @@ -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 } diff --git a/tenant_config.go b/tenant_config.go index 05d3e19..c594149 100644 --- a/tenant_config.go +++ b/tenant_config.go @@ -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), } } diff --git a/tenant_config_test.go b/tenant_config_test.go index bfc2b1d..d8b7e53 100644 --- a/tenant_config_test.go +++ b/tenant_config_test.go @@ -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)