Skip to content
This repository has been archived by the owner on Apr 25, 2023. It is now read-only.

Commit

Permalink
fix: 修改租户个别接口返回值类型
Browse files Browse the repository at this point in the history
  • Loading branch information
xiaoliuing committed Dec 15, 2021
1 parent 24d7ecc commit 4443d07
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 20 deletions.
33 changes: 16 additions & 17 deletions lib/management/tenant_management_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ func (c *Client) GetTenantDetails(tenantId string) (*model.TenantDetails, error)
// CreateTenant
// 创建租户
func (c *Client) CreateTenant(request *model.CreateTenantRequest) (*model.TenantDetails, error) {

data, _ := jsoniter.Marshal(request)
variables := make(map[string]interface{})
jsoniter.Unmarshal(data, &variables)
Expand All @@ -80,7 +79,7 @@ func (c *Client) CreateTenant(request *model.CreateTenantRequest) (*model.Tenant

// UpdateTenant
// 修改租户
func (c *Client) UpdateTenant(tenantId string, request *model.CreateTenantRequest) (*bool, error) {
func (c *Client) UpdateTenant(tenantId string, request *model.CreateTenantRequest) (bool, error) {

data, _ := jsoniter.Marshal(request)
variables := make(map[string]interface{})
Expand All @@ -89,7 +88,7 @@ func (c *Client) UpdateTenant(tenantId string, request *model.CreateTenantReques
url := fmt.Sprintf("%s/api/v2/tenant/%s", c.Host, tenantId)
b, err := c.SendHttpRestRequest(url, http.MethodPost, variables)
if err != nil {
return nil, err
return false, err
}
resp := &struct {
Message string `json:"message"`
Expand All @@ -98,9 +97,9 @@ func (c *Client) UpdateTenant(tenantId string, request *model.CreateTenantReques
}{}
jsoniter.Unmarshal(b, &resp)
if resp.Code != 200 {
return nil, errors.New(resp.Message)
return false, errors.New(resp.Message)
}
return &resp.Data, nil
return true, nil
}

// RemoveTenant
Expand All @@ -125,7 +124,7 @@ func (c *Client) RemoveTenant(tenantId string) (*string, error) {

// ConfigTenant
// 配置租户品牌化
func (c *Client) ConfigTenant(tenantId string, request *model.ConfigTenantRequest) (*string, error) {
func (c *Client) ConfigTenant(tenantId string, request *model.ConfigTenantRequest) (bool, error) {

data, _ := jsoniter.Marshal(request)
variables := make(map[string]interface{})
Expand All @@ -134,7 +133,7 @@ func (c *Client) ConfigTenant(tenantId string, request *model.ConfigTenantReques
url := fmt.Sprintf("%s/api/v2/tenant/%s", c.Host, tenantId)
b, err := c.SendHttpRestRequest(url, http.MethodPost, variables)
if err != nil {
return nil, err
return false, err
}
resp := &struct {
Message string `json:"message"`
Expand All @@ -143,9 +142,9 @@ func (c *Client) ConfigTenant(tenantId string, request *model.ConfigTenantReques
}{}
jsoniter.Unmarshal(b, &resp)
if resp.Code != 200 {
return nil, errors.New(resp.Message)
return resp.Data, errors.New(resp.Message)
}
return &resp.Message, nil
return resp.Data, nil
}

// GetTenantMembers
Expand Down Expand Up @@ -434,7 +433,7 @@ func (c *Client) CheckExtIdpConnectionIdentifierUnique(identifier string) (bool,

// ChangeExtIdpConnectionState
// 开关身份源连接
func (c *Client) ChangeExtIdpConnectionState(extIdpConnectionId string, request *model.ChangeExtIdpConnectionStateRequest) (*string, error) {
func (c *Client) ChangeExtIdpConnectionState(extIdpConnectionId string, request *model.ChangeExtIdpConnectionStateRequest) (bool, error) {

data, _ := jsoniter.Marshal(request)
variables := make(map[string]interface{})
Expand All @@ -444,7 +443,7 @@ func (c *Client) ChangeExtIdpConnectionState(extIdpConnectionId string, request
b, err := c.SendHttpRestRequest(url, http.MethodPut, variables)

if err != nil {
return nil, err
return false, err
}

resp := &struct {
Expand All @@ -454,14 +453,14 @@ func (c *Client) ChangeExtIdpConnectionState(extIdpConnectionId string, request

jsoniter.Unmarshal(b, &resp)
if resp.Code != 200 {
return nil, errors.New(resp.Message)
return false, errors.New(resp.Message)
}
return &resp.Message, nil
return true, nil
}

// BatchChangeExtIdpConnectionState
// 批量开关身份源连接
func (c *Client) BatchChangeExtIdpConnectionState(extIdpId string, request *model.ChangeExtIdpConnectionStateRequest) (*string, error) {
func (c *Client) BatchChangeExtIdpConnectionState(extIdpId string, request *model.ChangeExtIdpConnectionStateRequest) (bool, error) {

data, _ := jsoniter.Marshal(request)
variables := make(map[string]interface{})
Expand All @@ -471,7 +470,7 @@ func (c *Client) BatchChangeExtIdpConnectionState(extIdpId string, request *mode
b, err := c.SendHttpRestRequest(url, http.MethodPut, variables)

if err != nil {
return nil, err
return false, err
}

resp := &struct {
Expand All @@ -481,7 +480,7 @@ func (c *Client) BatchChangeExtIdpConnectionState(extIdpId string, request *mode

jsoniter.Unmarshal(b, &resp)
if resp.Code != 200 {
return nil, errors.New(resp.Message)
return false, errors.New(resp.Message)
}
return &resp.Message, nil
return true, nil
}
6 changes: 3 additions & 3 deletions lib/model/tenant_model.go
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ type ExtIdpConnection struct {
DisplayName string `json:"displayName"`
Fields interface{} `json:"fields"`
Logo string `json:"logo,omitempty"`
UserMatchFields interface{} `json:"userMatchFields,omitempty"`
UserMatchFields []string `json:"userMatchFields,omitempty"`
}

type ExtIdpConnectionDetails struct {
Expand All @@ -222,14 +222,14 @@ type CreateExtIdpConnectionRequest struct {
DisplayName string `json:"displayName"`
Fields interface{} `json:"fields"`
Logo string `json:"logo,omitempty"`
UserMatchFields interface{} `json:"userMatchFields,omitempty"`
UserMatchFields []string `json:"userMatchFields,omitempty"`
}

type UpdateExtIdpConnectionRequest struct {
DisplayName string `json:"displayName"`
Fields interface{} `json:"fields"`
Logo string `json:"logo,omitempty"`
UserMatchFields interface{} `json:"userMatchFields,omitempty"`
UserMatchFields []string `json:"userMatchFields,omitempty"`
}

type ChangeExtIdpConnectionStateRequest struct {
Expand Down

0 comments on commit 4443d07

Please sign in to comment.