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
@@ -0,0 +1,37 @@
package user_repo
import (
"github.com/XingfenD/yoresee_doc/internal/model"
"gorm.io/gorm"
)
type UserGetByIDOperation struct {
repo *UserRepository
id int64
tx *gorm.DB
}
func (r *UserRepository) GetByID(id int64) *UserGetByIDOperation {
return &UserGetByIDOperation{
repo: r,
id: id,
}
}
func (op *UserGetByIDOperation) WithTx(tx *gorm.DB) *UserGetByIDOperation {
op.tx = tx
return op
}
func (op *UserGetByIDOperation) Exec() (*model.User, error) {
var user model.User
var err error
if op.tx != nil {
err = op.tx.First(&user, op.id).Error
} else {
err = op.repo.db.First(&user, op.id).Error
}
return &user, err
}