修复 「1.2.2 用户管理-用户列表勾选单一用户会全选 」 close #216

This commit is contained in:
dushixiang
2022-01-23 17:53:22 +08:00
parent 29c066ca3a
commit d35b348a33
130 changed files with 5467 additions and 4554 deletions

View File

@ -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
}