Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 18 additions & 12 deletions sqle/api/controller/v2/instance.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,17 +31,20 @@ type RuleTemplateV2 struct {
}

type InstanceResV2 struct {
Name string `json:"instance_name"`
DBType string `json:"db_type" example:"mysql"`
Host string `json:"db_host" example:"10.10.10.10"`
Port string `json:"db_port" example:"3306"`
User string `json:"db_user" example:"root"`
Desc string `json:"desc" example:"this is a instance"`
MaintenanceTimes []*v1.MaintenanceTimeResV1 `json:"maintenance_times" from:"maintenance_times"`
RuleTemplate *RuleTemplateV2 `json:"rule_template,omitempty"`
AdditionalParams []*v1.InstanceAdditionalParamResV1 `json:"additional_params"`
SQLQueryConfig *v1.SQLQueryConfigResV1 `json:"sql_query_config"`
Source string `json:"source" example:"SQLE"`
Name string `json:"instance_name"`
DBType string `json:"db_type" example:"mysql"`
Host string `json:"db_host" example:"10.10.10.10"`
Port string `json:"db_port" example:"3306"`
User string `json:"db_user" example:"root"`
Desc string `json:"desc" example:"this is a instance"`
MaintenanceTimes []*v1.MaintenanceTimeResV1 `json:"maintenance_times" from:"maintenance_times"`
RuleTemplate *RuleTemplateV2 `json:"rule_template,omitempty"`
AdditionalParams []*v1.InstanceAdditionalParamResV1 `json:"additional_params"`
SQLQueryConfig *v1.SQLQueryConfigResV1 `json:"sql_query_config"`
Source string `json:"source" example:"SQLE"`
EnvironmentTagName string `json:"environment_tag_name"`
EnvironmentTagUID string `json:"environment_tag_uid"`
EnvironmentTagColor string `json:"environment_tag_color,omitempty"`
}

type GetInstanceResV2 struct {
Expand Down Expand Up @@ -99,7 +102,10 @@ func convertInstanceToRes(ctx context.Context, instance *model.Instance) Instanc
AuditEnabled: instance.SqlQueryConfig.AuditEnabled,
AllowQueryWhenLessThanAuditLevel: instance.SqlQueryConfig.AllowQueryWhenLessThanAuditLevel,
},
Source: instance.Source,
Source: instance.Source,
EnvironmentTagName: instance.EnvironmentTagName,
EnvironmentTagUID: instance.EnvironmentTagUID,
EnvironmentTagColor: instance.EnvironmentTagColor,
}

if len(instance.RuleTemplates) != 0 {
Expand Down
2 changes: 2 additions & 0 deletions sqle/api/controller/v2/instance_audit_plan.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ type InstanceTipResV2 struct {
BackupMaxRows uint64 `json:"backup_max_rows"`
EnvironmentTagName string `json:"environment_tag_name"`
EnvironmentTagUID string `json:"environment_tag_uid"`
EnvironmentTagColor string `json:"environment_tag_color,omitempty"`
}

// GetInstanceTips get instance tip list
Expand Down Expand Up @@ -132,6 +133,7 @@ func GetInstanceTips(c echo.Context) error {
SupportedBackupStrategy: svc.SupportedBackupStrategy(inst.DbType),
EnvironmentTagName: inst.EnvironmentTagName,
EnvironmentTagUID: inst.EnvironmentTagUID,
EnvironmentTagColor: inst.EnvironmentTagColor,
}
instanceTipsResV1 = append(instanceTipsResV1, instanceTipRes)
}
Expand Down
40 changes: 21 additions & 19 deletions sqle/dms/instance.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,34 +128,36 @@ func convertInstance(instance *dmsV2.ListDBService) (*model.Instance, error) {
AllowQueryWhenLessThanAuditLevel: string(instance.SQLEConfig.SQLQueryConfig.AllowQueryWhenLessThanAuditLevel),
}
}
var environmentTagName, environmentTagUID string
var environmentTagName, environmentTagUID, environmentTagColor string
if instance.EnvironmentTag != nil {
environmentTagUID = instance.EnvironmentTag.UID
environmentTagName = instance.EnvironmentTag.Name
environmentTagColor = instance.EnvironmentTag.Color
}
var ruleTemplateName string
if instance.SQLEConfig != nil {
ruleTemplateName = instance.SQLEConfig.RuleTemplateName
}
return &model.Instance{
ID: uint64(instanceId),
Name: instance.Name,
DbType: instance.DBType,
RuleTemplateId: uint64(ruleTemplateId),
RuleTemplateName: ruleTemplateName,
ProjectId: instance.ProjectUID,
MaintenancePeriod: maintenancePeriod,
Host: instance.Host,
Port: instance.Port,
User: instance.User,
Password: decryptPassword,
Desc: instance.Desc,
AdditionalParams: additionalParams,
SqlQueryConfig: sqlQueryConfig,
EnvironmentTagName: environmentTagName,
EnvironmentTagUID: environmentTagUID,
EnableBackup: instance.EnableBackup,
BackupMaxRows: instance.BackupMaxRows,
ID: uint64(instanceId),
Name: instance.Name,
DbType: instance.DBType,
RuleTemplateId: uint64(ruleTemplateId),
RuleTemplateName: ruleTemplateName,
ProjectId: instance.ProjectUID,
MaintenancePeriod: maintenancePeriod,
Host: instance.Host,
Port: instance.Port,
User: instance.User,
Password: decryptPassword,
Desc: instance.Desc,
AdditionalParams: additionalParams,
SqlQueryConfig: sqlQueryConfig,
EnvironmentTagName: environmentTagName,
EnvironmentTagUID: environmentTagUID,
EnvironmentTagColor: environmentTagColor,
EnableBackup: instance.EnableBackup,
BackupMaxRows: instance.BackupMaxRows,
}, nil
}

