38 lines
975 B
Go
38 lines
975 B
Go
|
|
package job
|
||
|
|
|
||
|
|
import (
|
||
|
|
"context"
|
||
|
|
|
||
|
|
"haixun-backend/internal/svc"
|
||
|
|
"haixun-backend/internal/types"
|
||
|
|
)
|
||
|
|
|
||
|
|
type ListJobSchedulesLogic struct {
|
||
|
|
ctx context.Context
|
||
|
|
svcCtx *svc.ServiceContext
|
||
|
|
}
|
||
|
|
|
||
|
|
func NewListJobSchedulesLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ListJobSchedulesLogic {
|
||
|
|
return &ListJobSchedulesLogic{ctx: ctx, svcCtx: svcCtx}
|
||
|
|
}
|
||
|
|
|
||
|
|
func (l *ListJobSchedulesLogic) ListJobSchedules(req *types.ListJobSchedulesReq) (*types.JobScheduleListData, error) {
|
||
|
|
items, total, page, pageSize, totalPages, err := l.svcCtx.Job.ListSchedules(l.ctx, req.Scope, req.ScopeID, req.Page, req.PageSize)
|
||
|
|
if err != nil {
|
||
|
|
return nil, err
|
||
|
|
}
|
||
|
|
list := make([]types.JobScheduleData, 0, len(items))
|
||
|
|
for _, item := range items {
|
||
|
|
list = append(list, toJobScheduleData(item))
|
||
|
|
}
|
||
|
|
return &types.JobScheduleListData{
|
||
|
|
Pagination: types.PaginationData{
|
||
|
|
Total: total,
|
||
|
|
Page: page,
|
||
|
|
PageSize: pageSize,
|
||
|
|
TotalPages: totalPages,
|
||
|
|
},
|
||
|
|
List: list,
|
||
|
|
}, nil
|
||
|
|
}
|