提交 v1.3.0 beta
This commit is contained in:
@ -7,6 +7,8 @@ import (
|
||||
"next-terminal/server/model"
|
||||
)
|
||||
|
||||
var JobLogRepository = new(jobLogRepository)
|
||||
|
||||
type jobLogRepository struct {
|
||||
baseRepository
|
||||
}
|
||||
@ -15,8 +17,16 @@ func (r jobLogRepository) Create(c context.Context, o *model.JobLog) error {
|
||||
return r.GetDB(c).Create(o).Error
|
||||
}
|
||||
|
||||
func (r jobLogRepository) FindByJobId(c context.Context, jobId string) (o []model.JobLog, err error) {
|
||||
err = r.GetDB(c).Where("job_id = ?", jobId).Order("timestamp asc").Find(&o).Error
|
||||
func (r jobLogRepository) FindByJobId(c context.Context, jobId string, pageIndex, pageSize int) (o []model.JobLog, total int64, err error) {
|
||||
|
||||
err = r.GetDB(c).Table("job_logs").Where("job_id = ?", jobId).Count(&total).Error
|
||||
if err != nil {
|
||||
return nil, 0, err
|
||||
}
|
||||
err = r.GetDB(c).Where("job_id = ?", jobId).Order("timestamp desc").Find(&o).Offset((pageIndex - 1) * pageSize).Limit(pageSize).Error
|
||||
if o == nil {
|
||||
o = make([]model.JobLog, 0)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user