added method GetUserUsersByID
This commit is contained in:
parent
43096217dc
commit
437e709ac3
@ -1556,4 +1556,7 @@ select * from YclientsTokens where AccountID = $1 and Expiration=false and Activ
|
|||||||
insert into YclientsAccounts (AccountID,SalonID,Title,Country,ShortDecription) values ($1,$2,$3,$4,$5) RETURNING *;
|
insert into YclientsAccounts (AccountID,SalonID,Title,Country,ShortDecription) values ($1,$2,$3,$4,$5) RETURNING *;
|
||||||
|
|
||||||
-- name: GetAllYclientsUserToken :many
|
-- name: GetAllYclientsUserToken :many
|
||||||
select * from YclientsTokens where Expiration=false and Active = true;
|
select * from YclientsTokens where Expiration=false and Active = true;
|
||||||
|
|
||||||
|
-- name: GetUsersByIDYclients :many
|
||||||
|
SELECT * FROM YclientsAccountUsers WHERE SalonID = $1 AND Deleted = false;
|
||||||
@ -4391,6 +4391,41 @@ func (q *Queries) GetUsersBitrixWithPagination(ctx context.Context, arg GetUsers
|
|||||||
return items, nil
|
return items, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const getUsersByIDYclients = `-- name: GetUsersByIDYclients :many
|
||||||
|
SELECT id, salonid, yclientsuserid, name, role, deleted, createdat FROM YclientsAccountUsers WHERE SalonID = $1 AND Deleted = false
|
||||||
|
`
|
||||||
|
|
||||||
|
func (q *Queries) GetUsersByIDYclients(ctx context.Context, salonid int32) ([]Yclientsaccountuser, error) {
|
||||||
|
rows, err := q.db.QueryContext(ctx, getUsersByIDYclients, salonid)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
defer rows.Close()
|
||||||
|
var items []Yclientsaccountuser
|
||||||
|
for rows.Next() {
|
||||||
|
var i Yclientsaccountuser
|
||||||
|
if err := rows.Scan(
|
||||||
|
&i.ID,
|
||||||
|
&i.Salonid,
|
||||||
|
&i.Yclientsuserid,
|
||||||
|
&i.Name,
|
||||||
|
&i.Role,
|
||||||
|
&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 getUsersCount = `-- name: GetUsersCount :one
|
const getUsersCount = `-- name: GetUsersCount :one
|
||||||
WITH user_data AS (
|
WITH user_data AS (
|
||||||
SELECT AmoID FROM accountsAmo WHERE accountsAmo.AccountID = $1 AND accountsAmo.Deleted = false
|
SELECT AmoID FROM accountsAmo WHERE accountsAmo.AccountID = $1 AND accountsAmo.Deleted = false
|
||||||
|
|||||||
@ -210,6 +210,26 @@ func (r *YclientsRepository) CreateAccount(ctx context.Context, account model.Yc
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (r *YclientsRepository) GetUserUsersByID(ctx context.Context, salonID int32) ([]model.YclientsAccountUser, error) {
|
||||||
|
rows, err := r.queries.GetUsersByIDYclients(ctx, salonID)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
var users []model.YclientsAccountUser
|
||||||
|
for _, row := range rows {
|
||||||
|
users = append(users, model.YclientsAccountUser{
|
||||||
|
ID: row.ID,
|
||||||
|
SalonID: row.Salonid,
|
||||||
|
YclientsUserID: row.Yclientsuserid,
|
||||||
|
Name: row.Name,
|
||||||
|
Role: row.Role,
|
||||||
|
Deleted: row.Deleted,
|
||||||
|
CreatedAt: row.Createdat,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
return users, nil
|
||||||
|
}
|
||||||
|
|
||||||
// company
|
// company
|
||||||
//func (r *YclientsRepository) GettingCompanyWithPagination(ctx context.Context, req *model.PaginationReq, accountID string) (*model.CompanyListYclientsResp, error) {
|
//func (r *YclientsRepository) GettingCompanyWithPagination(ctx context.Context, req *model.PaginationReq, accountID string) (*model.CompanyListYclientsResp, error) {
|
||||||
// rows, err := r.queries.GetCompanyYclientsWithPagination(ctx, sqlcgen.GetCompanyYclientsWithPaginationParams{
|
// rows, err := r.queries.GetCompanyYclientsWithPagination(ctx, sqlcgen.GetCompanyYclientsWithPaginationParams{
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user