package service import ( "github.com/1Panel-dev/1Panel/backend/app/dto/request" "github.com/1Panel-dev/1Panel/backend/app/dto/response" "github.com/1Panel-dev/1Panel/backend/app/repo" ) type RuntimeService struct { } type IRuntimeService interface { Page(req request.RuntimeSearch) (int64, []response.RuntimeRes, error) } func NewRuntimeService() IRuntimeService { return &RuntimeService{} } func (r *RuntimeService) Create() { } func (r *RuntimeService) Page(req request.RuntimeSearch) (int64, []response.RuntimeRes, error) { var ( opts []repo.DBOption res []response.RuntimeRes ) if req.Name != "" { opts = append(opts, commonRepo.WithLikeName(req.Name)) } total, runtimes, err := runtimeRepo.Page(req.Page, req.PageSize, opts...) if err != nil { return 0, nil, err } for _, runtime := range runtimes { res = append(res, response.RuntimeRes{ Runtime: runtime, }) } return total, res, nil }