migrate from github
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
package comment_repo
|
||||
|
||||
import (
|
||||
"github.com/XingfenD/yoresee_doc/internal/model"
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
type CommentDeleteOperation struct {
|
||||
repo *CommentRepository
|
||||
id int64
|
||||
tx *gorm.DB
|
||||
}
|
||||
|
||||
func (r *CommentRepository) Delete(id int64) *CommentDeleteOperation {
|
||||
return &CommentDeleteOperation{
|
||||
repo: r,
|
||||
id: id,
|
||||
}
|
||||
}
|
||||
|
||||
func (op *CommentDeleteOperation) WithTx(tx *gorm.DB) *CommentDeleteOperation {
|
||||
op.tx = tx
|
||||
return op
|
||||
}
|
||||
|
||||
func (op *CommentDeleteOperation) Exec() error {
|
||||
db := op.repo.db
|
||||
if op.tx != nil {
|
||||
db = op.tx
|
||||
}
|
||||
return db.Delete(&model.DocumentComment{}, op.id).Error
|
||||
}
|
||||
Reference in New Issue
Block a user