38 lines
961 B
Go
38 lines
961 B
Go
|
|
package repositories
|
||
|
|
|
||
|
|
import (
|
||
|
|
"agent-desk/internal/models"
|
||
|
|
|
||
|
|
"github.com/mlogclub/simple/sqls"
|
||
|
|
"gorm.io/gorm"
|
||
|
|
)
|
||
|
|
|
||
|
|
var AIWorkflowRunRepository = newAIWorkflowRunRepository()
|
||
|
|
|
||
|
|
func newAIWorkflowRunRepository() *aiWorkflowRunRepository {
|
||
|
|
return &aiWorkflowRunRepository{}
|
||
|
|
}
|
||
|
|
|
||
|
|
type aiWorkflowRunRepository struct{}
|
||
|
|
|
||
|
|
func (r *aiWorkflowRunRepository) Get(db *gorm.DB, id int64) *models.AIWorkflowRun {
|
||
|
|
ret := &models.AIWorkflowRun{}
|
||
|
|
if err := db.First(ret, "id = ?", id).Error; err != nil {
|
||
|
|
return nil
|
||
|
|
}
|
||
|
|
return ret
|
||
|
|
}
|
||
|
|
|
||
|
|
func (r *aiWorkflowRunRepository) Find(db *gorm.DB, cnd *sqls.Cnd) (list []models.AIWorkflowRun) {
|
||
|
|
cnd.Find(db, &list)
|
||
|
|
return
|
||
|
|
}
|
||
|
|
|
||
|
|
func (r *aiWorkflowRunRepository) Create(db *gorm.DB, t *models.AIWorkflowRun) error {
|
||
|
|
return db.Create(t).Error
|
||
|
|
}
|
||
|
|
|
||
|
|
func (r *aiWorkflowRunRepository) Updates(db *gorm.DB, id int64, columns map[string]interface{}) error {
|
||
|
|
return db.Model(&models.AIWorkflowRun{}).Where("id = ?", id).Updates(columns).Error
|
||
|
|
}
|