add repo method for get lead target

This commit is contained in:
Pavel 2024-06-11 16:56:31 +03:00
parent 4c6b21e7f0
commit 30262442b2

@ -392,9 +392,28 @@ func (r *AccountRepository) DeleteLeadTarget(ctx context.Context, id int64) erro
return nil
}
func (r *AccountRepository) GetLeadTarget(ctx context.Context, accountID string) ([]model.LeadTarget, error) {
func (r *AccountRepository) GetLeadTarget(ctx context.Context, accountID string, quizID int32) ([]model.LeadTarget, error) {
rows, err := r.queries.GetLeadTarget(ctx, sqlcgen.GetLeadTargetParams{
Accountid: accountID,
Quizid: quizID,
})
if err != nil {
return nil, err
}
var leadTargets []model.LeadTarget
for _, row := range rows {
leadTargets = append(leadTargets, model.LeadTarget{
ID: row.ID,
AccountID: row.Accountid,
Type: row.Type,
QuizID: row.Quizid,
Target: row.Target,
Deleted: row.Deleted,
CreatedAt: row.Createdat,
})
}
return []model.LeadTarget{}, nil
return leadTargets, nil
}
func (r *AccountRepository) UpdateLeadTarget(ctx context.Context, req model.LeadTarget) (model.LeadTarget, error) {