(req request.AppInstalledSearch)
| 198 | } |
| 199 | |
| 200 | func (a *AppInstallService) SearchForWebsite(req request.AppInstalledSearch) ([]response.AppInstallDTO, error) { |
| 201 | var ( |
| 202 | installs []model.AppInstall |
| 203 | err error |
| 204 | opts []repo.DBOption |
| 205 | ) |
| 206 | if req.Type != "" { |
| 207 | if req.Type == "proxy" { |
| 208 | phpApps, _ := appRepo.GetBy(appRepo.WithType("php")) |
| 209 | var ids []uint |
| 210 | for _, app := range phpApps { |
| 211 | ids = append(ids, app.ID) |
| 212 | } |
| 213 | runtimeApps, _ := appRepo.GetBy(appRepo.WithType("runtime")) |
| 214 | for _, app := range runtimeApps { |
| 215 | ids = append(ids, app.ID) |
| 216 | } |
| 217 | opts = append(opts, appInstallRepo.WithAppIdsNotIn(ids)) |
| 218 | } else { |
| 219 | apps, err := appRepo.GetBy(appRepo.WithType(req.Type)) |
| 220 | if err != nil { |
| 221 | return nil, err |
| 222 | } |
| 223 | var ids []uint |
| 224 | for _, app := range apps { |
| 225 | ids = append(ids, app.ID) |
| 226 | } |
| 227 | if req.Unused { |
| 228 | opts = append(opts, appInstallRepo.WithIdNotInWebsite()) |
| 229 | } |
| 230 | opts = append(opts, appInstallRepo.WithAppIdsIn(ids)) |
| 231 | } |
| 232 | installs, err = appInstallRepo.ListBy(context.Background(), opts...) |
| 233 | if err != nil { |
| 234 | return nil, err |
| 235 | } |
| 236 | } else { |
| 237 | installs, err = appInstallRepo.ListBy(context.Background()) |
| 238 | if err != nil { |
| 239 | return nil, err |
| 240 | } |
| 241 | } |
| 242 | |
| 243 | return handleInstalled(installs, false, true, false) |
| 244 | } |
| 245 | |
| 246 | func (a *AppInstallService) Operate(req request.AppInstalledOperate) error { |
| 247 | install, err := appInstallRepo.GetFirstByCtx(context.Background(), repo.WithByID(req.InstallId)) |
nothing calls this directly
no test coverage detected