update sqlc gen

This commit is contained in:
Pavel 2024-06-19 20:47:28 +03:00
parent dae8abec18
commit 1e97acc6a9
2 changed files with 56 additions and 2 deletions

@ -1053,5 +1053,5 @@ FROM amoContact WHERE AccountID = $1 AND (Field = $2 OR Field = $3);
-- name: InsertContactAmo :one
INSERT INTO amoContact (AccountID, AmoID, Field) VALUES ($1, $2, $3) RETURNING AmoID;
-- name: UpdateAmoAccount :exec
UPDATE amoContact SET Field = $1 WHERE ID = $2;
-- name: UpdateAmoContact :exec
UPDATE amoContact SET Field = $1 WHERE ID = $2;

@ -1449,6 +1449,29 @@ func (q *Queries) GetCurrentCompany(ctx context.Context, accountid string) (Acco
return i, err
}
const getExistingContactAmo = `-- name: GetExistingContactAmo :one
SELECT ID, AccountID, AmoID, Field
FROM amoContact WHERE AccountID = $1 AND (Field = $2 OR Field = $3)
`
type GetExistingContactAmoParams struct {
Accountid int32 `db:"accountid" json:"accountid"`
Field string `db:"field" json:"field"`
Field_2 string `db:"field_2" json:"field_2"`
}
func (q *Queries) GetExistingContactAmo(ctx context.Context, arg GetExistingContactAmoParams) (Amocontact, error) {
row := q.db.QueryRowContext(ctx, getExistingContactAmo, arg.Accountid, arg.Field, arg.Field_2)
var i Amocontact
err := row.Scan(
&i.ID,
&i.Accountid,
&i.Amoid,
&i.Field,
)
return i, err
}
const getExpiredCountPrivilege = `-- name: GetExpiredCountPrivilege :many
SELECT p.id, p.privilegeID, p.privilege_name, p.amount, p.created_at, a.user_id
FROM privileges p
@ -2893,6 +2916,23 @@ func (q *Queries) InsertAnswers(ctx context.Context, arg InsertAnswersParams) (A
return i, err
}
const insertContactAmo = `-- name: InsertContactAmo :one
INSERT INTO amoContact (AccountID, AmoID, Field) VALUES ($1, $2, $3) RETURNING AmoID
`
type InsertContactAmoParams struct {
Accountid int32 `db:"accountid" json:"accountid"`
Amoid int32 `db:"amoid" json:"amoid"`
Field string `db:"field" json:"field"`
}
func (q *Queries) InsertContactAmo(ctx context.Context, arg InsertContactAmoParams) (int32, error) {
row := q.db.QueryRowContext(ctx, insertContactAmo, arg.Accountid, arg.Amoid, arg.Field)
var amoid int32
err := row.Scan(&amoid)
return amoid, err
}
const insertPrivilege = `-- name: InsertPrivilege :exec
INSERT INTO privileges (privilegeID, account_id, privilege_name, amount, created_at) VALUES ($1, $2, $3, $4, $5)
`
@ -3450,6 +3490,20 @@ func (q *Queries) UpdateAmoAccountUser(ctx context.Context, arg UpdateAmoAccount
return err
}
const updateAmoContact = `-- name: UpdateAmoContact :exec
UPDATE amoContact SET Field = $1 WHERE ID = $2
`
type UpdateAmoContactParams struct {
Field string `db:"field" json:"field"`
ID int64 `db:"id" json:"id"`
}
func (q *Queries) UpdateAmoContact(ctx context.Context, arg UpdateAmoContactParams) error {
_, err := q.db.ExecContext(ctx, updateAmoContact, arg.Field, arg.ID)
return err
}
const updateFieldRules = `-- name: UpdateFieldRules :exec
UPDATE rules SET FieldsRule = $1
WHERE AccountID = (SELECT AmoID FROM accountsAmo WHERE accountsAmo.AccountID = $2 AND accountsAmo.Deleted = false) AND QuizID = $3 AND Deleted = false