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,32 @@
package document_repo
import (
"github.com/XingfenD/yoresee_doc/internal/model"
"gorm.io/gorm"
)
type DocumentCreateOperation struct {
repo *DocumentRepository
doc *model.Document
tx *gorm.DB
}
func (r *DocumentRepository) Create(doc *model.Document) *DocumentCreateOperation {
return &DocumentCreateOperation{
repo: r,
doc: doc,
}
}
func (op *DocumentCreateOperation) WithTx(tx *gorm.DB) *DocumentCreateOperation {
op.tx = tx
return op
}
func (op *DocumentCreateOperation) Exec() error {
if op.tx == nil {
op.tx = op.repo.db
}
return op.tx.Create(op.doc).Error
}