(ctx *gin.Context, req request.AppSearch)
| 67 | } |
| 68 | |
| 69 | func (a AppService) PageApp(ctx *gin.Context, req request.AppSearch) (*response.AppRes, error) { |
| 70 | var opts []repo.DBOption |
| 71 | opts = append(opts, appRepo.OrderByRecommend()) |
| 72 | if req.Name != "" { |
| 73 | opts = append(opts, appRepo.WithByLikeName(strings.TrimSpace(req.Name))) |
| 74 | } |
| 75 | if req.Type != "" { |
| 76 | opts = append(opts, appRepo.WithType(req.Type)) |
| 77 | } |
| 78 | if req.Recommend { |
| 79 | opts = append(opts, appRepo.GetRecommend()) |
| 80 | } |
| 81 | if req.Resource != "" && req.Resource != "all" { |
| 82 | opts = append(opts, appRepo.WithResource(req.Resource)) |
| 83 | } |
| 84 | |
| 85 | if req.ShowCurrentArch { |
| 86 | info, err := NewIDashboardService().LoadOsInfo() |
| 87 | if err != nil { |
| 88 | return nil, err |
| 89 | } |
| 90 | kernelArch := info.KernelArch |
| 91 | if kernelArch == "aarch64" { |
| 92 | kernelArch = "arm64" |
| 93 | } |
| 94 | opts = append(opts, appRepo.WithArch(kernelArch)) |
| 95 | } |
| 96 | if len(req.Tags) != 0 { |
| 97 | tags, err := tagRepo.GetByKeys(req.Tags) |
| 98 | if err != nil { |
| 99 | return nil, err |
| 100 | } |
| 101 | var tagIds []uint |
| 102 | for _, t := range tags { |
| 103 | tagIds = append(tagIds, t.ID) |
| 104 | } |
| 105 | appTags, err := appTagRepo.GetByTagIds(tagIds) |
| 106 | if err != nil { |
| 107 | return nil, err |
| 108 | } |
| 109 | var appIds []uint |
| 110 | for _, t := range appTags { |
| 111 | appIds = append(appIds, t.AppId) |
| 112 | } |
| 113 | opts = append(opts, repo.WithByIDs(appIds)) |
| 114 | } |
| 115 | res := &response.AppRes{} |
| 116 | |
| 117 | total, apps, err := appRepo.Page(req.Page, req.PageSize, opts...) |
| 118 | if err != nil { |
| 119 | return nil, err |
| 120 | } |
| 121 | appDTOs := make([]*response.AppItem, 0) |
| 122 | info := &dto.SettingInfo{} |
| 123 | if req.Type == "php" { |
| 124 | info, _ = NewISettingService().GetSettingInfo() |
| 125 | } |
| 126 | lang := strings.ToLower(common.GetLang(ctx)) |
nothing calls this directly
no test coverage detected