Skip to content

Commit

Permalink
Merge pull request #279 from actiontech/feat-overview-of-global-DBSer…
Browse files Browse the repository at this point in the history
…vices-ce

Feat overview of global db services ce
  • Loading branch information
ColdWaterLW authored Jul 17, 2024
2 parents ac6a110 + 5936dcb commit 4a5fbad
Show file tree
Hide file tree
Showing 9 changed files with 195 additions and 54 deletions.
44 changes: 40 additions & 4 deletions api/dms/service/v1/db_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -344,12 +344,12 @@ type ListGlobalDBServicesReq struct {
// the db service project id
// in:query
FilterByProjectUid string `query:"filter_by_project_uid" json:"filter_by_project_uid"`
// is masking
// in:query
FilterByIsEnableMasking *bool `query:"filter_by_is_enable_masking" json:"filter_by_is_enable_masking"`
// the db service fuzzy keyword
// in:query
FuzzyKeyword string `query:"fuzzy_keyword" json:"fuzzy_keyword"`
// is masking
// in:query
IsEnableMasking *bool `query:"is_enable_masking" json:"is_enable_masking"`
}

// swagger:model ListGlobalDBServicesReply
Expand All @@ -363,9 +363,45 @@ type ListGlobalDBServicesReply struct {
}

type ListGlobalDBService struct {
dmsCommonV1.ListDBService
// db service uid
DBServiceUid string `json:"uid"`
// db service name
Name string `json:"name"`
// db service DB type
DBType string `json:"db_type"`
// db service host
Host string `json:"host"`
// db service port
Port string `json:"port"`
// the db service business name
Business string `json:"business"`
// DB Service maintenance time
MaintenanceTimes []*dmsCommonV1.MaintenanceTime `json:"maintenance_times"`
// DB desc
Desc string `json:"desc"`
// DB source
Source string `json:"source"`
// DB project uid
ProjectUID string `json:"project_uid"`
// db service project_name
ProjectName string `json:"project_name"`
// is enable audit
IsEnableAudit bool `json:"is_enable_audit"`
// is enable masking
IsEnableMasking bool `json:"is_enable_masking"`
// db service unfinished workflow num
UnfinishedWorkflowNum int64 `json:"unfinished_workflow_num"`
}

// swagger:model ListGlobalDBServicesTipsReply
type ListGlobalDBServicesTipsReply struct {
// List global db service tips reply
Data *ListGlobalDBServiceTips `json:"data"`

// Generic reply
base.GenericResp
}

