修复 「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,29 +1,24 @@
package repository
import (
"next-terminal/server/model"
"context"
"gorm.io/gorm"
"next-terminal/server/model"
)
type StrategyRepository struct {
DB *gorm.DB
type strategyRepository struct {
baseRepository
}
func NewStrategyRepository(db *gorm.DB) *StrategyRepository {
strategyRepository = &StrategyRepository{DB: db}
return strategyRepository
}
func (r StrategyRepository) FindAll() (o []model.Strategy, err error) {
err = r.DB.Order("name desc").Find(&o).Error
func (r strategyRepository) FindAll(c context.Context) (o []model.Strategy, err error) {
err = r.GetDB(c).Order("name desc").Find(&o).Error
return
}
func (r StrategyRepository) Find(pageIndex, pageSize int, name, order, field string) (o []model.Strategy, total int64, err error) {
func (r strategyRepository) Find(c context.Context, pageIndex, pageSize int, name, order, field string) (o []model.Strategy, total int64, err error) {
m := model.Strategy{}
db := r.DB.Table(m.TableName())
dbCounter := r.DB.Table(m.TableName())
db := r.GetDB(c).Table(m.TableName())
dbCounter := r.GetDB(c).Table(m.TableName())
if len(name) > 0 {
db = db.Where("name like ?", "%"+name+"%")
@ -54,20 +49,20 @@ func (r StrategyRepository) Find(pageIndex, pageSize int, name, order, field str
return
}
func (r StrategyRepository) DeleteById(id string) error {
return r.DB.Where("id = ?", id).Delete(model.Strategy{}).Error
func (r strategyRepository) DeleteById(c context.Context, id string) error {
return r.GetDB(c).Where("id = ?", id).Delete(model.Strategy{}).Error
}
func (r StrategyRepository) Create(m *model.Strategy) error {
return r.DB.Create(m).Error
func (r strategyRepository) Create(c context.Context, m *model.Strategy) error {
return r.GetDB(c).Create(m).Error
}
func (r StrategyRepository) UpdateById(o *model.Strategy, id string) error {
func (r strategyRepository) UpdateById(c context.Context, o *model.Strategy, id string) error {
o.ID = id
return r.DB.Updates(o).Error
return r.GetDB(c).Updates(o).Error
}
func (r StrategyRepository) FindById(id string) (m model.Strategy, err error) {
err = r.DB.Where("id = ?", id).First(&m).Error
func (r strategyRepository) FindById(c context.Context, id string) (m model.Strategy, err error) {
err = r.GetDB(c).Where("id = ?", id).First(&m).Error
return
}