mirror of https://github.com/1Panel-dev/1Panel
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
43 lines
930 B
43 lines
930 B
2 years ago
|
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
|
||
|
}
|