feat(dashboard-apps): align chatwoot payloads

This commit is contained in:
2026-06-06 13:03:16 +08:00
parent 11e5537f9b
commit 75f0e809a5
9 changed files with 312 additions and 71 deletions
+13 -1
View File
@@ -28,6 +28,14 @@ func (r *DashboardAppRepo) GetByID(ctx context.Context, id uint) (*model.Dashboa
return &app, nil
}
func (r *DashboardAppRepo) GetByAccountAndID(ctx context.Context, accountID, id uint) (*model.DashboardApp, error) {
var app model.DashboardApp
if err := r.db.WithContext(ctx).Where("account_id = ? AND id = ?", accountID, id).First(&app).Error; err != nil {
return nil, err
}
return &app, nil
}
func (r *DashboardAppRepo) Update(ctx context.Context, app *model.DashboardApp) error {
return r.db.WithContext(ctx).Save(app).Error
}
@@ -36,6 +44,10 @@ func (r *DashboardAppRepo) Delete(ctx context.Context, id uint) error {
return r.db.WithContext(ctx).Delete(&model.DashboardApp{}, id).Error
}
func (r *DashboardAppRepo) DeleteByAccountAndID(ctx context.Context, accountID, id uint) error {
return r.db.WithContext(ctx).Where("account_id = ? AND id = ?", accountID, id).Delete(&model.DashboardApp{}).Error
}
// FindAllByAccountID returns all dashboard apps for an account (no pagination).
// Chatwoot: Current.account.dashboard_apps — returns all without limit/offset
func (r *DashboardAppRepo) FindAllByAccountID(ctx context.Context, accountID uint) ([]model.DashboardApp, error) {
@@ -105,4 +117,4 @@ func (r *DashboardAppRepo) FindAllActiveByAccountID(ctx context.Context, account
return nil, err
}
return apps, nil
}
}