update sqlc gen

This commit is contained in:
Pavel 2024-05-07 20:47:49 +03:00
parent 9f3b71ecd5
commit 767c884ae0
2 changed files with 189 additions and 3 deletions

@ -1048,7 +1048,7 @@ UPDATE pipelines SET Deleted = true WHERE ID = ANY($1::bigint[]);
UPDATE users SET Deleted = true WHERE ID = ANY($1::bigint[]);
-- name: GetUserTagsByID :many
SELECT ID,AmoID,AccountID,Name,Entity,Type,Color
SELECT ID,AmoID,AccountID,Name,Entity,Color
FROM tags
WHERE AccountID = $1 AND Deleted = false;
@ -1065,4 +1065,4 @@ WHERE AccountID = $1 AND Deleted = false;
-- name: GetUserUsersByID :many
SELECT ID,AccountID,AmoID,Name,Email,Role,"Group",Subdomain,AmoUserID,Country
FROM users
WHERE AmoUserID = $1 AND Deleted = false;
WHERE AmoUserID = $1 AND Deleted = false;

@ -2409,7 +2409,7 @@ func (q *Queries) GetUTMsWithPagination(ctx context.Context, arg GetUTMsWithPagi
const getUserFieldsByID = `-- name: GetUserFieldsByID :many
SELECT ID,AmoID,Code,AccountID,Name,Entity,Type
FROM fields
WHERE AccountID = $1
WHERE AccountID = $1 AND Deleted = false
`
type GetUserFieldsByIDRow struct {
@ -2453,6 +2453,192 @@ func (q *Queries) GetUserFieldsByID(ctx context.Context, accountid int32) ([]Get
return items, nil
}
const getUserPipelinesByID = `-- name: GetUserPipelinesByID :many
SELECT ID,AmoID,AccountID,Name,IsArchive
FROM pipelines
WHERE AccountID = $1 AND Deleted = false
`
type GetUserPipelinesByIDRow struct {
ID int64 `db:"id" json:"id"`
Amoid int32 `db:"amoid" json:"amoid"`
Accountid int32 `db:"accountid" json:"accountid"`
Name string `db:"name" json:"name"`
Isarchive bool `db:"isarchive" json:"isarchive"`
}
func (q *Queries) GetUserPipelinesByID(ctx context.Context, accountid int32) ([]GetUserPipelinesByIDRow, error) {
rows, err := q.db.QueryContext(ctx, getUserPipelinesByID, accountid)
if err != nil {
return nil, err
}
defer rows.Close()
var items []GetUserPipelinesByIDRow
for rows.Next() {
var i GetUserPipelinesByIDRow
if err := rows.Scan(
&i.ID,
&i.Amoid,
&i.Accountid,
&i.Name,
&i.Isarchive,
); err != nil {
return nil, err
}
items = append(items, i)
}
if err := rows.Close(); err != nil {
return nil, err
}
if err := rows.Err(); err != nil {
return nil, err
}
return items, nil
}
const getUserStepsByID = `-- name: GetUserStepsByID :many
SELECT ID,AmoID,PipelineID,AccountID,Name,Color
FROM steps
WHERE AccountID = $1 AND Deleted = false
`
type GetUserStepsByIDRow struct {
ID int64 `db:"id" json:"id"`
Amoid int32 `db:"amoid" json:"amoid"`
Pipelineid int32 `db:"pipelineid" json:"pipelineid"`
Accountid int32 `db:"accountid" json:"accountid"`
Name string `db:"name" json:"name"`
Color string `db:"color" json:"color"`
}
func (q *Queries) GetUserStepsByID(ctx context.Context, accountid int32) ([]GetUserStepsByIDRow, error) {
rows, err := q.db.QueryContext(ctx, getUserStepsByID, accountid)
if err != nil {
return nil, err
}
defer rows.Close()
var items []GetUserStepsByIDRow
for rows.Next() {
var i GetUserStepsByIDRow
if err := rows.Scan(
&i.ID,
&i.Amoid,
&i.Pipelineid,
&i.Accountid,
&i.Name,
&i.Color,
); err != nil {
return nil, err
}
items = append(items, i)
}
if err := rows.Close(); err != nil {
return nil, err
}
if err := rows.Err(); err != nil {
return nil, err
}
return items, nil
}
const getUserTagsByID = `-- name: GetUserTagsByID :many
SELECT ID,AmoID,AccountID,Name,Entity,Color
FROM tags
WHERE AccountID = $1 AND Deleted = false
`
type GetUserTagsByIDRow struct {
ID int64 `db:"id" json:"id"`
Amoid int32 `db:"amoid" json:"amoid"`
Accountid int32 `db:"accountid" json:"accountid"`
Name string `db:"name" json:"name"`
Entity interface{} `db:"entity" json:"entity"`
Color string `db:"color" json:"color"`
}
func (q *Queries) GetUserTagsByID(ctx context.Context, accountid int32) ([]GetUserTagsByIDRow, error) {
rows, err := q.db.QueryContext(ctx, getUserTagsByID, accountid)
if err != nil {
return nil, err
}
defer rows.Close()
var items []GetUserTagsByIDRow
for rows.Next() {
var i GetUserTagsByIDRow
if err := rows.Scan(
&i.ID,
&i.Amoid,
&i.Accountid,
&i.Name,
&i.Entity,
&i.Color,
); err != nil {
return nil, err
}
items = append(items, i)
}
if err := rows.Close(); err != nil {
return nil, err
}
if err := rows.Err(); err != nil {
return nil, err
}
return items, nil
}
const getUserUsersByID = `-- name: GetUserUsersByID :many
SELECT ID,AccountID,AmoID,Name,Email,Role,"Group",Subdomain,AmoUserID,Country
FROM users
WHERE AmoUserID = $1 AND Deleted = false
`
type GetUserUsersByIDRow struct {
ID int64 `db:"id" json:"id"`
Accountid string `db:"accountid" json:"accountid"`
Amoid int32 `db:"amoid" json:"amoid"`
Name string `db:"name" json:"name"`
Email string `db:"email" json:"email"`
Role int32 `db:"role" json:"role"`
Group int32 `db:"Group" json:"Group"`
Subdomain string `db:"subdomain" json:"subdomain"`
Amouserid int32 `db:"amouserid" json:"amouserid"`
Country string `db:"country" json:"country"`
}
func (q *Queries) GetUserUsersByID(ctx context.Context, amouserid int32) ([]GetUserUsersByIDRow, error) {
rows, err := q.db.QueryContext(ctx, getUserUsersByID, amouserid)
if err != nil {
return nil, err
}
defer rows.Close()
var items []GetUserUsersByIDRow
for rows.Next() {
var i GetUserUsersByIDRow
if err := rows.Scan(
&i.ID,
&i.Accountid,
&i.Amoid,
&i.Name,
&i.Email,
&i.Role,
&i.Group,
&i.Subdomain,
&i.Amouserid,
&i.Country,
); err != nil {
return nil, err
}
items = append(items, i)
}
if err := rows.Close(); err != nil {
return nil, err
}
if err := rows.Err(); err != nil {
return nil, err
}
return items, nil
}
const getUsersWithPagination = `-- name: GetUsersWithPagination :many
WITH user_data AS (
SELECT AmoID FROM users WHERE users.AccountID = $1 AND Deleted = false