added new db method GetAllYclientsAccounts
This commit is contained in:
parent
9a7a360c23
commit
6a3f41120c
@ -1510,6 +1510,9 @@ FROM YclientsAccountUsers u
|
||||
WHERE u.Deleted = false
|
||||
ORDER BY u.ID OFFSET ($2 - 1) * $3 LIMIT $3;
|
||||
|
||||
-- name: GetAllYclientsAccounts :many
|
||||
SELECT * from YclientsAccounts where Deleted = false;
|
||||
|
||||
-- -- name: GetCompanyYclientsWithPagination :many
|
||||
-- WITH user_data AS (
|
||||
-- SELECT SalonID FROM YclientsAccounts WHERE YclientsAccounts.AccountID = $1 AND YclientsAccounts.Deleted = false
|
||||
|
||||
@ -2351,6 +2351,40 @@ func (q *Queries) GetAllTokens(ctx context.Context) ([]Token, error) {
|
||||
return items, nil
|
||||
}
|
||||
|
||||
const getAllYclientsAccounts = `-- name: GetAllYclientsAccounts :many
|
||||
SELECT id, accountid, salonid, title, deleted, createdat from YclientsAccounts where Deleted = false
|
||||
`
|
||||
|
||||
func (q *Queries) GetAllYclientsAccounts(ctx context.Context) ([]Yclientsaccount, error) {
|
||||
rows, err := q.db.QueryContext(ctx, getAllYclientsAccounts)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer rows.Close()
|
||||
var items []Yclientsaccount
|
||||
for rows.Next() {
|
||||
var i Yclientsaccount
|
||||
if err := rows.Scan(
|
||||
&i.ID,
|
||||
&i.Accountid,
|
||||
&i.Salonid,
|
||||
&i.Title,
|
||||
&i.Deleted,
|
||||
&i.Createdat,
|
||||
); 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 getBitrixFieldByID = `-- name: GetBitrixFieldByID :one
|
||||
SELECT id, bitrixid, accountid, entityid, fieldname, editfromlabel, fieldtype, deleted, createdat FROM BitrixFields WHERE BitrixID = $1 AND Deleted = false
|
||||
`
|
||||
|
||||
@ -46,6 +46,25 @@ func (r *YclientsRepository) GetCurrentAccount(ctx context.Context, accountID st
|
||||
return &user, nil
|
||||
}
|
||||
|
||||
func (r *YclientsRepository) GetAllYclientsAccounts(ctx context.Context) ([]*model.YclientsAccount, error) {
|
||||
rows, err := r.queries.GetAllYclientsAccounts(ctx)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
var result []*model.YclientsAccount
|
||||
for _, row := range rows {
|
||||
result = append(result, &model.YclientsAccount{
|
||||
ID: row.ID,
|
||||
AccountID: row.Accountid,
|
||||
SalonID: row.Salonid,
|
||||
Title: row.Title,
|
||||
Deleted: row.Deleted,
|
||||
CreatedAt: row.Createdat,
|
||||
})
|
||||
}
|
||||
return result, nil
|
||||
}
|
||||
|
||||
func (r *YclientsRepository) GettingUserWithPagination(ctx context.Context, req *model.PaginationReq, accountID string) (*model.UserListYclientsResp, error) {
|
||||
rows, err := r.queries.GetUsersYclientsWithPagination(ctx, sqlcgen.GetUsersYclientsWithPaginationParams{
|
||||
Accountid: accountID,
|
||||
|
||||
Loading…
Reference in New Issue
Block a user