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,35 @@
package comment_repo
import (
"github.com/XingfenD/yoresee_doc/internal/model"
"gorm.io/gorm"
)
type CommentCreateOperation struct {
repo *CommentRepository
item *model.DocumentComment
tx *gorm.DB
}
func (r *CommentRepository) Create(item *model.DocumentComment) *CommentCreateOperation {
return &CommentCreateOperation{
repo: r,
item: item,
}
}
func (op *CommentCreateOperation) WithTx(tx *gorm.DB) *CommentCreateOperation {
op.tx = tx
return op
}
func (op *CommentCreateOperation) Exec() error {
if op.item == nil {
return nil
}
db := op.repo.db
if op.tx != nil {
db = op.tx
}
return db.Create(op.item).Error
}