update query
This commit is contained in:
parent
f9eec59ce1
commit
70c87cef1b
@ -1049,7 +1049,7 @@ RETURNING p.id, p.privilegeID, p.account_id, p.privilege_name, p.amount, p.creat
|
||||
-- name: GetExistingContactAmo :many
|
||||
WITH getAmoID AS (
|
||||
SELECT AmoID FROM amoContact WHERE amoContact.AccountID = $1 AND amoContact.Field IN ($2::text[])
|
||||
) SELECT DISTINCT * FROM amoContact
|
||||
) SELECT * FROM amoContact
|
||||
WHERE amoContact.AccountID = $1 AND amoContact.AmoID IN (SELECT AmoID FROM getAmoID);
|
||||
|
||||
-- name: InsertContactAmo :one
|
||||
|
@ -1084,24 +1084,31 @@ func (r *AmoRepository) UpdatingDealAmoStatus(ctx context.Context, deps SaveDeal
|
||||
|
||||
// методы для contact в амо
|
||||
|
||||
func (r *AmoRepository) GetExistingContactAmo(ctx context.Context, accountID int32, field string) (model.ContactAmo, error) {
|
||||
row, err := r.queries.GetExistingContactAmo(ctx, sqlcgen.GetExistingContactAmoParams{
|
||||
func (r *AmoRepository) GetExistingContactAmo(ctx context.Context, accountID int32, fields []string) ([]model.ContactAmo, error) {
|
||||
rows, err := r.queries.GetExistingContactAmo(ctx, sqlcgen.GetExistingContactAmoParams{
|
||||
Accountid: accountID,
|
||||
Field: field,
|
||||
Column2: fields,
|
||||
})
|
||||
|
||||
if err != nil {
|
||||
if err == sql.ErrNoRows {
|
||||
return model.ContactAmo{}, pj_errors.ErrNotFound
|
||||
return nil, pj_errors.ErrNotFound
|
||||
}
|
||||
return model.ContactAmo{}, err
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return model.ContactAmo{
|
||||
ID: row.ID,
|
||||
AccountID: row.Accountid,
|
||||
AmoID: row.Amoid,
|
||||
}, nil
|
||||
var result []model.ContactAmo
|
||||
|
||||
for _, row := range rows {
|
||||
result = append(result, model.ContactAmo{
|
||||
ID: row.ID,
|
||||
AmoID: row.Amoid,
|
||||
AccountID: row.Accountid,
|
||||
Field: row.Field,
|
||||
})
|
||||
}
|
||||
|
||||
return result, nil
|
||||
}
|
||||
|
||||
func (r *AmoRepository) InsertContactAmo(ctx context.Context, val model.ContactAmo) (int32, error) {
|
||||
|
Loading…
Reference in New Issue
Block a user