update yclients table,queries,repository methods,models
This commit is contained in:
parent
0f50c86b1a
commit
86d8476caf
@ -1495,45 +1495,59 @@ WHERE quiz_id = $1 AND privilege_id = $2;
|
|||||||
UPDATE quiz_privilege_usage SET used_count = 0, updated_at = CURRENT_TIMESTAMP
|
UPDATE quiz_privilege_usage SET used_count = 0, updated_at = CURRENT_TIMESTAMP
|
||||||
WHERE quiz_id = $1 AND privilege_id = $2;
|
WHERE quiz_id = $1 AND privilege_id = $2;
|
||||||
|
|
||||||
|
-- Yclients
|
||||||
|
|
||||||
-- name: GetCurrentYclientsCompany :one
|
-- name: GetCurrentYclientsCompany :one
|
||||||
SELECT * FROM YclientsAccounts WHERE AccountID = $1 AND Deleted = false;
|
SELECT * FROM YclientsAccounts WHERE AccountID = $1 AND Deleted = false;
|
||||||
|
|
||||||
-- name: GetUsersYclientsWithPagination :many
|
-- name: GetUsersYclientsWithPagination :many
|
||||||
WITH user_data AS (
|
WITH user_data AS (
|
||||||
SELECT YclientsID FROM YclientsAccounts WHERE YclientsAccounts.AccountID = $1 AND YclientsAccounts.Deleted = false
|
SELECT SalonID FROM YclientsAccounts WHERE YclientsAccounts.AccountID = $1 AND YclientsAccounts.Deleted = false
|
||||||
)
|
)
|
||||||
SELECT u.*, COUNT(*) OVER() as total_count
|
SELECT u.*, COUNT(*) OVER() as total_count
|
||||||
FROM YclientsAccountUsers u
|
FROM YclientsAccountUsers u
|
||||||
JOIN user_data a ON u.YclientsID = a.YclientsID
|
JOIN user_data a ON u.SalonID = a.SalonID
|
||||||
WHERE u.Deleted = false
|
WHERE u.Deleted = false
|
||||||
ORDER BY u.ID OFFSET ($2 - 1) * $3 LIMIT $3;
|
ORDER BY u.ID OFFSET ($2 - 1) * $3 LIMIT $3;
|
||||||
|
|
||||||
-- name: GetCompanyYclientsWithPagination :many
|
-- name: GetCompanyYclientsWithPagination :many
|
||||||
WITH user_data AS (
|
WITH user_data AS (
|
||||||
SELECT YclientsID FROM YclientsAccounts WHERE YclientsAccounts.AccountID = $1 AND YclientsAccounts.Deleted = false
|
SELECT SalonID FROM YclientsAccounts WHERE YclientsAccounts.AccountID = $1 AND YclientsAccounts.Deleted = false
|
||||||
)
|
)
|
||||||
SELECT u.*, COUNT(*) OVER() as total_count
|
SELECT u.*, COUNT(*) OVER() as total_count
|
||||||
FROM YclientsCompany u
|
FROM YclientsCompany u
|
||||||
JOIN user_data a ON u.YclientsID = a.YclientsID
|
JOIN user_data a ON u.SalonID = a.SalonID
|
||||||
WHERE u.Deleted = false
|
WHERE u.Deleted = false
|
||||||
ORDER BY u.ID OFFSET ($2 - 1) * $3 LIMIT $3;
|
ORDER BY u.ID OFFSET ($2 - 1) * $3 LIMIT $3;
|
||||||
|
|
||||||
-- name: GetServicesYclientsWithPagination :many
|
-- name: GetServicesYclientsWithPagination :many
|
||||||
WITH user_data AS (
|
WITH user_data AS (
|
||||||
SELECT YclientsID FROM YclientsAccounts WHERE YclientsAccounts.AccountID = $1 AND YclientsAccounts.Deleted = false
|
SELECT SalonID FROM YclientsAccounts WHERE YclientsAccounts.AccountID = $1 AND YclientsAccounts.Deleted = false
|
||||||
)
|
)
|
||||||
SELECT u.*, COUNT(*) OVER() as total_count
|
SELECT u.*, COUNT(*) OVER() as total_count
|
||||||
FROM YclientsServices u
|
FROM YclientsServices u
|
||||||
JOIN user_data a ON u.YclientsID = a.YclientsID
|
JOIN user_data a ON u.SalonID = a.SalonID
|
||||||
WHERE u.Deleted = false
|
WHERE u.Deleted = false
|
||||||
ORDER BY u.ID OFFSET ($2 - 1) * $3 LIMIT $3;
|
ORDER BY u.ID OFFSET ($2 - 1) * $3 LIMIT $3;
|
||||||
|
|
||||||
-- name: GetTimeslotsYclientsWithPagination :many
|
-- name: GetTimeslotsYclientsWithPagination :many
|
||||||
WITH user_data AS (
|
WITH user_data AS (
|
||||||
SELECT YclientsID FROM YclientsAccounts WHERE YclientsAccounts.AccountID = $1 AND YclientsAccounts.Deleted = false
|
SELECT SalonID FROM YclientsAccounts WHERE YclientsAccounts.AccountID = $1 AND YclientsAccounts.Deleted = false
|
||||||
)
|
)
|
||||||
SELECT u.*, COUNT(*) OVER() as total_count
|
SELECT u.*, COUNT(*) OVER() as total_count
|
||||||
FROM YclientsTimeSlots u
|
FROM YclientsTimeSlots u
|
||||||
JOIN user_data a ON u.YclientsID = a.YclientsID
|
JOIN user_data a ON u.SalonID = a.SalonID
|
||||||
WHERE u.Deleted = false
|
WHERE u.Deleted = false
|
||||||
ORDER BY u.ID OFFSET ($2 - 1) * $3 LIMIT $3;
|
ORDER BY u.ID OFFSET ($2 - 1) * $3 LIMIT $3;
|
||||||
|
|
||||||
|
-- name: InsertYclientsTokens :one
|
||||||
|
insert into YclientsTokens (AccountID,SalonID) values($1,$2) RETURNING *;
|
||||||
|
|
||||||
|
-- name: UpdateYclientsTokensAccessToken :one
|
||||||
|
update YclientsTokens set AccessToken = $1, Active = true where AccountID = $2 and SalonID = $3 and Expiration = false RETURNING *;
|
||||||
|
|
||||||
|
-- name: UpdateYclientsTokensExpiration :one
|
||||||
|
update YclientsTokens set Expiration=$1, Active = $2 where AccountID = $3 RETURNING *;
|
||||||
|
|
||||||
|
-- name: GetYclientsUserToken :one
|
||||||
|
select * from YclientsTokens where AccountID = $1 and Expiration=false and Active = true;
|
||||||
@ -1,18 +1,27 @@
|
|||||||
|
CREATE TABLE IF NOT EXISTS YclientsTokens (
|
||||||
|
AccountID VARCHAR(30) PRIMARY KEY, -- связь с users AccountID неявная посредством join
|
||||||
|
SalonID INT NOT NULL, -- ID компании
|
||||||
|
AccessToken TEXT NOT NULL DEFAULT '',
|
||||||
|
Active BOOLEAN NOT NULL DEFAULT FALSE,
|
||||||
|
Expiration BOOLEAN NOT NULL DEFAULT FALSE, -- флаг истек ли токен
|
||||||
|
CreatedAt TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP
|
||||||
|
);
|
||||||
|
|
||||||
|
create UNIQUE INDEX idx_unique_tokens_yclients ON YclientsTokens (SalonID, AccountID) WHERE Active = false and Expiration = false;
|
||||||
|
|
||||||
CREATE TABLE IF NOT EXISTS YclientsAccounts (
|
CREATE TABLE IF NOT EXISTS YclientsAccounts (
|
||||||
ID BIGSERIAL UNIQUE NOT NULL PRIMARY KEY,
|
ID BIGSERIAL UNIQUE NOT NULL PRIMARY KEY,
|
||||||
AccountID VARCHAR(30) NOT NULL DEFAULT '', -- ID аккаунта у нас
|
AccountID VARCHAR(30) NOT NULL DEFAULT '', -- ID аккаунта у нас
|
||||||
YclientsID INT NOT NULL, -- ID "аккаунта который ГЛАВНЫЙ"
|
SalonID INT NOT NULL, -- ID компании
|
||||||
Name VARCHAR(512) NOT NULL DEFAULT '',
|
Name VARCHAR(512) NOT NULL DEFAULT '',
|
||||||
Country VARCHAR(50) NOT NULL DEFAULT '',
|
Country VARCHAR(50) NOT NULL DEFAULT '',
|
||||||
Deleted BOOLEAN NOT NULL DEFAULT FALSE,
|
Deleted BOOLEAN NOT NULL DEFAULT FALSE,
|
||||||
CreatedAt TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
CreatedAt TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP
|
||||||
Subdomain VARCHAR(50) NOT NULL DEFAULT '' -- поддомен - пример https://penadigitaltech.amocrm.ru
|
|
||||||
);
|
);
|
||||||
|
|
||||||
CREATE TABLE IF NOT EXISTS YclientsAccountUsers (
|
CREATE TABLE IF NOT EXISTS YclientsAccountUsers (
|
||||||
ID BIGSERIAL UNIQUE NOT NULL PRIMARY KEY,
|
ID BIGSERIAL UNIQUE NOT NULL PRIMARY KEY,
|
||||||
YclientsID INT NOT NULL, -- ID "аккаунта который ГЛАВНЫЙ"
|
SalonID INT NOT NULL, -- ID компании
|
||||||
YclientsCompanyID INT NOT NULL, -- ID компании
|
|
||||||
YclientsUserID INT NOT NULL, -- ID пользователя в Yclients
|
YclientsUserID INT NOT NULL, -- ID пользователя в Yclients
|
||||||
Name VARCHAR(512) NOT NULL DEFAULT '',
|
Name VARCHAR(512) NOT NULL DEFAULT '',
|
||||||
Role INT NOT NULL DEFAULT 0, -- position
|
Role INT NOT NULL DEFAULT 0, -- position
|
||||||
@ -22,8 +31,7 @@ CREATE TABLE IF NOT EXISTS YclientsAccountUsers (
|
|||||||
|
|
||||||
CREATE TABLE IF NOT EXISTS YclientsCompany (
|
CREATE TABLE IF NOT EXISTS YclientsCompany (
|
||||||
ID BIGSERIAL UNIQUE NOT NULL PRIMARY KEY,
|
ID BIGSERIAL UNIQUE NOT NULL PRIMARY KEY,
|
||||||
YclientsID INT NOT NULL, -- ID "аккаунта который ГЛАВНЫЙ"
|
SalonID INT NOT NULL, -- ID компании
|
||||||
YclientsCompanyID INT NOT NULL,
|
|
||||||
Title text NOT NULL,
|
Title text NOT NULL,
|
||||||
ShortDecription text NOT NULL,
|
ShortDecription text NOT NULL,
|
||||||
Active INT NOT NULL,
|
Active INT NOT NULL,
|
||||||
@ -35,8 +43,7 @@ CREATE TABLE IF NOT EXISTS YclientsCompany (
|
|||||||
|
|
||||||
CREATE TABLE IF NOT EXISTS YclientsServices (
|
CREATE TABLE IF NOT EXISTS YclientsServices (
|
||||||
ID BIGSERIAL UNIQUE NOT NULL PRIMARY KEY,
|
ID BIGSERIAL UNIQUE NOT NULL PRIMARY KEY,
|
||||||
YclientsID INT NOT NULL, -- ID "аккаунта который ГЛАВНЫЙ"
|
SalonID INT NOT NULL, -- ID компании
|
||||||
YclientsCompanyID INT NOT NULL, -- ID компании
|
|
||||||
ServiceID INT NOT NULL,
|
ServiceID INT NOT NULL,
|
||||||
Title text NOT NULL,
|
Title text NOT NULL,
|
||||||
CategoryID INT NOT NULL,
|
CategoryID INT NOT NULL,
|
||||||
@ -52,8 +59,7 @@ CREATE TABLE IF NOT EXISTS YclientsServices (
|
|||||||
|
|
||||||
CREATE TABLE IF NOT EXISTS YclientsTimeSlots (
|
CREATE TABLE IF NOT EXISTS YclientsTimeSlots (
|
||||||
ID BIGSERIAL UNIQUE NOT NULL PRIMARY KEY,
|
ID BIGSERIAL UNIQUE NOT NULL PRIMARY KEY,
|
||||||
YclientsID INT NOT NULL, -- ID "аккаунта который ГЛАВНЫЙ"
|
SalonID INT NOT NULL, -- ID компании
|
||||||
YclientsCompanyID INT NOT NULL, -- ID компании
|
|
||||||
IsEnabled BOOLEAN NOT NULL DEFAULT false,
|
IsEnabled BOOLEAN NOT NULL DEFAULT false,
|
||||||
WeekdaysSettings JSONB NOT NULL DEFAULT '[]',
|
WeekdaysSettings JSONB NOT NULL DEFAULT '[]',
|
||||||
DatesSettings JSONB NOT NULL DEFAULT '{}',
|
DatesSettings JSONB NOT NULL DEFAULT '{}',
|
||||||
|
|||||||
@ -400,64 +400,68 @@ type Usersamo struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type Yclientsaccount struct {
|
type Yclientsaccount struct {
|
||||||
ID int64 `db:"id" json:"id"`
|
ID int64 `db:"id" json:"id"`
|
||||||
Accountid string `db:"accountid" json:"accountid"`
|
Accountid string `db:"accountid" json:"accountid"`
|
||||||
Yclientsid int32 `db:"yclientsid" json:"yclientsid"`
|
Salonid int32 `db:"salonid" json:"salonid"`
|
||||||
Name string `db:"name" json:"name"`
|
Name string `db:"name" json:"name"`
|
||||||
Country string `db:"country" json:"country"`
|
Country string `db:"country" json:"country"`
|
||||||
Deleted bool `db:"deleted" json:"deleted"`
|
Deleted bool `db:"deleted" json:"deleted"`
|
||||||
Createdat time.Time `db:"createdat" json:"createdat"`
|
Createdat time.Time `db:"createdat" json:"createdat"`
|
||||||
Subdomain string `db:"subdomain" json:"subdomain"`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type Yclientsaccountuser struct {
|
type Yclientsaccountuser struct {
|
||||||
ID int64 `db:"id" json:"id"`
|
ID int64 `db:"id" json:"id"`
|
||||||
Yclientsid int32 `db:"yclientsid" json:"yclientsid"`
|
Salonid int32 `db:"salonid" json:"salonid"`
|
||||||
Yclientscompanyid int32 `db:"yclientscompanyid" json:"yclientscompanyid"`
|
Yclientsuserid int32 `db:"yclientsuserid" json:"yclientsuserid"`
|
||||||
Yclientsuserid int32 `db:"yclientsuserid" json:"yclientsuserid"`
|
Name string `db:"name" json:"name"`
|
||||||
Name string `db:"name" json:"name"`
|
Role int32 `db:"role" json:"role"`
|
||||||
Role int32 `db:"role" json:"role"`
|
Deleted bool `db:"deleted" json:"deleted"`
|
||||||
Deleted bool `db:"deleted" json:"deleted"`
|
Createdat time.Time `db:"createdat" json:"createdat"`
|
||||||
Createdat time.Time `db:"createdat" json:"createdat"`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type Yclientscompany struct {
|
type Yclientscompany struct {
|
||||||
ID int64 `db:"id" json:"id"`
|
ID int64 `db:"id" json:"id"`
|
||||||
Yclientsid int32 `db:"yclientsid" json:"yclientsid"`
|
Salonid int32 `db:"salonid" json:"salonid"`
|
||||||
Yclientscompanyid int32 `db:"yclientscompanyid" json:"yclientscompanyid"`
|
Title string `db:"title" json:"title"`
|
||||||
Title string `db:"title" json:"title"`
|
Shortdecription string `db:"shortdecription" json:"shortdecription"`
|
||||||
Shortdecription string `db:"shortdecription" json:"shortdecription"`
|
Active int32 `db:"active" json:"active"`
|
||||||
Active int32 `db:"active" json:"active"`
|
Country string `db:"country" json:"country"`
|
||||||
Country string `db:"country" json:"country"`
|
Grouppriority int32 `db:"grouppriority" json:"grouppriority"`
|
||||||
Grouppriority int32 `db:"grouppriority" json:"grouppriority"`
|
Deleted bool `db:"deleted" json:"deleted"`
|
||||||
Deleted bool `db:"deleted" json:"deleted"`
|
Createdat time.Time `db:"createdat" json:"createdat"`
|
||||||
Createdat time.Time `db:"createdat" json:"createdat"`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type Yclientsservice struct {
|
type Yclientsservice struct {
|
||||||
ID int64 `db:"id" json:"id"`
|
ID int64 `db:"id" json:"id"`
|
||||||
Yclientsid int32 `db:"yclientsid" json:"yclientsid"`
|
Salonid int32 `db:"salonid" json:"salonid"`
|
||||||
Yclientscompanyid int32 `db:"yclientscompanyid" json:"yclientscompanyid"`
|
Serviceid int32 `db:"serviceid" json:"serviceid"`
|
||||||
Serviceid int32 `db:"serviceid" json:"serviceid"`
|
Title string `db:"title" json:"title"`
|
||||||
Title string `db:"title" json:"title"`
|
Categoryid int32 `db:"categoryid" json:"categoryid"`
|
||||||
Categoryid int32 `db:"categoryid" json:"categoryid"`
|
Pricemin string `db:"pricemin" json:"pricemin"`
|
||||||
Pricemin string `db:"pricemin" json:"pricemin"`
|
Pricemax string `db:"pricemax" json:"pricemax"`
|
||||||
Pricemax string `db:"pricemax" json:"pricemax"`
|
Discount string `db:"discount" json:"discount"`
|
||||||
Discount string `db:"discount" json:"discount"`
|
Comment string `db:"comment" json:"comment"`
|
||||||
Comment string `db:"comment" json:"comment"`
|
Active string `db:"active" json:"active"`
|
||||||
Active string `db:"active" json:"active"`
|
Apiid string `db:"apiid" json:"apiid"`
|
||||||
Apiid string `db:"apiid" json:"apiid"`
|
Deleted bool `db:"deleted" json:"deleted"`
|
||||||
Deleted bool `db:"deleted" json:"deleted"`
|
Createdat time.Time `db:"createdat" json:"createdat"`
|
||||||
Createdat time.Time `db:"createdat" json:"createdat"`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type Yclientstimeslot struct {
|
type Yclientstimeslot struct {
|
||||||
ID int64 `db:"id" json:"id"`
|
ID int64 `db:"id" json:"id"`
|
||||||
Yclientsid int32 `db:"yclientsid" json:"yclientsid"`
|
Salonid int32 `db:"salonid" json:"salonid"`
|
||||||
Yclientscompanyid int32 `db:"yclientscompanyid" json:"yclientscompanyid"`
|
Isenabled bool `db:"isenabled" json:"isenabled"`
|
||||||
Isenabled bool `db:"isenabled" json:"isenabled"`
|
Weekdayssettings json.RawMessage `db:"weekdayssettings" json:"weekdayssettings"`
|
||||||
Weekdayssettings json.RawMessage `db:"weekdayssettings" json:"weekdayssettings"`
|
Datessettings json.RawMessage `db:"datessettings" json:"datessettings"`
|
||||||
Datessettings json.RawMessage `db:"datessettings" json:"datessettings"`
|
Deleted bool `db:"deleted" json:"deleted"`
|
||||||
Deleted bool `db:"deleted" json:"deleted"`
|
Createdat time.Time `db:"createdat" json:"createdat"`
|
||||||
Createdat time.Time `db:"createdat" json:"createdat"`
|
}
|
||||||
|
|
||||||
|
type Yclientstoken struct {
|
||||||
|
Accountid string `db:"accountid" json:"accountid"`
|
||||||
|
Salonid int32 `db:"salonid" json:"salonid"`
|
||||||
|
Accesstoken string `db:"accesstoken" json:"accesstoken"`
|
||||||
|
Active bool `db:"active" json:"active"`
|
||||||
|
Expiration bool `db:"expiration" json:"expiration"`
|
||||||
|
Createdat time.Time `db:"createdat" json:"createdat"`
|
||||||
}
|
}
|
||||||
|
|||||||
@ -2385,11 +2385,11 @@ func (q *Queries) GetBitrixTokenById(ctx context.Context, accountid string) (Bit
|
|||||||
|
|
||||||
const getCompanyYclientsWithPagination = `-- name: GetCompanyYclientsWithPagination :many
|
const getCompanyYclientsWithPagination = `-- name: GetCompanyYclientsWithPagination :many
|
||||||
WITH user_data AS (
|
WITH user_data AS (
|
||||||
SELECT YclientsID FROM YclientsAccounts WHERE YclientsAccounts.AccountID = $1 AND YclientsAccounts.Deleted = false
|
SELECT SalonID FROM YclientsAccounts WHERE YclientsAccounts.AccountID = $1 AND YclientsAccounts.Deleted = false
|
||||||
)
|
)
|
||||||
SELECT u.id, u.yclientsid, u.yclientscompanyid, u.title, u.shortdecription, u.active, u.country, u.grouppriority, u.deleted, u.createdat, COUNT(*) OVER() as total_count
|
SELECT u.id, u.salonid, u.title, u.shortdecription, u.active, u.country, u.grouppriority, u.deleted, u.createdat, COUNT(*) OVER() as total_count
|
||||||
FROM YclientsCompany u
|
FROM YclientsCompany u
|
||||||
JOIN user_data a ON u.YclientsID = a.YclientsID
|
JOIN user_data a ON u.SalonID = a.SalonID
|
||||||
WHERE u.Deleted = false
|
WHERE u.Deleted = false
|
||||||
ORDER BY u.ID OFFSET ($2 - 1) * $3 LIMIT $3
|
ORDER BY u.ID OFFSET ($2 - 1) * $3 LIMIT $3
|
||||||
`
|
`
|
||||||
@ -2401,17 +2401,16 @@ type GetCompanyYclientsWithPaginationParams struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type GetCompanyYclientsWithPaginationRow struct {
|
type GetCompanyYclientsWithPaginationRow struct {
|
||||||
ID int64 `db:"id" json:"id"`
|
ID int64 `db:"id" json:"id"`
|
||||||
Yclientsid int32 `db:"yclientsid" json:"yclientsid"`
|
Salonid int32 `db:"salonid" json:"salonid"`
|
||||||
Yclientscompanyid int32 `db:"yclientscompanyid" json:"yclientscompanyid"`
|
Title string `db:"title" json:"title"`
|
||||||
Title string `db:"title" json:"title"`
|
Shortdecription string `db:"shortdecription" json:"shortdecription"`
|
||||||
Shortdecription string `db:"shortdecription" json:"shortdecription"`
|
Active int32 `db:"active" json:"active"`
|
||||||
Active int32 `db:"active" json:"active"`
|
Country string `db:"country" json:"country"`
|
||||||
Country string `db:"country" json:"country"`
|
Grouppriority int32 `db:"grouppriority" json:"grouppriority"`
|
||||||
Grouppriority int32 `db:"grouppriority" json:"grouppriority"`
|
Deleted bool `db:"deleted" json:"deleted"`
|
||||||
Deleted bool `db:"deleted" json:"deleted"`
|
Createdat time.Time `db:"createdat" json:"createdat"`
|
||||||
Createdat time.Time `db:"createdat" json:"createdat"`
|
TotalCount int64 `db:"total_count" json:"total_count"`
|
||||||
TotalCount int64 `db:"total_count" json:"total_count"`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (q *Queries) GetCompanyYclientsWithPagination(ctx context.Context, arg GetCompanyYclientsWithPaginationParams) ([]GetCompanyYclientsWithPaginationRow, error) {
|
func (q *Queries) GetCompanyYclientsWithPagination(ctx context.Context, arg GetCompanyYclientsWithPaginationParams) ([]GetCompanyYclientsWithPaginationRow, error) {
|
||||||
@ -2425,8 +2424,7 @@ func (q *Queries) GetCompanyYclientsWithPagination(ctx context.Context, arg GetC
|
|||||||
var i GetCompanyYclientsWithPaginationRow
|
var i GetCompanyYclientsWithPaginationRow
|
||||||
if err := rows.Scan(
|
if err := rows.Scan(
|
||||||
&i.ID,
|
&i.ID,
|
||||||
&i.Yclientsid,
|
&i.Salonid,
|
||||||
&i.Yclientscompanyid,
|
|
||||||
&i.Title,
|
&i.Title,
|
||||||
&i.Shortdecription,
|
&i.Shortdecription,
|
||||||
&i.Active,
|
&i.Active,
|
||||||
@ -2489,21 +2487,22 @@ func (q *Queries) GetCurrentCompany(ctx context.Context, accountid string) (Acco
|
|||||||
}
|
}
|
||||||
|
|
||||||
const getCurrentYclientsCompany = `-- name: GetCurrentYclientsCompany :one
|
const getCurrentYclientsCompany = `-- name: GetCurrentYclientsCompany :one
|
||||||
SELECT id, accountid, yclientsid, name, country, deleted, createdat, subdomain FROM YclientsAccounts WHERE AccountID = $1 AND Deleted = false
|
|
||||||
|
SELECT id, accountid, salonid, name, country, deleted, createdat FROM YclientsAccounts WHERE AccountID = $1 AND Deleted = false
|
||||||
`
|
`
|
||||||
|
|
||||||
|
// Yclients
|
||||||
func (q *Queries) GetCurrentYclientsCompany(ctx context.Context, accountid string) (Yclientsaccount, error) {
|
func (q *Queries) GetCurrentYclientsCompany(ctx context.Context, accountid string) (Yclientsaccount, error) {
|
||||||
row := q.db.QueryRowContext(ctx, getCurrentYclientsCompany, accountid)
|
row := q.db.QueryRowContext(ctx, getCurrentYclientsCompany, accountid)
|
||||||
var i Yclientsaccount
|
var i Yclientsaccount
|
||||||
err := row.Scan(
|
err := row.Scan(
|
||||||
&i.ID,
|
&i.ID,
|
||||||
&i.Accountid,
|
&i.Accountid,
|
||||||
&i.Yclientsid,
|
&i.Salonid,
|
||||||
&i.Name,
|
&i.Name,
|
||||||
&i.Country,
|
&i.Country,
|
||||||
&i.Deleted,
|
&i.Deleted,
|
||||||
&i.Createdat,
|
&i.Createdat,
|
||||||
&i.Subdomain,
|
|
||||||
)
|
)
|
||||||
return i, err
|
return i, err
|
||||||
}
|
}
|
||||||
@ -3654,11 +3653,11 @@ func (q *Queries) GetResultAnswers(ctx context.Context, id int64) ([]GetResultAn
|
|||||||
|
|
||||||
const getServicesYclientsWithPagination = `-- name: GetServicesYclientsWithPagination :many
|
const getServicesYclientsWithPagination = `-- name: GetServicesYclientsWithPagination :many
|
||||||
WITH user_data AS (
|
WITH user_data AS (
|
||||||
SELECT YclientsID FROM YclientsAccounts WHERE YclientsAccounts.AccountID = $1 AND YclientsAccounts.Deleted = false
|
SELECT SalonID FROM YclientsAccounts WHERE YclientsAccounts.AccountID = $1 AND YclientsAccounts.Deleted = false
|
||||||
)
|
)
|
||||||
SELECT u.id, u.yclientsid, u.yclientscompanyid, u.serviceid, u.title, u.categoryid, u.pricemin, u.pricemax, u.discount, u.comment, u.active, u.apiid, u.deleted, u.createdat, COUNT(*) OVER() as total_count
|
SELECT u.id, u.salonid, u.serviceid, u.title, u.categoryid, u.pricemin, u.pricemax, u.discount, u.comment, u.active, u.apiid, u.deleted, u.createdat, COUNT(*) OVER() as total_count
|
||||||
FROM YclientsServices u
|
FROM YclientsServices u
|
||||||
JOIN user_data a ON u.YclientsID = a.YclientsID
|
JOIN user_data a ON u.SalonID = a.SalonID
|
||||||
WHERE u.Deleted = false
|
WHERE u.Deleted = false
|
||||||
ORDER BY u.ID OFFSET ($2 - 1) * $3 LIMIT $3
|
ORDER BY u.ID OFFSET ($2 - 1) * $3 LIMIT $3
|
||||||
`
|
`
|
||||||
@ -3670,21 +3669,20 @@ type GetServicesYclientsWithPaginationParams struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type GetServicesYclientsWithPaginationRow struct {
|
type GetServicesYclientsWithPaginationRow struct {
|
||||||
ID int64 `db:"id" json:"id"`
|
ID int64 `db:"id" json:"id"`
|
||||||
Yclientsid int32 `db:"yclientsid" json:"yclientsid"`
|
Salonid int32 `db:"salonid" json:"salonid"`
|
||||||
Yclientscompanyid int32 `db:"yclientscompanyid" json:"yclientscompanyid"`
|
Serviceid int32 `db:"serviceid" json:"serviceid"`
|
||||||
Serviceid int32 `db:"serviceid" json:"serviceid"`
|
Title string `db:"title" json:"title"`
|
||||||
Title string `db:"title" json:"title"`
|
Categoryid int32 `db:"categoryid" json:"categoryid"`
|
||||||
Categoryid int32 `db:"categoryid" json:"categoryid"`
|
Pricemin string `db:"pricemin" json:"pricemin"`
|
||||||
Pricemin string `db:"pricemin" json:"pricemin"`
|
Pricemax string `db:"pricemax" json:"pricemax"`
|
||||||
Pricemax string `db:"pricemax" json:"pricemax"`
|
Discount string `db:"discount" json:"discount"`
|
||||||
Discount string `db:"discount" json:"discount"`
|
Comment string `db:"comment" json:"comment"`
|
||||||
Comment string `db:"comment" json:"comment"`
|
Active string `db:"active" json:"active"`
|
||||||
Active string `db:"active" json:"active"`
|
Apiid string `db:"apiid" json:"apiid"`
|
||||||
Apiid string `db:"apiid" json:"apiid"`
|
Deleted bool `db:"deleted" json:"deleted"`
|
||||||
Deleted bool `db:"deleted" json:"deleted"`
|
Createdat time.Time `db:"createdat" json:"createdat"`
|
||||||
Createdat time.Time `db:"createdat" json:"createdat"`
|
TotalCount int64 `db:"total_count" json:"total_count"`
|
||||||
TotalCount int64 `db:"total_count" json:"total_count"`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (q *Queries) GetServicesYclientsWithPagination(ctx context.Context, arg GetServicesYclientsWithPaginationParams) ([]GetServicesYclientsWithPaginationRow, error) {
|
func (q *Queries) GetServicesYclientsWithPagination(ctx context.Context, arg GetServicesYclientsWithPaginationParams) ([]GetServicesYclientsWithPaginationRow, error) {
|
||||||
@ -3698,8 +3696,7 @@ func (q *Queries) GetServicesYclientsWithPagination(ctx context.Context, arg Get
|
|||||||
var i GetServicesYclientsWithPaginationRow
|
var i GetServicesYclientsWithPaginationRow
|
||||||
if err := rows.Scan(
|
if err := rows.Scan(
|
||||||
&i.ID,
|
&i.ID,
|
||||||
&i.Yclientsid,
|
&i.Salonid,
|
||||||
&i.Yclientscompanyid,
|
|
||||||
&i.Serviceid,
|
&i.Serviceid,
|
||||||
&i.Title,
|
&i.Title,
|
||||||
&i.Categoryid,
|
&i.Categoryid,
|
||||||
@ -3863,11 +3860,11 @@ func (q *Queries) GetTagsWithPagination(ctx context.Context, arg GetTagsWithPagi
|
|||||||
|
|
||||||
const getTimeslotsYclientsWithPagination = `-- name: GetTimeslotsYclientsWithPagination :many
|
const getTimeslotsYclientsWithPagination = `-- name: GetTimeslotsYclientsWithPagination :many
|
||||||
WITH user_data AS (
|
WITH user_data AS (
|
||||||
SELECT YclientsID FROM YclientsAccounts WHERE YclientsAccounts.AccountID = $1 AND YclientsAccounts.Deleted = false
|
SELECT SalonID FROM YclientsAccounts WHERE YclientsAccounts.AccountID = $1 AND YclientsAccounts.Deleted = false
|
||||||
)
|
)
|
||||||
SELECT u.id, u.yclientsid, u.yclientscompanyid, u.isenabled, u.weekdayssettings, u.datessettings, u.deleted, u.createdat, COUNT(*) OVER() as total_count
|
SELECT u.id, u.salonid, u.isenabled, u.weekdayssettings, u.datessettings, u.deleted, u.createdat, COUNT(*) OVER() as total_count
|
||||||
FROM YclientsTimeSlots u
|
FROM YclientsTimeSlots u
|
||||||
JOIN user_data a ON u.YclientsID = a.YclientsID
|
JOIN user_data a ON u.SalonID = a.SalonID
|
||||||
WHERE u.Deleted = false
|
WHERE u.Deleted = false
|
||||||
ORDER BY u.ID OFFSET ($2 - 1) * $3 LIMIT $3
|
ORDER BY u.ID OFFSET ($2 - 1) * $3 LIMIT $3
|
||||||
`
|
`
|
||||||
@ -3879,15 +3876,14 @@ type GetTimeslotsYclientsWithPaginationParams struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type GetTimeslotsYclientsWithPaginationRow struct {
|
type GetTimeslotsYclientsWithPaginationRow struct {
|
||||||
ID int64 `db:"id" json:"id"`
|
ID int64 `db:"id" json:"id"`
|
||||||
Yclientsid int32 `db:"yclientsid" json:"yclientsid"`
|
Salonid int32 `db:"salonid" json:"salonid"`
|
||||||
Yclientscompanyid int32 `db:"yclientscompanyid" json:"yclientscompanyid"`
|
Isenabled bool `db:"isenabled" json:"isenabled"`
|
||||||
Isenabled bool `db:"isenabled" json:"isenabled"`
|
Weekdayssettings json.RawMessage `db:"weekdayssettings" json:"weekdayssettings"`
|
||||||
Weekdayssettings json.RawMessage `db:"weekdayssettings" json:"weekdayssettings"`
|
Datessettings json.RawMessage `db:"datessettings" json:"datessettings"`
|
||||||
Datessettings json.RawMessage `db:"datessettings" json:"datessettings"`
|
Deleted bool `db:"deleted" json:"deleted"`
|
||||||
Deleted bool `db:"deleted" json:"deleted"`
|
Createdat time.Time `db:"createdat" json:"createdat"`
|
||||||
Createdat time.Time `db:"createdat" json:"createdat"`
|
TotalCount int64 `db:"total_count" json:"total_count"`
|
||||||
TotalCount int64 `db:"total_count" json:"total_count"`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (q *Queries) GetTimeslotsYclientsWithPagination(ctx context.Context, arg GetTimeslotsYclientsWithPaginationParams) ([]GetTimeslotsYclientsWithPaginationRow, error) {
|
func (q *Queries) GetTimeslotsYclientsWithPagination(ctx context.Context, arg GetTimeslotsYclientsWithPaginationParams) ([]GetTimeslotsYclientsWithPaginationRow, error) {
|
||||||
@ -3901,8 +3897,7 @@ func (q *Queries) GetTimeslotsYclientsWithPagination(ctx context.Context, arg Ge
|
|||||||
var i GetTimeslotsYclientsWithPaginationRow
|
var i GetTimeslotsYclientsWithPaginationRow
|
||||||
if err := rows.Scan(
|
if err := rows.Scan(
|
||||||
&i.ID,
|
&i.ID,
|
||||||
&i.Yclientsid,
|
&i.Salonid,
|
||||||
&i.Yclientscompanyid,
|
|
||||||
&i.Isenabled,
|
&i.Isenabled,
|
||||||
&i.Weekdayssettings,
|
&i.Weekdayssettings,
|
||||||
&i.Datessettings,
|
&i.Datessettings,
|
||||||
@ -4447,11 +4442,11 @@ func (q *Queries) GetUsersWithPagination(ctx context.Context, arg GetUsersWithPa
|
|||||||
|
|
||||||
const getUsersYclientsWithPagination = `-- name: GetUsersYclientsWithPagination :many
|
const getUsersYclientsWithPagination = `-- name: GetUsersYclientsWithPagination :many
|
||||||
WITH user_data AS (
|
WITH user_data AS (
|
||||||
SELECT YclientsID FROM YclientsAccounts WHERE YclientsAccounts.AccountID = $1 AND YclientsAccounts.Deleted = false
|
SELECT SalonID FROM YclientsAccounts WHERE YclientsAccounts.AccountID = $1 AND YclientsAccounts.Deleted = false
|
||||||
)
|
)
|
||||||
SELECT u.id, u.yclientsid, u.yclientscompanyid, u.yclientsuserid, u.name, u.role, u.deleted, u.createdat, COUNT(*) OVER() as total_count
|
SELECT u.id, u.salonid, u.yclientsuserid, u.name, u.role, u.deleted, u.createdat, COUNT(*) OVER() as total_count
|
||||||
FROM YclientsAccountUsers u
|
FROM YclientsAccountUsers u
|
||||||
JOIN user_data a ON u.YclientsID = a.YclientsID
|
JOIN user_data a ON u.SalonID = a.SalonID
|
||||||
WHERE u.Deleted = false
|
WHERE u.Deleted = false
|
||||||
ORDER BY u.ID OFFSET ($2 - 1) * $3 LIMIT $3
|
ORDER BY u.ID OFFSET ($2 - 1) * $3 LIMIT $3
|
||||||
`
|
`
|
||||||
@ -4463,15 +4458,14 @@ type GetUsersYclientsWithPaginationParams struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type GetUsersYclientsWithPaginationRow struct {
|
type GetUsersYclientsWithPaginationRow struct {
|
||||||
ID int64 `db:"id" json:"id"`
|
ID int64 `db:"id" json:"id"`
|
||||||
Yclientsid int32 `db:"yclientsid" json:"yclientsid"`
|
Salonid int32 `db:"salonid" json:"salonid"`
|
||||||
Yclientscompanyid int32 `db:"yclientscompanyid" json:"yclientscompanyid"`
|
Yclientsuserid int32 `db:"yclientsuserid" json:"yclientsuserid"`
|
||||||
Yclientsuserid int32 `db:"yclientsuserid" json:"yclientsuserid"`
|
Name string `db:"name" json:"name"`
|
||||||
Name string `db:"name" json:"name"`
|
Role int32 `db:"role" json:"role"`
|
||||||
Role int32 `db:"role" json:"role"`
|
Deleted bool `db:"deleted" json:"deleted"`
|
||||||
Deleted bool `db:"deleted" json:"deleted"`
|
Createdat time.Time `db:"createdat" json:"createdat"`
|
||||||
Createdat time.Time `db:"createdat" json:"createdat"`
|
TotalCount int64 `db:"total_count" json:"total_count"`
|
||||||
TotalCount int64 `db:"total_count" json:"total_count"`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (q *Queries) GetUsersYclientsWithPagination(ctx context.Context, arg GetUsersYclientsWithPaginationParams) ([]GetUsersYclientsWithPaginationRow, error) {
|
func (q *Queries) GetUsersYclientsWithPagination(ctx context.Context, arg GetUsersYclientsWithPaginationParams) ([]GetUsersYclientsWithPaginationRow, error) {
|
||||||
@ -4485,8 +4479,7 @@ func (q *Queries) GetUsersYclientsWithPagination(ctx context.Context, arg GetUse
|
|||||||
var i GetUsersYclientsWithPaginationRow
|
var i GetUsersYclientsWithPaginationRow
|
||||||
if err := rows.Scan(
|
if err := rows.Scan(
|
||||||
&i.ID,
|
&i.ID,
|
||||||
&i.Yclientsid,
|
&i.Salonid,
|
||||||
&i.Yclientscompanyid,
|
|
||||||
&i.Yclientsuserid,
|
&i.Yclientsuserid,
|
||||||
&i.Name,
|
&i.Name,
|
||||||
&i.Role,
|
&i.Role,
|
||||||
@ -4507,6 +4500,24 @@ func (q *Queries) GetUsersYclientsWithPagination(ctx context.Context, arg GetUse
|
|||||||
return items, nil
|
return items, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const getYclientsUserToken = `-- name: GetYclientsUserToken :one
|
||||||
|
select accountid, salonid, accesstoken, active, expiration, createdat from YclientsTokens where AccountID = $1 and Expiration=false and Active = true
|
||||||
|
`
|
||||||
|
|
||||||
|
func (q *Queries) GetYclientsUserToken(ctx context.Context, accountid string) (Yclientstoken, error) {
|
||||||
|
row := q.db.QueryRowContext(ctx, getYclientsUserToken, accountid)
|
||||||
|
var i Yclientstoken
|
||||||
|
err := row.Scan(
|
||||||
|
&i.Accountid,
|
||||||
|
&i.Salonid,
|
||||||
|
&i.Accesstoken,
|
||||||
|
&i.Active,
|
||||||
|
&i.Expiration,
|
||||||
|
&i.Createdat,
|
||||||
|
)
|
||||||
|
return i, err
|
||||||
|
}
|
||||||
|
|
||||||
const gettingAmoUsersTrueResults = `-- name: GettingAmoUsersTrueResults :many
|
const gettingAmoUsersTrueResults = `-- name: GettingAmoUsersTrueResults :many
|
||||||
SELECT a.quiz_id,a.id,a.result,a.question_id,a.content,a.session,
|
SELECT a.quiz_id,a.id,a.result,a.question_id,a.content,a.session,
|
||||||
COALESCE((SELECT a2.utm
|
COALESCE((SELECT a2.utm
|
||||||
@ -5002,6 +5013,29 @@ func (q *Queries) InsertQuizPrivilegeUsage(ctx context.Context, arg InsertQuizPr
|
|||||||
return i, err
|
return i, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const insertYclientsTokens = `-- name: InsertYclientsTokens :one
|
||||||
|
insert into YclientsTokens (AccountID,SalonID) values($1,$2) RETURNING accountid, salonid, accesstoken, active, expiration, createdat
|
||||||
|
`
|
||||||
|
|
||||||
|
type InsertYclientsTokensParams struct {
|
||||||
|
Accountid string `db:"accountid" json:"accountid"`
|
||||||
|
Salonid int32 `db:"salonid" json:"salonid"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (q *Queries) InsertYclientsTokens(ctx context.Context, arg InsertYclientsTokensParams) (Yclientstoken, error) {
|
||||||
|
row := q.db.QueryRowContext(ctx, insertYclientsTokens, arg.Accountid, arg.Salonid)
|
||||||
|
var i Yclientstoken
|
||||||
|
err := row.Scan(
|
||||||
|
&i.Accountid,
|
||||||
|
&i.Salonid,
|
||||||
|
&i.Accesstoken,
|
||||||
|
&i.Active,
|
||||||
|
&i.Expiration,
|
||||||
|
&i.Createdat,
|
||||||
|
)
|
||||||
|
return i, err
|
||||||
|
}
|
||||||
|
|
||||||
const moveToHistory = `-- name: MoveToHistory :one
|
const moveToHistory = `-- name: MoveToHistory :one
|
||||||
INSERT INTO question(
|
INSERT INTO question(
|
||||||
quiz_id, title, description, questiontype, required,
|
quiz_id, title, description, questiontype, required,
|
||||||
@ -5849,6 +5883,54 @@ func (q *Queries) UpdateTags(ctx context.Context, dollar_1 json.RawMessage) erro
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const updateYclientsTokensAccessToken = `-- name: UpdateYclientsTokensAccessToken :one
|
||||||
|
update YclientsTokens set AccessToken = $1, Active = true where AccountID = $2 and SalonID = $3 and Expiration = false RETURNING accountid, salonid, accesstoken, active, expiration, createdat
|
||||||
|
`
|
||||||
|
|
||||||
|
type UpdateYclientsTokensAccessTokenParams struct {
|
||||||
|
Accesstoken string `db:"accesstoken" json:"accesstoken"`
|
||||||
|
Accountid string `db:"accountid" json:"accountid"`
|
||||||
|
Salonid int32 `db:"salonid" json:"salonid"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (q *Queries) UpdateYclientsTokensAccessToken(ctx context.Context, arg UpdateYclientsTokensAccessTokenParams) (Yclientstoken, error) {
|
||||||
|
row := q.db.QueryRowContext(ctx, updateYclientsTokensAccessToken, arg.Accesstoken, arg.Accountid, arg.Salonid)
|
||||||
|
var i Yclientstoken
|
||||||
|
err := row.Scan(
|
||||||
|
&i.Accountid,
|
||||||
|
&i.Salonid,
|
||||||
|
&i.Accesstoken,
|
||||||
|
&i.Active,
|
||||||
|
&i.Expiration,
|
||||||
|
&i.Createdat,
|
||||||
|
)
|
||||||
|
return i, err
|
||||||
|
}
|
||||||
|
|
||||||
|
const updateYclientsTokensExpiration = `-- name: UpdateYclientsTokensExpiration :one
|
||||||
|
update YclientsTokens set Expiration=$1, Active = $2 where AccountID = $3 RETURNING accountid, salonid, accesstoken, active, expiration, createdat
|
||||||
|
`
|
||||||
|
|
||||||
|
type UpdateYclientsTokensExpirationParams struct {
|
||||||
|
Expiration bool `db:"expiration" json:"expiration"`
|
||||||
|
Active bool `db:"active" json:"active"`
|
||||||
|
Accountid string `db:"accountid" json:"accountid"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (q *Queries) UpdateYclientsTokensExpiration(ctx context.Context, arg UpdateYclientsTokensExpirationParams) (Yclientstoken, error) {
|
||||||
|
row := q.db.QueryRowContext(ctx, updateYclientsTokensExpiration, arg.Expiration, arg.Active, arg.Accountid)
|
||||||
|
var i Yclientstoken
|
||||||
|
err := row.Scan(
|
||||||
|
&i.Accountid,
|
||||||
|
&i.Salonid,
|
||||||
|
&i.Accesstoken,
|
||||||
|
&i.Active,
|
||||||
|
&i.Expiration,
|
||||||
|
&i.Createdat,
|
||||||
|
)
|
||||||
|
return i, err
|
||||||
|
}
|
||||||
|
|
||||||
const updatingDealAmoStatus = `-- name: UpdatingDealAmoStatus :exec
|
const updatingDealAmoStatus = `-- name: UpdatingDealAmoStatus :exec
|
||||||
UPDATE amoCRMStatuses SET Status = $1
|
UPDATE amoCRMStatuses SET Status = $1
|
||||||
WHERE DealID = $2 AND AccountID = (SELECT u.AmoID FROM tokens AS t JOIN accountsAmo AS u ON t.AccountID = u.AccountID WHERE t.AccessToken = $3 AND u.Deleted = false)
|
WHERE DealID = $2 AND AccountID = (SELECT u.AmoID FROM tokens AS t JOIN accountsAmo AS u ON t.AccountID = u.AccountID WHERE t.AccessToken = $3 AND u.Deleted = false)
|
||||||
|
|||||||
@ -2,27 +2,34 @@ package model
|
|||||||
|
|
||||||
import "time"
|
import "time"
|
||||||
|
|
||||||
|
type YclientsToken struct {
|
||||||
|
AccountID string `json:"accountID"` // ID аккаунта нас
|
||||||
|
SalonID int32 `json:"salon_id"` // ID "аккаунта который ГЛАВНЫЙ"
|
||||||
|
AccessToken string `json:"access_token"`
|
||||||
|
Active bool `json:"active"`
|
||||||
|
Expiration bool `json:"expiration"`
|
||||||
|
CreatedAt time.Time `json:"createdAt"`
|
||||||
|
}
|
||||||
|
|
||||||
type YclientsAccount struct {
|
type YclientsAccount struct {
|
||||||
ID int64 `json:"id"`
|
ID int64 `json:"id"`
|
||||||
AccountID string `json:"accountID"` // ID аккаунта нас
|
AccountID string `json:"accountID"` // ID аккаунта нас
|
||||||
YclientsID int32 `json:"yclientsID"` // ID "аккаунта который ГЛАВНЫЙ"
|
SalonID int32 `json:"salon_id"` // ID "аккаунта который ГЛАВНЫЙ"
|
||||||
Name string `json:"name"`
|
Name string `json:"name"`
|
||||||
Country string `json:"country"`
|
Country string `json:"country"`
|
||||||
Deleted bool `json:"deleted"`
|
Deleted bool `json:"deleted"`
|
||||||
CreatedAt time.Time `json:"createdAt"`
|
CreatedAt time.Time `json:"createdAt"`
|
||||||
Subdomain string `json:"subdomain"`
|
Stale bool `json:"stale"`
|
||||||
Stale bool `json:"stale"`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type YclientsAccountUser struct {
|
type YclientsAccountUser struct {
|
||||||
ID int64 `json:"id"`
|
ID int64 `json:"id"`
|
||||||
YclientsID int32 `json:"yclientsID"` // ID "аккаунта который ГЛАВНЫЙ"
|
SalonID int32 `json:"salon_id"` // ID "аккаунта который ГЛАВНЫЙ"
|
||||||
YclientsCompanyID int32 `json:"yclientsCompanyID"` // ID компании
|
YclientsUserID int32 `json:"yclientsUserID"`
|
||||||
YclientsUserID int32 `json:"yclientsUserID"`
|
Name string `json:"name"`
|
||||||
Name string `json:"name"`
|
Role int32 `json:"role"`
|
||||||
Role int32 `json:"role"`
|
Deleted bool `json:"deleted"`
|
||||||
Deleted bool `json:"deleted"`
|
CreatedAt time.Time `json:"createdAt"`
|
||||||
CreatedAt time.Time `json:"createdAt"`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type UserListYclientsResp struct {
|
type UserListYclientsResp struct {
|
||||||
@ -31,16 +38,15 @@ type UserListYclientsResp struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type YclientsCompany struct {
|
type YclientsCompany struct {
|
||||||
ID int64 `json:"id"`
|
ID int64 `json:"id"`
|
||||||
YclientsID int32 `json:"yclientsID"` // ID "аккаунта который ГЛАВНЫЙ"
|
SalonID int32 `json:"salon_id"` // ID "аккаунта который ГЛАВНЫЙ"
|
||||||
YclientsCompanyID int32 `json:"yclientsCompanyID"`
|
Title string `json:"title"`
|
||||||
Title string `json:"title"`
|
ShortDecription string `json:"shortDecription"`
|
||||||
ShortDecription string `json:"shortDecription"`
|
Active int32 `json:"active"`
|
||||||
Active int32 `json:"active"`
|
Country string `json:"country"`
|
||||||
Country string `json:"country"`
|
GroupPriority int32 `json:"groupPriority"`
|
||||||
GroupPriority int32 `json:"groupPriority"`
|
Deleted bool `json:"deleted"`
|
||||||
Deleted bool `json:"deleted"`
|
CreatedAt time.Time `json:"createdAt"`
|
||||||
CreatedAt time.Time `json:"createdAt"`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type CompanyListYclientsResp struct {
|
type CompanyListYclientsResp struct {
|
||||||
@ -49,20 +55,19 @@ type CompanyListYclientsResp struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type YclientsServices struct {
|
type YclientsServices struct {
|
||||||
ID int64 `json:"id"`
|
ID int64 `json:"id"`
|
||||||
YclientsID int32 `json:"yclientsID"` // ID "аккаунта который ГЛАВНЫЙ"
|
SalonID int32 `json:"salon_id"` // ID "аккаунта который ГЛАВНЫЙ"
|
||||||
YclientsCompanyID int32 `json:"yclientsCompanyID"` // ID компании
|
ServiceID int32 `json:"serviceID"`
|
||||||
ServiceID int32 `json:"serviceID"`
|
Title string `json:"title"`
|
||||||
Title string `json:"title"`
|
CategoryID int32 `json:"categoryID"`
|
||||||
CategoryID int32 `json:"categoryID"`
|
PriceMin string `json:"priceMin"`
|
||||||
PriceMin string `json:"priceMin"`
|
PriceMax string `json:"priceMax"`
|
||||||
PriceMax string `json:"priceMax"`
|
Discount string `json:"discount"`
|
||||||
Discount string `json:"discount"`
|
Comment string `json:"comment"`
|
||||||
Comment string `json:"comment"`
|
Active string `json:"active"`
|
||||||
Active string `json:"active"`
|
ApiID string `json:"apiID"`
|
||||||
ApiID string `json:"apiID"`
|
Deleted bool `json:"deleted"`
|
||||||
Deleted bool `json:"deleted"`
|
CreatedAt time.Time `json:"createdAt"`
|
||||||
CreatedAt time.Time `json:"createdAt"`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type ServicesListYclientsResp struct {
|
type ServicesListYclientsResp struct {
|
||||||
@ -71,9 +76,8 @@ type ServicesListYclientsResp struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type Timeslots struct {
|
type Timeslots struct {
|
||||||
ID int64 `json:"id"`
|
ID int64 `json:"id"`
|
||||||
YclientsID int32 `json:"yclientsID"` // ID "аккаунта который ГЛАВНЫЙ"
|
SalonID int32 `json:"salon_id"` // ID "аккаунта который ГЛАВНЫЙ"
|
||||||
YclientsCompanyID int32 `json:"yclientsCompanyID"` // ID компании
|
|
||||||
// ниже то что используется в запросе
|
// ниже то что используется в запросе
|
||||||
IsEnabled bool `json:"is_enabled"`
|
IsEnabled bool `json:"is_enabled"`
|
||||||
WeekdaysSettings []WeekdaySetting `json:"weekdays_settings"`
|
WeekdaysSettings []WeekdaySetting `json:"weekdays_settings"`
|
||||||
|
|||||||
@ -25,6 +25,70 @@ func NewYclientsRepository(deps Deps) *YclientsRepository {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// tokens
|
||||||
|
|
||||||
|
func (r *YclientsRepository) InsertYclientsTokens(ctx context.Context, accountID string, salonID int32) error {
|
||||||
|
_, err := r.queries.InsertYclientsTokens(ctx, sqlcgen.InsertYclientsTokensParams{
|
||||||
|
Accountid: accountID,
|
||||||
|
Salonid: salonID,
|
||||||
|
})
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (r *YclientsRepository) UpdateYclientsTokensAccessToken(ctx context.Context, accountID string, salonID int32, yclientsAccessToken string) (*model.YclientsToken, error) {
|
||||||
|
row, err := r.queries.UpdateYclientsTokensAccessToken(ctx, sqlcgen.UpdateYclientsTokensAccessTokenParams{
|
||||||
|
Accountid: accountID,
|
||||||
|
Salonid: salonID,
|
||||||
|
Accesstoken: yclientsAccessToken,
|
||||||
|
})
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return &model.YclientsToken{
|
||||||
|
AccountID: row.Accountid,
|
||||||
|
SalonID: row.Salonid,
|
||||||
|
AccessToken: row.Accesstoken,
|
||||||
|
Active: row.Active,
|
||||||
|
Expiration: row.Expiration,
|
||||||
|
CreatedAt: row.Createdat,
|
||||||
|
}, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (r *YclientsRepository) UpdateYclientsTokensExpiration(ctx context.Context, accountID string, active, expiration bool) error {
|
||||||
|
_, err := r.queries.UpdateYclientsTokensExpiration(ctx, sqlcgen.UpdateYclientsTokensExpirationParams{
|
||||||
|
Accountid: accountID,
|
||||||
|
Active: active,
|
||||||
|
Expiration: expiration,
|
||||||
|
})
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (r *YclientsRepository) GetYclientsUserToken(ctx context.Context, accountID string) (*model.YclientsToken, error) {
|
||||||
|
row, err := r.queries.GetYclientsUserToken(ctx, accountID)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return &model.YclientsToken{
|
||||||
|
AccountID: row.Accountid,
|
||||||
|
SalonID: row.Salonid,
|
||||||
|
AccessToken: row.Accesstoken,
|
||||||
|
Active: row.Active,
|
||||||
|
Expiration: row.Expiration,
|
||||||
|
CreatedAt: row.Createdat,
|
||||||
|
}, err
|
||||||
|
}
|
||||||
|
|
||||||
|
// users
|
||||||
func (r *YclientsRepository) GetCurrentAccount(ctx context.Context, accountID string) (*model.YclientsAccount, error) {
|
func (r *YclientsRepository) GetCurrentAccount(ctx context.Context, accountID string) (*model.YclientsAccount, error) {
|
||||||
row, err := r.queries.GetCurrentYclientsCompany(ctx, accountID)
|
row, err := r.queries.GetCurrentYclientsCompany(ctx, accountID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -32,14 +96,13 @@ func (r *YclientsRepository) GetCurrentAccount(ctx context.Context, accountID st
|
|||||||
}
|
}
|
||||||
|
|
||||||
user := model.YclientsAccount{
|
user := model.YclientsAccount{
|
||||||
ID: row.ID,
|
ID: row.ID,
|
||||||
AccountID: row.Accountid,
|
AccountID: row.Accountid,
|
||||||
YclientsID: row.Yclientsid,
|
SalonID: row.Salonid,
|
||||||
Name: row.Name,
|
Name: row.Name,
|
||||||
Country: row.Country,
|
Country: row.Country,
|
||||||
Deleted: row.Deleted,
|
Deleted: row.Deleted,
|
||||||
CreatedAt: row.Createdat,
|
CreatedAt: row.Createdat,
|
||||||
Subdomain: row.Subdomain,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//_, err = r.queries.CheckExpiredYclientsToken(ctx, accountID)
|
//_, err = r.queries.CheckExpiredYclientsToken(ctx, accountID)
|
||||||
@ -77,14 +140,13 @@ func (r *YclientsRepository) GettingUserWithPagination(ctx context.Context, req
|
|||||||
var count int64
|
var count int64
|
||||||
for _, row := range rows {
|
for _, row := range rows {
|
||||||
users = append(users, model.YclientsAccountUser{
|
users = append(users, model.YclientsAccountUser{
|
||||||
ID: row.ID,
|
ID: row.ID,
|
||||||
YclientsID: row.Yclientsid,
|
SalonID: row.Salonid,
|
||||||
YclientsCompanyID: row.Yclientscompanyid,
|
YclientsUserID: row.Yclientsuserid,
|
||||||
YclientsUserID: row.Yclientsuserid,
|
Name: row.Name,
|
||||||
Name: row.Name,
|
Role: row.Role,
|
||||||
Role: row.Role,
|
Deleted: row.Deleted,
|
||||||
Deleted: row.Deleted,
|
CreatedAt: row.Createdat,
|
||||||
CreatedAt: row.Createdat,
|
|
||||||
})
|
})
|
||||||
count = row.TotalCount
|
count = row.TotalCount
|
||||||
}
|
}
|
||||||
@ -112,16 +174,15 @@ func (r *YclientsRepository) GettingCompanyWithPagination(ctx context.Context, r
|
|||||||
var count int64
|
var count int64
|
||||||
for _, row := range rows {
|
for _, row := range rows {
|
||||||
users = append(users, model.YclientsCompany{
|
users = append(users, model.YclientsCompany{
|
||||||
ID: row.ID,
|
ID: row.ID,
|
||||||
YclientsID: row.Yclientsid,
|
SalonID: row.Salonid,
|
||||||
YclientsCompanyID: row.Yclientscompanyid,
|
Title: row.Title,
|
||||||
Title: row.Title,
|
ShortDecription: row.Shortdecription,
|
||||||
ShortDecription: row.Shortdecription,
|
Active: row.Active,
|
||||||
Active: row.Active,
|
Country: row.Country,
|
||||||
Country: row.Country,
|
GroupPriority: row.Grouppriority,
|
||||||
GroupPriority: row.Grouppriority,
|
Deleted: row.Deleted,
|
||||||
Deleted: row.Deleted,
|
CreatedAt: row.Createdat,
|
||||||
CreatedAt: row.Createdat,
|
|
||||||
})
|
})
|
||||||
count = row.TotalCount
|
count = row.TotalCount
|
||||||
}
|
}
|
||||||
@ -154,20 +215,19 @@ func (r *YclientsRepository) GettingServicesWithPagination(ctx context.Context,
|
|||||||
var count int64
|
var count int64
|
||||||
for _, row := range rows {
|
for _, row := range rows {
|
||||||
users = append(users, model.YclientsServices{
|
users = append(users, model.YclientsServices{
|
||||||
ID: row.ID,
|
ID: row.ID,
|
||||||
YclientsID: row.Yclientsid,
|
SalonID: row.Salonid,
|
||||||
YclientsCompanyID: row.Yclientscompanyid,
|
ServiceID: row.Serviceid,
|
||||||
ServiceID: row.Serviceid,
|
Title: row.Title,
|
||||||
Title: row.Title,
|
CategoryID: row.Categoryid,
|
||||||
CategoryID: row.Categoryid,
|
PriceMin: row.Pricemin,
|
||||||
PriceMin: row.Pricemin,
|
PriceMax: row.Pricemax,
|
||||||
PriceMax: row.Pricemax,
|
Discount: row.Discount,
|
||||||
Discount: row.Discount,
|
Comment: row.Comment,
|
||||||
Comment: row.Comment,
|
Active: row.Active,
|
||||||
Active: row.Active,
|
ApiID: row.Apiid,
|
||||||
ApiID: row.Apiid,
|
Deleted: row.Deleted,
|
||||||
Deleted: row.Deleted,
|
CreatedAt: row.Createdat,
|
||||||
CreatedAt: row.Createdat,
|
|
||||||
})
|
})
|
||||||
count = row.TotalCount
|
count = row.TotalCount
|
||||||
}
|
}
|
||||||
@ -212,14 +272,13 @@ func (r *YclientsRepository) GettingTimeslotsWithPagination(ctx context.Context,
|
|||||||
}
|
}
|
||||||
|
|
||||||
users = append(users, model.Timeslots{
|
users = append(users, model.Timeslots{
|
||||||
ID: row.ID,
|
ID: row.ID,
|
||||||
YclientsID: row.Yclientsid,
|
SalonID: row.Salonid,
|
||||||
YclientsCompanyID: row.Yclientscompanyid,
|
IsEnabled: row.Isenabled,
|
||||||
IsEnabled: row.Isenabled,
|
WeekdaysSettings: weekdaysSettings,
|
||||||
WeekdaysSettings: weekdaysSettings,
|
DatesSettings: datesSettings,
|
||||||
DatesSettings: datesSettings,
|
Deleted: row.Deleted,
|
||||||
Deleted: row.Deleted,
|
CreatedAt: row.Createdat,
|
||||||
CreatedAt: row.Createdat,
|
|
||||||
})
|
})
|
||||||
count = row.TotalCount
|
count = row.TotalCount
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user