Skip to content

Commit

Permalink
Merge pull request #2770 from actiontech/audit_plan_add_model_for_del…
Browse files Browse the repository at this point in the history
…_project

chore: add audit plan model for delete project
  • Loading branch information
winfredLIN authored Nov 22, 2024
2 parents eb6b269 + 81f42e2 commit 5868e4c
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
7 changes: 6 additions & 1 deletion sqle/api/controller/v1/instance_audit_plan.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,13 @@ func CreateInstanceAuditPlan(c echo.Context) error {
return controller.JSONBaseErrorReq(c, err)
}

instID, err := strconv.Atoi(req.InstanceId)
if err != nil {
return controller.JSONBaseErrorReq(c, err)
}

// check instance
inst, exist, err := dms.GetInstancesById(c.Request().Context(), req.InstanceId)
inst, exist, err := dms.GetInstanceInProjectById(c.Request().Context(), projectUid, uint64(instID))
if !exist {
return controller.JSONBaseErrorReq(c, ErrInstanceNotExist)
} else if err != nil {
Expand Down
6 changes: 6 additions & 0 deletions sqle/model/instance_audit_plan.go
Original file line number Diff line number Diff line change
Expand Up @@ -531,3 +531,9 @@ func (s *Storage) UpdateAuditPlanLastCollectionTime(auditPlanID uint, collection
}
return nil
}

func (s *Storage) GetAuditPlansByProjectId(projectID string) ([]*InstanceAuditPlan, error) {
instanceAuditPlan := []*InstanceAuditPlan{}
err := s.db.Model(InstanceAuditPlan{}).Where("project_id = ?", projectID).Find(&instanceAuditPlan).Error
return instanceAuditPlan, err
}

0 comments on commit 5868e4c

Please sign in to comment.