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

Method PageWebsite

agent/app/service/website.go:163–251  ·  view source on GitHub ↗
(req request.WebsiteSearch)

Source from the content-addressed store, hash-verified

161}
162
163func (w WebsiteService) PageWebsite(req request.WebsiteSearch) (int64, []response.WebsiteRes, error) {
164 var (
165 websiteDTOs []response.WebsiteRes
166 opts []repo.DBOption
167 )
168 opts = append(opts, repo.WithOrderRuleBy(req.OrderBy, req.Order), repo.WithOrderRuleBy("updated_at", "descending"))
169 if req.Name != "" {
170 domains, _ := websiteDomainRepo.GetBy(websiteDomainRepo.WithDomainLike(req.Name))
171 if len(domains) > 0 {
172 var websiteIds []uint
173 for _, domain := range domains {
174 websiteIds = append(websiteIds, domain.WebsiteID)
175 }
176 opts = append(opts, repo.WithByIDs(websiteIds))
177 } else {
178 opts = append(opts, websiteRepo.WithDomainLike(req.Name))
179 }
180 }
181 if req.WebsiteGroupID != 0 {
182 opts = append(opts, websiteRepo.WithGroupID(req.WebsiteGroupID))
183 }
184 if req.Type != "" {
185 opts = append(opts, websiteRepo.WithType(req.Type))
186 }
187 total, websites, err := websiteRepo.Page(req.Page, req.PageSize, opts...)
188 if err != nil {
189 return 0, nil, err
190 }
191 for _, web := range websites {
192 var (
193 appName string
194 runtimeName string
195 runtimeType string
196 appInstallID uint
197 )
198 switch web.Type {
199 case constant.Deployment:
200 appInstall, err := appInstallRepo.GetFirst(repo.WithByID(web.AppInstallID))
201 if err == nil {
202 appName = appInstall.Name
203 appInstallID = appInstall.ID
204 }
205 case constant.Runtime:
206 runtime, _ := runtimeRepo.GetFirst(context.Background(), repo.WithByID(web.RuntimeID))
207 if runtime != nil {
208 runtimeName = runtime.Name
209 runtimeType = runtime.Type
210 }
211 }
212 sitePath := GetSitePath(web, SiteDir)
213
214 siteDTO := response.WebsiteRes{
215 ID: web.ID,
216 CreatedAt: web.CreatedAt,
217 Protocol: web.Protocol,
218 PrimaryDomain: web.PrimaryDomain,
219 Type: web.Type,
220 Remark: web.Remark,

Callers

nothing calls this directly

Calls 11

GetSitePathFunction · 0.85
checkSSLStatusFunction · 0.85
GetByMethod · 0.65
WithDomainLikeMethod · 0.65
WithGroupIDMethod · 0.65
WithTypeMethod · 0.65
PageMethod · 0.65
GetFirstMethod · 0.65
WithByIDMethod · 0.65
ListMethod · 0.65
WithParentIDMethod · 0.65

Tested by

no test coverage detected