Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: add audit plan model for delete project #2770

Merged
merged 3 commits into from
Nov 22, 2024
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
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
}
Loading