type ListGlobalDBServiceTips struct {
DBType []string `json:"db_type"`
}
96 changes: 68 additions & 28 deletions api/swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -788,19 +788,19 @@
"name": "filter_by_project_uid",
"in": "query"
},
{
"type": "boolean",
"x-go-name": "FilterByIsEnableMasking",
"description": "is masking",
"name": "filter_by_is_enable_masking",
"in": "query"
},
{
"type": "string",
"x-go-name": "FuzzyKeyword",
"description": "the db service fuzzy keyword",
"name": "fuzzy_keyword",
"in": "query"
},
{
"type": "boolean",
"x-go-name": "IsEnableMasking",
"description": "is masking",
"name": "is_enable_masking",
"in": "query"
}
],
"responses": {
Expand Down Expand Up @@ -842,6 +842,29 @@
}
}
},
"/v1/dms/db_services/tips": {
"get": {
"description": "list global DBServices tips",
"tags": [
"DBService"
],
"operationId": "ListGlobalDBServicesTips",
"responses": {
"200": {
"description": "ListGlobalDBServicesTipsReply",
"schema": {
"$ref": "#/definitions/ListGlobalDBServicesTipsReply"
}
},
"default": {
"description": "GenericResp",
"schema": {
"$ref": "#/definitions/GenericResp"
}
}
}
}
},
"/v1/dms/masking/rules": {
"get": {
"tags": [
Expand Down Expand Up @@ -7611,14 +7634,6 @@
"ListGlobalDBService": {
"type": "object",
"properties": {
"additional_params": {
"description": "DB Service Custom connection parameters",
"type": "array",
"items": {
"$ref": "#/definitions/AdditionalParam"
},
"x-go-name": "AdditionalParams"
},
"business": {
"description": "the db service business name",
"type": "string",
Expand All @@ -7639,6 +7654,11 @@
"type": "string",
"x-go-name": "Host"
},
"is_enable_audit": {
"description": "is enable audit",
"type": "boolean",
"x-go-name": "IsEnableAudit"
},
"is_enable_masking": {
"description": "is enable masking",
"type": "boolean",
Expand All @@ -7657,11 +7677,6 @@
"type": "string",
"x-go-name": "Name"
},
"password": {
"description": "db service admin encrypted password",
"type": "string",
"x-go-name": "Password"
},
"port": {
"description": "db service port",
"type": "string",
Expand All @@ -7682,9 +7697,6 @@
"type": "string",
"x-go-name": "Source"
},
"sqle_config": {
"$ref": "#/definitions/SQLEConfig"
},
"uid": {
"description": "db service uid",
"type": "string",
Expand All @@ -7695,11 +7707,19 @@
"type": "integer",
"format": "int64",
"x-go-name": "UnfinishedWorkflowNum"
},
"user": {
"description": "db service admin user",
"type": "string",
"x-go-name": "User"
}
},
"x-go-package": "github.com/actiontech/dms/api/dms/service/v1"
},
"ListGlobalDBServiceTips": {
"type": "object",
"properties": {
"db_type": {
"type": "array",
"items": {
"type": "string"
},
"x-go-name": "DBType"
}
},
"x-go-package": "github.com/actiontech/dms/api/dms/service/v1"
Expand Down Expand Up @@ -7734,6 +7754,26 @@
},
"x-go-package": "github.com/actiontech/dms/api/dms/service/v1"
},
"ListGlobalDBServicesTipsReply": {
"type": "object",
"properties": {
"code": {
"description": "code",
"type": "integer",
"format": "int64",
"x-go-name": "Code"
},
"data": {
"$ref": "#/definitions/ListGlobalDBServiceTips"
},
"message": {
"description": "message",
"type": "string",
"x-go-name": "Message"
}
},
"x-go-package": "github.com/actiontech/dms/api/dms/service/v1"
},
"ListMaskingRulesData": {
"type": "object",
"properties": {
Expand Down
69 changes: 48 additions & 21 deletions api/swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2436,12 +2436,6 @@ definitions:
x-go-package: github.com/actiontech/dms/api/dms/service/v1
ListGlobalDBService:
properties:
additional_params:
description: DB Service Custom connection parameters
items:
$ref: '#/definitions/AdditionalParam'
type: array
x-go-name: AdditionalParams
business:
description: the db service business name
type: string
Expand All @@ -2458,6 +2452,10 @@ definitions:
description: db service host
type: string
x-go-name: Host
is_enable_audit:
description: is enable audit
type: boolean
x-go-name: IsEnableAudit
is_enable_masking:
description: is enable masking
type: boolean
Expand All @@ -2472,10 +2470,6 @@ definitions:
description: db service name
type: string
x-go-name: Name
password:
description: db service admin encrypted password
type: string
x-go-name: Password
port:
description: db service port
type: string
Expand All @@ -2492,8 +2486,6 @@ definitions:
description: DB source
type: string
x-go-name: Source
sqle_config:
$ref: '#/definitions/SQLEConfig'
uid:
description: db service uid
type: string
Expand All @@ -2503,10 +2495,15 @@ definitions:
format: int64
type: integer
x-go-name: UnfinishedWorkflowNum
user:
description: db service admin user
type: string
x-go-name: User
type: object
x-go-package: github.com/actiontech/dms/api/dms/service/v1
ListGlobalDBServiceTips:
properties:
db_type:
items:
type: string
type: array
x-go-name: DBType
type: object
x-go-package: github.com/actiontech/dms/api/dms/service/v1
ListGlobalDBServicesReply:
Expand All @@ -2532,6 +2529,21 @@ definitions:
x-go-name: Total
type: object
x-go-package: github.com/actiontech/dms/api/dms/service/v1
ListGlobalDBServicesTipsReply:
properties:
code:
description: code
format: int64
type: integer
x-go-name: Code
data:
$ref: '#/definitions/ListGlobalDBServiceTips'
message:
description: message
type: string
x-go-name: Message
type: object
x-go-package: github.com/actiontech/dms/api/dms/service/v1
ListMaskingRulesData:
properties:
description:
Expand Down Expand Up @@ -4987,16 +4999,16 @@ paths:
name: filter_by_project_uid
type: string
x-go-name: FilterByProjectUid
- description: is masking
in: query
name: filter_by_is_enable_masking
type: boolean
x-go-name: FilterByIsEnableMasking
- description: the db service fuzzy keyword
in: query
name: fuzzy_keyword
type: string
x-go-name: FuzzyKeyword
- description: is masking
in: query
name: is_enable_masking
type: boolean
x-go-name: IsEnableMasking
responses:
"200":
description: ListGlobalDBServicesReply
Expand All @@ -5023,6 +5035,21 @@ paths:
summary: List db service driver option.
tags:
- DBService
/v1/dms/db_services/tips:
get:
description: list global DBServices tips
operationId: ListGlobalDBServicesTips
responses:
"200":
description: ListGlobalDBServicesTipsReply
schema:
$ref: '#/definitions/ListGlobalDBServicesTipsReply'
default:
description: GenericResp
schema:
$ref: '#/definitions/GenericResp'
tags:
- DBService
/v1/dms/masking/rules:
get:
operationId: ListMaskingRules
Expand Down
19 changes: 19 additions & 0 deletions internal/apiserver/service/dms_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,25 @@ func (d *DMSController) ListGlobalDBServices(c echo.Context) error {
return NewOkRespWithReply(c, reply)
}

// swagger:route GET /v1/dms/db_services/tips DBService ListGlobalDBServicesTips
//
// list global DBServices tips
//
// responses:
// 200: body:ListGlobalDBServicesTipsReply
// default: body:GenericResp
func (d *DMSController) ListGlobalDBServicesTips(c echo.Context) error {
currentUserUid, err := jwt.GetUserUidStrFromContext(c)
if err != nil {
return NewErrResp(c, err, apiError.DMSServiceErr)
}
reply, err := d.DMS.ListGlobalDBServicesTips(c.Request().Context(), currentUserUid)
if nil != err {
return NewErrResp(c, err, apiError.DMSServiceErr)
}
return NewOkRespWithReply(c, reply)
}

// swagger:route DELETE /v1/dms/projects/{project_uid}/db_services/{db_service_uid} DBService DelDBService
//
// Delete a DB Service.
Expand Down
1 change: 1 addition & 0 deletions internal/apiserver/service/router.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ func (s *APIServer) initRouter() error {
v1.POST("/dms/personalization", s.DMSController.Personalization)
v1.GET("/dms/db_services/driver_options", s.DMSController.ListDBServiceDriverOption)
v1.GET("/dms/db_services", s.DMSController.ListGlobalDBServices)
v1.GET("/dms/db_services/tips", s.DMSController.ListGlobalDBServicesTips)

dmsProxyV1 := v1.Group(dmsV1.ProxyRouterGroup)
dmsProxyV1.POST("", s.DMSController.RegisterDMSProxyTarget)
Expand Down
1 change: 1 addition & 0 deletions internal/dms/biz/db_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ type DBServiceRepo interface {
UpdateDBService(ctx context.Context, dbService *DBService) error
CountDBService(ctx context.Context) ([]DBTypeCount, error)
GetBusinessByProjectUID(ctx context.Context, projectUid string) ([]string, error)
GetFieldDistinctValue(ctx context.Context, field DBServiceField, results interface{}) error
}

type DBServiceUsecase struct {
Expand Down
Loading

0 comments on commit 4a5fbad

Please sign in to comment.