修复 「1.2.2 用户管理-用户列表勾选单一用户会全选 」 close #216
This commit is contained in:
@ -1,45 +1,39 @@
|
||||
package repository
|
||||
|
||||
import (
|
||||
"context"
|
||||
"time"
|
||||
|
||||
"next-terminal/server/model"
|
||||
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
type JobLogRepository struct {
|
||||
DB *gorm.DB
|
||||
type jobLogRepository struct {
|
||||
baseRepository
|
||||
}
|
||||
|
||||
func NewJobLogRepository(db *gorm.DB) *JobLogRepository {
|
||||
jobLogRepository = &JobLogRepository{DB: db}
|
||||
return jobLogRepository
|
||||
func (r jobLogRepository) Create(c context.Context, o *model.JobLog) error {
|
||||
return r.GetDB(c).Create(o).Error
|
||||
}
|
||||
|
||||
func (r JobLogRepository) Create(o *model.JobLog) error {
|
||||
return r.DB.Create(o).Error
|
||||
}
|
||||
|
||||
func (r JobLogRepository) FindByJobId(jobId string) (o []model.JobLog, err error) {
|
||||
err = r.DB.Where("job_id = ?", jobId).Order("timestamp asc").Find(&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
|
||||
return
|
||||
}
|
||||
|
||||
func (r JobLogRepository) FindOutTimeLog(dayLimit int) (o []model.JobLog, err error) {
|
||||
func (r jobLogRepository) FindOutTimeLog(c context.Context, dayLimit int) (o []model.JobLog, err error) {
|
||||
limitTime := time.Now().Add(time.Duration(-dayLimit*24) * time.Hour)
|
||||
err = r.DB.Where("timestamp < ?", limitTime).Find(&o).Error
|
||||
err = r.GetDB(c).Where("timestamp < ?", limitTime).Find(&o).Error
|
||||
return
|
||||
}
|
||||
|
||||
func (r JobLogRepository) DeleteByJobId(jobId string) error {
|
||||
return r.DB.Where("job_id = ?", jobId).Delete(model.JobLog{}).Error
|
||||
func (r jobLogRepository) DeleteByJobId(c context.Context, jobId string) error {
|
||||
return r.GetDB(c).Where("job_id = ?", jobId).Delete(model.JobLog{}).Error
|
||||
}
|
||||
|
||||
func (r JobLogRepository) DeleteByIdIn(ids []string) error {
|
||||
return r.DB.Where("id in ?", ids).Delete(&model.JobLog{}).Error
|
||||
func (r jobLogRepository) DeleteByIdIn(c context.Context, ids []string) error {
|
||||
return r.GetDB(c).Where("id in ?", ids).Delete(&model.JobLog{}).Error
|
||||
}
|
||||
|
||||
func (r JobLogRepository) DeleteById(id string) error {
|
||||
return r.DB.Where("id = ?", id).Delete(&model.JobLog{}).Error
|
||||
func (r jobLogRepository) DeleteById(c context.Context, id string) error {
|
||||
return r.GetDB(c).Where("id = ?", id).Delete(&model.JobLog{}).Error
|
||||
}
|
||||
|
Reference in New Issue
Block a user