feat: add CountActiveByDirectoryID method to KnowledgeDocument and KnowledgeFAQ repositories; update directory deletion logic to allow soft-deleted documents
This commit is contained in:
@@ -80,6 +80,14 @@ func (r *knowledgeDocumentRepository) Count(db *gorm.DB, cnd *sqls.Cnd) int64 {
|
||||
return cnd.Count(db, &models.KnowledgeDocument{})
|
||||
}
|
||||
|
||||
func (r *knowledgeDocumentRepository) CountActiveByDirectoryID(db *gorm.DB, directoryID int64) int64 {
|
||||
var count int64
|
||||
db.Model(&models.KnowledgeDocument{}).
|
||||
Where("directory_id = ? AND status <> ?", directoryID, enums.StatusDeleted).
|
||||
Count(&count)
|
||||
return count
|
||||
}
|
||||
|
||||
func (r *knowledgeDocumentRepository) Create(db *gorm.DB, t *models.KnowledgeDocument) (err error) {
|
||||
err = db.Create(t).Error
|
||||
return
|
||||
|
||||
Reference in New Issue
Block a user