Expand Down
19 changes: 19 additions & 0 deletions sqle/docs/docs.go
Original file line number Diff line number Diff line change
Expand Up @@ -13983,6 +13983,10 @@ var doc = `{
"dashboard.GlobalWorkflowListItem": {
"type": "object",
"properties": {
"assignee": {
"description": "当前处理人姓名",
"type": "string"
},
"create_user_name": {
"type": "string"
},
Expand Down Expand Up @@ -16345,6 +16349,9 @@ var doc = `{
"db_type": {
"type": "string"
},
"default_port": {
"type": "integer"
},
"params": {
"type": "array",
"items": {
Expand Down Expand Up @@ -24592,6 +24599,15 @@ var doc = `{
"type": "string",
"example": "this is a instance"
},
"environment_tag_color": {
"type": "string"
},
"environment_tag_name": {
"type": "string"
},
"environment_tag_uid": {
"type": "string"
},
"instance_name": {
"type": "string"
},
Expand Down Expand Up @@ -24624,6 +24640,9 @@ var doc = `{
"enable_backup": {
"type": "boolean"
},
"environment_tag_color": {
"type": "string"
},
"environment_tag_name": {
"type": "string"
},
Expand Down
19 changes: 19 additions & 0 deletions sqle/docs/swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -13967,6 +13967,10 @@
"dashboard.GlobalWorkflowListItem": {
"type": "object",
"properties": {
"assignee": {
"description": "当前处理人姓名",
"type": "string"
},
"create_user_name": {
"type": "string"
},
Expand Down Expand Up @@ -16329,6 +16333,9 @@
"db_type": {
"type": "string"
},
"default_port": {
"type": "integer"
},
"params": {
"type": "array",
"items": {
Expand Down Expand Up @@ -24576,6 +24583,15 @@
"type": "string",
"example": "this is a instance"
},
"environment_tag_color": {
"type": "string"
},
"environment_tag_name": {
"type": "string"
},
"environment_tag_uid": {
"type": "string"
},
"instance_name": {
"type": "string"
},
Expand Down Expand Up @@ -24608,6 +24624,9 @@
"enable_backup": {
"type": "boolean"
},
"environment_tag_color": {
"type": "string"
},
"environment_tag_name": {
"type": "string"
},
Expand Down
13 changes: 13 additions & 0 deletions sqle/docs/swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,9 @@ definitions:
type: object
dashboard.GlobalWorkflowListItem:
properties:
assignee:
description: 当前处理人姓名
type: string
create_user_name:
type: string
created_at:
Expand Down Expand Up @@ -1809,6 +1812,8 @@ definitions:
properties:
db_type:
type: string
default_port:
type: integer
params:
items:
$ref: '#/definitions/v1.InstanceAdditionalParamResV1'
Expand Down Expand Up @@ -7482,6 +7487,12 @@ definitions:
desc:
example: this is a instance
type: string
environment_tag_color:
type: string
environment_tag_name:
type: string
environment_tag_uid:
type: string
instance_name:
type: string
maintenance_times:
Expand All @@ -7504,6 +7515,8 @@ definitions:
type: integer
enable_backup:
type: boolean
environment_tag_color:
type: string
environment_tag_name:
type: string
environment_tag_uid:
Expand Down
5 changes: 3 additions & 2 deletions sqle/model/instance.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,9 @@ type Instance struct {
Source string `json:"source" gorm:"not null"`
SyncInstanceTaskID uint `json:"sync_instance_task_id"`

EnvironmentTagName string `json:"environment_tag_name"`
EnvironmentTagUID string `json:"environment_tag_uid"`
EnvironmentTagName string `json:"environment_tag_name"`
EnvironmentTagUID string `json:"environment_tag_uid"`
EnvironmentTagColor string `json:"environment_tag_color"`

EnableBackup bool `json:"enable_backup"`
BackupMaxRows uint64 `json:"backup_max_rows"`
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading