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,39 @@
package template_repo
import (
"github.com/XingfenD/yoresee_doc/internal/model"
"gorm.io/gorm"
)
type TemplateMGetByIDsOperation struct {
repo *TemplateRepository
ids []int64
tx *gorm.DB
}
func (r *TemplateRepository) MGetByIDs(ids []int64) *TemplateMGetByIDsOperation {
return &TemplateMGetByIDsOperation{
repo: r,
ids: ids,
}
}
func (op *TemplateMGetByIDsOperation) WithTx(tx *gorm.DB) *TemplateMGetByIDsOperation {
op.tx = tx
return op
}
func (op *TemplateMGetByIDsOperation) Exec() ([]*model.Template, error) {
db := op.repo.db
if op.tx != nil {
db = op.tx
}
var templates []*model.Template
if len(op.ids) == 0 {
return templates, nil
}
if err := db.Where("id IN ?", op.ids).Find(&templates).Error; err != nil {
return nil, err
}
return templates, nil
}