migrate from github

This commit is contained in:
2026-07-15 22:42:31 +08:00
commit 3ad559f05e
262 changed files with 21637 additions and 0 deletions
+45
View File
@@ -0,0 +1,45 @@
package user_repo
import (
"context"
"github.com/XingfenD/yoresee_doc/internal/model"
"github.com/XingfenD/yoresee_doc/pkg/key"
"gorm.io/gorm"
)
type UserDeleteOperation struct {
repo *UserRepository
id int64
tx *gorm.DB
}
func (r *UserRepository) Delete(id int64) *UserDeleteOperation {
return &UserDeleteOperation{
repo: r,
id: id,
}
}
func (op *UserDeleteOperation) WithTx(tx *gorm.DB) *UserDeleteOperation {
op.tx = tx
return op
}
func (op *UserDeleteOperation) Exec() error {
if op.tx != nil {
if err := op.tx.Delete(&model.User{}, op.id).Error; err != nil {
return err
}
return op.clearQueryCache()
}
if err := op.repo.db.Delete(&model.User{}, op.id).Error; err != nil {
return err
}
return op.clearQueryCache()
}
func (op *UserDeleteOperation) clearQueryCache() error {
_, _ = op.repo.redis.Incr(context.Background(), key.KeyUserQueryVersion()).Result()
return nil
}