(req dto.MongodbDBDeleteCheck)
| 224 | } |
| 225 | |
| 226 | func (u *MongodbService) DeleteCheck(req dto.MongodbDBDeleteCheck) ([]dto.DBResource, error) { |
| 227 | var res []dto.DBResource |
| 228 | db, err := mongodbRepo.Get(repo.WithByID(req.ID)) |
| 229 | if err != nil { |
| 230 | return res, err |
| 231 | } |
| 232 | |
| 233 | if db.From == "local" { |
| 234 | app, err := appInstallRepo.LoadBaseInfo(req.Type, req.Database) |
| 235 | if err != nil { |
| 236 | return res, err |
| 237 | } |
| 238 | apps, _ := appInstallResourceRepo.GetBy(appInstallResourceRepo.WithLinkId(app.ID), appInstallResourceRepo.WithResourceId(db.ID)) |
| 239 | for _, app := range apps { |
| 240 | appInstall, _ := appInstallRepo.GetFirst(repo.WithByID(app.AppInstallId)) |
| 241 | if appInstall.ID != 0 { |
| 242 | res = append(res, dto.DBResource{ |
| 243 | Type: constant.TypeApp, |
| 244 | Name: appInstall.Name, |
| 245 | }) |
| 246 | } |
| 247 | } |
| 248 | } else { |
| 249 | apps, _ := appInstallResourceRepo.GetBy(appInstallResourceRepo.WithResourceId(db.ID), appRepo.WithKey(req.Type)) |
| 250 | for _, app := range apps { |
| 251 | appInstall, _ := appInstallRepo.GetFirst(repo.WithByID(app.AppInstallId)) |
| 252 | if appInstall.ID != 0 { |
| 253 | res = append(res, dto.DBResource{ |
| 254 | Type: constant.TypeApp, |
| 255 | Name: appInstall.Name, |
| 256 | }) |
| 257 | } |
| 258 | } |
| 259 | } |
| 260 | |
| 261 | return res, nil |
| 262 | } |
| 263 | |
| 264 | func (u *MongodbService) LoadPrivileges(req dto.MongodbPrivilegesLoad) (string, error) { |
| 265 | dbItem, err := mongodbRepo.Get(mongodbRepo.WithByMongodbName(req.Database), repo.WithByName(req.Name)) |
nothing calls this directly
no test coverage detected