thread-master/internal/logic/job/list_job_schedules_logic.go

38 lines
975 B
Go
Raw Permalink Normal View History

2026-06-26 08:37:04 +00:00
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
}