update sqlc gen
This commit is contained in:
parent
836cb9fce7
commit
c17fb92c50
@ -688,7 +688,15 @@ SELECT * FROM users WHERE AccountID = $1;
|
||||
UPDATE users SET Name = $1, "Group" = $2, Email = $3, Role = $4 WHERE AmoID = $5;
|
||||
|
||||
-- name: GetUsersWithPagination :many
|
||||
SELECT *, COUNT(*) OVER() as total_count FROM users WHERE Deleted = false AND AccountID = $3 ORDER BY ID OFFSET ($1 - 1) * $2 LIMIT $2;
|
||||
WITH user_data AS (
|
||||
SELECT AmoID FROM users WHERE users.AccountID = $1 AND Deleted = false
|
||||
)
|
||||
SELECT u.ID, u.Name, u.Email, u.Role, u."Group", u.CreatedAt, u.Subdomain, u.Country, u.AmoUserID, u.AmoID,
|
||||
COUNT(*) OVER() as total_count
|
||||
FROM users u
|
||||
JOIN user_data a ON u.AmoUserID = a.AmoID
|
||||
WHERE u.Deleted = false
|
||||
ORDER BY u.ID OFFSET ($2 - 1) * $3 LIMIT $3;
|
||||
|
||||
-- name: GetTagsWithPagination :many
|
||||
SELECT t.*, COUNT(*) OVER() as total_count
|
||||
|
@ -2151,33 +2151,39 @@ func (q *Queries) GetTokenById(ctx context.Context, accountid string) (Token, er
|
||||
}
|
||||
|
||||
const getUsersWithPagination = `-- name: GetUsersWithPagination :many
|
||||
SELECT id, accountid, amoid, name, email, role, "Group", deleted, createdat, subdomain, amouserid, country, COUNT(*) OVER() as total_count FROM users WHERE Deleted = false AND AccountID = $3 ORDER BY ID OFFSET ($1 - 1) * $2 LIMIT $2
|
||||
WITH user_data AS (
|
||||
SELECT AmoID FROM users WHERE users.AccountID = $1 AND Deleted = false
|
||||
)
|
||||
SELECT u.ID, u.Name, u.Email, u.Role, u."Group", u.CreatedAt, u.Subdomain, u.Country, u.AmoUserID, u.AmoID,
|
||||
COUNT(*) OVER() as total_count
|
||||
FROM users u
|
||||
JOIN user_data a ON u.AmoUserID = a.AmoID
|
||||
WHERE u.Deleted = false
|
||||
ORDER BY u.ID OFFSET ($2 - 1) * $3 LIMIT $3
|
||||
`
|
||||
|
||||
type GetUsersWithPaginationParams struct {
|
||||
Column1 interface{} `db:"column_1" json:"column_1"`
|
||||
Limit int32 `db:"limit" json:"limit"`
|
||||
Accountid string `db:"accountid" json:"accountid"`
|
||||
Column2 interface{} `db:"column_2" json:"column_2"`
|
||||
Limit int32 `db:"limit" json:"limit"`
|
||||
}
|
||||
|
||||
type GetUsersWithPaginationRow 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"`
|
||||
Deleted bool `db:"deleted" json:"deleted"`
|
||||
Createdat sql.NullTime `db:"createdat" json:"createdat"`
|
||||
Subdomain string `db:"subdomain" json:"subdomain"`
|
||||
Amouserid int32 `db:"amouserid" json:"amouserid"`
|
||||
Country string `db:"country" json:"country"`
|
||||
Amouserid int32 `db:"amouserid" json:"amouserid"`
|
||||
Amoid int32 `db:"amoid" json:"amoid"`
|
||||
TotalCount int64 `db:"total_count" json:"total_count"`
|
||||
}
|
||||
|
||||
func (q *Queries) GetUsersWithPagination(ctx context.Context, arg GetUsersWithPaginationParams) ([]GetUsersWithPaginationRow, error) {
|
||||
rows, err := q.db.QueryContext(ctx, getUsersWithPagination, arg.Column1, arg.Limit, arg.Accountid)
|
||||
rows, err := q.db.QueryContext(ctx, getUsersWithPagination, arg.Accountid, arg.Column2, arg.Limit)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@ -2187,17 +2193,15 @@ func (q *Queries) GetUsersWithPagination(ctx context.Context, arg GetUsersWithPa
|
||||
var i GetUsersWithPaginationRow
|
||||
if err := rows.Scan(
|
||||
&i.ID,
|
||||
&i.Accountid,
|
||||
&i.Amoid,
|
||||
&i.Name,
|
||||
&i.Email,
|
||||
&i.Role,
|
||||
&i.Group,
|
||||
&i.Deleted,
|
||||
&i.Createdat,
|
||||
&i.Subdomain,
|
||||
&i.Amouserid,
|
||||
&i.Country,
|
||||
&i.Amouserid,
|
||||
&i.Amoid,
|
||||
&i.TotalCount,
|
||||
); err != nil {
|
||||
return nil, err
|
||||
|
Loading…
Reference in New Issue
Block a user