MCPcopy Create free account
hub / github.com/1Panel-dev/1Panel / DeleteCheck

Method DeleteCheck

agent/app/service/database_postgresql.go:251–302  ·  view source on GitHub ↗
(req dto.PostgresqlDBDeleteCheck)

Source from the content-addressed store, hash-verified

249}
250
251func (u *PostgresqlService) DeleteCheck(req dto.PostgresqlDBDeleteCheck) ([]dto.DBResource, error) {
252 var res []dto.DBResource
253 db, err := postgresqlRepo.Get(repo.WithByID(req.ID))
254 if err != nil {
255 return res, err
256 }
257
258 website, _ := websiteRepo.GetFirst(websiteRepo.WithDBType(constant.AppPostgresql), websiteRepo.WithDBID(req.ID))
259 if website.ID != 0 {
260 res = append(res, dto.DBResource{
261 Type: constant.TypeWebsite,
262 Name: website.PrimaryDomain,
263 })
264 }
265 website, _ = websiteRepo.GetFirst(websiteRepo.WithDBType(constant.AppPostgresqlCluster), websiteRepo.WithDBID(req.ID))
266 if website.ID != 0 {
267 res = append(res, dto.DBResource{
268 Type: constant.TypeWebsite,
269 Name: website.PrimaryDomain,
270 })
271 }
272
273 if db.From == "local" {
274 app, err := appInstallRepo.LoadBaseInfo(req.Type, req.Database)
275 if err != nil {
276 return res, err
277 }
278 apps, _ := appInstallResourceRepo.GetBy(appInstallResourceRepo.WithLinkId(app.ID), appInstallResourceRepo.WithResourceId(db.ID))
279 for _, app := range apps {
280 appInstall, _ := appInstallRepo.GetFirst(repo.WithByID(app.AppInstallId))
281 if appInstall.ID != 0 {
282 res = append(res, dto.DBResource{
283 Type: constant.TypeApp,
284 Name: appInstall.Name,
285 })
286 }
287 }
288 } else {
289 apps, _ := appInstallResourceRepo.GetBy(appInstallResourceRepo.WithResourceId(db.ID), appRepo.WithKey(req.Type))
290 for _, app := range apps {
291 appInstall, _ := appInstallRepo.GetFirst(repo.WithByID(app.AppInstallId))
292 if appInstall.ID != 0 {
293 res = append(res, dto.DBResource{
294 Type: constant.TypeApp,
295 Name: appInstall.Name,
296 })
297 }
298 }
299 }
300
301 return res, nil
302}
303
304func (u *PostgresqlService) Delete(ctx context.Context, req dto.PostgresqlDBDelete) error {
305 db, err := postgresqlRepo.Get(repo.WithByID(req.ID))

Callers

nothing calls this directly

Calls 10

GetMethod · 0.65
WithByIDMethod · 0.65
GetFirstMethod · 0.65
WithDBTypeMethod · 0.65
WithDBIDMethod · 0.65
LoadBaseInfoMethod · 0.65
GetByMethod · 0.65
WithLinkIdMethod · 0.65
WithResourceIdMethod · 0.65
WithKeyMethod · 0.65

Tested by

no test coverage detected