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
|
-- name: GetExistingContactAmo :many
|
||||||
WITH getAmoID AS (
|
WITH getAmoID AS (
|
||||||
SELECT AmoID FROM amoContact WHERE amoContact.AccountID = $1 AND amoContact.Field IN ($2::text[])
|
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);
|
WHERE amoContact.AccountID = $1 AND amoContact.AmoID IN (SELECT AmoID FROM getAmoID);
|
||||||
|
|
||||||
-- name: InsertContactAmo :one
|
-- name: InsertContactAmo :one
|
||||||
|
@ -1084,24 +1084,31 @@ func (r *AmoRepository) UpdatingDealAmoStatus(ctx context.Context, deps SaveDeal
|
|||||||
|
|
||||||
// методы для contact в амо
|
// методы для contact в амо
|
||||||
|
|
||||||
func (r *AmoRepository) GetExistingContactAmo(ctx context.Context, accountID int32, field string) (model.ContactAmo, error) {
|
func (r *AmoRepository) GetExistingContactAmo(ctx context.Context, accountID int32, fields []string) ([]model.ContactAmo, error) {
|
||||||
row, err := r.queries.GetExistingContactAmo(ctx, sqlcgen.GetExistingContactAmoParams{
|
rows, err := r.queries.GetExistingContactAmo(ctx, sqlcgen.GetExistingContactAmoParams{
|
||||||
Accountid: accountID,
|
Accountid: accountID,
|
||||||
Field: field,
|
Column2: fields,
|
||||||
})
|
})
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if err == sql.ErrNoRows {
|
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{
|
var result []model.ContactAmo
|
||||||
ID: row.ID,
|
|
||||||
AccountID: row.Accountid,
|
for _, row := range rows {
|
||||||
AmoID: row.Amoid,
|
result = append(result, model.ContactAmo{
|
||||||
}, nil
|
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) {
|
func (r *AmoRepository) InsertContactAmo(ctx context.Context, val model.ContactAmo) (int32, error) {
|
||||||
|
Loading…
Reference in New Issue
Block a user