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

Method DeleteCheck

agent/app/service/database_mysql.go:234–285  ·  view source on GitHub ↗
(req dto.MysqlDBDeleteCheck)

Source from the content-addressed store, hash-verified

232}
233
234func (u *MysqlService) DeleteCheck(req dto.MysqlDBDeleteCheck) ([]dto.DBResource, error) {
235 var res []dto.DBResource
236 db, err := mysqlRepo.Get(repo.WithByID(req.ID))
237 if err != nil {
238 return res, err
239 }
240
241 website, _ := websiteRepo.GetFirst(websiteRepo.WithDBType(constant.AppMysql), websiteRepo.WithDBID(req.ID))
242 if website.ID != 0 {
243 res = append(res, dto.DBResource{
244 Type: constant.TypeWebsite,
245 Name: website.PrimaryDomain,
246 })
247 }
248 website, _ = websiteRepo.GetFirst(websiteRepo.WithDBType(constant.AppMysqlCluster), websiteRepo.WithDBID(req.ID))
249 if website.ID != 0 {
250 res = append(res, dto.DBResource{
251 Type: constant.TypeWebsite,
252 Name: website.PrimaryDomain,
253 })
254 }
255
256 if db.From == "local" {
257 app, err := appInstallRepo.LoadBaseInfo(req.Type, req.Database)
258 if err != nil {
259 return res, err
260 }
261 apps, _ := appInstallResourceRepo.GetBy(appInstallResourceRepo.WithLinkId(app.ID), appInstallResourceRepo.WithResourceId(db.ID))
262 for _, app := range apps {
263 appInstall, _ := appInstallRepo.GetFirst(repo.WithByID(app.AppInstallId))
264 if appInstall.ID != 0 {
265 res = append(res, dto.DBResource{
266 Type: constant.TypeApp,
267 Name: appInstall.Name,
268 })
269 }
270 }
271 } else {
272 apps, _ := appInstallResourceRepo.GetBy(appInstallResourceRepo.WithResourceId(db.ID), appRepo.WithKey(req.Type))
273 for _, app := range apps {
274 appInstall, _ := appInstallRepo.GetFirst(repo.WithByID(app.AppInstallId))
275 if appInstall.ID != 0 {
276 res = append(res, dto.DBResource{
277 Type: constant.TypeApp,
278 Name: appInstall.Name,
279 })
280 }
281 }
282 }
283
284 return res, nil
285}
286
287func (u *MysqlService) Delete(ctx context.Context, req dto.MysqlDBDelete) error {
288 db, err := mysqlRepo.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