Skip to content

Commit

Permalink
Merge pull request #325 from actiontech/1956mvp3-1
Browse files Browse the repository at this point in the history
feat: support mark instance enable backup
  • Loading branch information
ColdWaterLW authored Nov 22, 2024
2 parents a943dbc + 2d76460 commit 1feab39
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 0 deletions.
4 changes: 4 additions & 0 deletions internal/dms/biz/db_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ type DBService struct {
AuditPlanTypes []*dmsCommonV1.AuditPlanTypes `json:"audit_plan_types"`
// instance audit plan id
InstanceAuditPlanID uint `json:"instance_audit_plan_id"`
EnableBackup bool `json:"enable_backup"`
}

type DBTypeCount struct {
Expand Down Expand Up @@ -119,6 +120,7 @@ func newDBService(args *BizDBServiceArgs) (*DBService, error) {
MaintenancePeriod: args.MaintenancePeriod,
SQLEConfig: &SQLEConfig{},
IsMaskingSwitch: args.IsMaskingSwitch,
EnableBackup: args.EnableBackup,
}

if args.RuleTemplateName != "" {
Expand Down Expand Up @@ -189,6 +191,7 @@ type BizDBServiceArgs struct {
RuleTemplateID string
SQLQueryConfig *SQLQueryConfig
IsMaskingSwitch bool
EnableBackup bool
}

type SQLQueryConfig struct {
Expand Down Expand Up @@ -642,6 +645,7 @@ func (d *DBServiceUsecase) UpdateDBService(ctx context.Context, dbServiceUid str
ds.AdditionalParams = updateDBService.AdditionalParams
ds.MaintenancePeriod = updateDBService.MaintenancePeriod
ds.IsMaskingSwitch = updateDBService.IsMaskingSwitch
ds.EnableBackup = updateDBService.EnableBackup
ds.SQLEConfig = &SQLEConfig{}
// 支持新增和更新sqleConfig,不允许删除sqle配置
if updateDBService.RuleTemplateName != "" {
Expand Down
3 changes: 3 additions & 0 deletions internal/dms/service/db_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ func (d *DMSService) UpdateDBService(ctx context.Context, req *dmsV1.UpdateDBSer
User: req.DBService.User,
Password: req.DBService.Password,
Business: req.DBService.Business,
EnableBackup: req.DBService.EnableBackup,
MaintenancePeriod: d.convertMaintenanceTimeToPeriod(req.DBService.MaintenanceTimes),
AdditionalParams: additionalParams,
}
Expand Down Expand Up @@ -207,6 +208,7 @@ func (d *DMSService) AddDBService(ctx context.Context, req *dmsV1.AddDBServiceRe
ProjectUID: req.ProjectUid,
Source: string(pkgConst.DBServiceSourceNameSQLE),
AdditionalParams: additionalParams,
EnableBackup: req.DBService.EnableBackup,
}

if biz.IsDMS() {
Expand Down Expand Up @@ -508,6 +510,7 @@ func (d *DMSService) ListDBServices(ctx context.Context, req *dmsCommonV1.ListDB
IsEnableMasking: u.IsMaskingSwitch,
InstanceAuditPlanID: u.InstanceAuditPlanID,
AuditPlanTypes: u.AuditPlanTypes,
EnableBackup: u.EnableBackup,
}

if u.LastConnectionTime != nil {
Expand Down
2 changes: 2 additions & 0 deletions internal/dms/storage/convert.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ func convertBizDBService(ds *biz.DBService) (*model.DBService, error) {
MaintenancePeriod: ds.MaintenancePeriod,
ProjectUID: ds.ProjectUID,
IsEnableMasking: ds.IsMaskingSwitch,
EnableBackup: ds.EnableBackup,
}
if ds.LastConnectionStatus != nil {
dbService.LastConnectionStatus = (*string)(ds.LastConnectionStatus)
Expand Down Expand Up @@ -102,6 +103,7 @@ func convertModelDBService(ds *model.DBService) (*biz.DBService, error) {
Source: ds.Source,
ProjectUID: ds.ProjectUID,
IsMaskingSwitch: ds.IsEnableMasking,
EnableBackup: ds.EnableBackup,
}

if ds.LastConnectionStatus != nil {
Expand Down
1 change: 1 addition & 0 deletions internal/dms/storage/model/model.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ type DBService struct {
LastConnectionStatus *string `json:"last_connection_status"`
LastConnectionTime *time.Time `json:"last_connection_time"`
LastConnectionErrorMsg *string `json:"last_connection_error_msg"`
EnableBackup bool `json:"enable_backup" gorm:"column:enable_backup;type:bool"`
}

type ExtraParameters struct {
Expand Down

0 comments on commit 1feab39

Please sign in to comment.