added method CreateAccount and update table YclientsAccounts
This commit is contained in:
parent
c172584b98
commit
425ba10ad4
@ -1510,15 +1510,15 @@ FROM YclientsAccountUsers u
|
|||||||
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 SalonID 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.SalonID = a.SalonID
|
-- 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 (
|
||||||
@ -1550,4 +1550,7 @@ update YclientsTokens set AccessToken = $1, Active = true where AccountID = $2 a
|
|||||||
update YclientsTokens set Expiration=$1, Active = $2 where AccountID = $3 RETURNING *;
|
update YclientsTokens set Expiration=$1, Active = $2 where AccountID = $3 RETURNING *;
|
||||||
|
|
||||||
-- name: GetYclientsUserToken :one
|
-- name: GetYclientsUserToken :one
|
||||||
select * from YclientsTokens where AccountID = $1 and Expiration=false and Active = true;
|
select * from YclientsTokens where AccountID = $1 and Expiration=false and Active = true;
|
||||||
|
|
||||||
|
-- name: CreateYclientsAccount :one
|
||||||
|
insert into YclientsAccounts (AccountID,SalonID,Title,Country,ShortDecription,Active) values ($1,$2,$3,$4,$5,$6) RETURNING *;
|
||||||
@ -13,7 +13,9 @@ 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 аккаунта у нас
|
||||||
SalonID INT NOT NULL, -- ID компании
|
SalonID INT NOT NULL, -- ID компании
|
||||||
Name VARCHAR(512) NOT NULL DEFAULT '',
|
Title text NOT NULL DEFAULT '',
|
||||||
|
ShortDecription text NOT NULL DEFAULT '',
|
||||||
|
Active INT NOT NULL,
|
||||||
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
|
||||||
@ -29,17 +31,17 @@ CREATE TABLE IF NOT EXISTS YclientsAccountUsers (
|
|||||||
CreatedAt TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP
|
CreatedAt TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP
|
||||||
);
|
);
|
||||||
|
|
||||||
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,
|
||||||
SalonID INT NOT NULL, -- ID компании
|
-- SalonID INT NOT NULL, -- ID компании
|
||||||
Title text NOT NULL,
|
-- Title text NOT NULL,
|
||||||
ShortDecription text NOT NULL,
|
-- ShortDecription text NOT NULL,
|
||||||
Active INT NOT NULL,
|
-- Active INT NOT NULL,
|
||||||
Country text NOT NULL,
|
-- Country text NOT NULL,
|
||||||
GroupPriority INT NOT NULL,
|
-- GroupPriority INT NOT NULL,
|
||||||
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
|
||||||
);
|
-- );
|
||||||
|
|
||||||
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,
|
||||||
|
|||||||
@ -400,13 +400,15 @@ 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"`
|
||||||
Salonid int32 `db:"salonid" json:"salonid"`
|
Salonid int32 `db:"salonid" json:"salonid"`
|
||||||
Name string `db:"name" json:"name"`
|
Title string `db:"title" json:"title"`
|
||||||
Country string `db:"country" json:"country"`
|
Shortdecription string `db:"shortdecription" json:"shortdecription"`
|
||||||
Deleted bool `db:"deleted" json:"deleted"`
|
Active int32 `db:"active" json:"active"`
|
||||||
Createdat time.Time `db:"createdat" json:"createdat"`
|
Country string `db:"country" json:"country"`
|
||||||
|
Deleted bool `db:"deleted" json:"deleted"`
|
||||||
|
Createdat time.Time `db:"createdat" json:"createdat"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type Yclientsaccountuser struct {
|
type Yclientsaccountuser struct {
|
||||||
@ -419,18 +421,6 @@ type Yclientsaccountuser struct {
|
|||||||
Createdat time.Time `db:"createdat" json:"createdat"`
|
Createdat time.Time `db:"createdat" json:"createdat"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type Yclientscompany struct {
|
|
||||||
ID int64 `db:"id" json:"id"`
|
|
||||||
Salonid int32 `db:"salonid" json:"salonid"`
|
|
||||||
Title string `db:"title" json:"title"`
|
|
||||||
Shortdecription string `db:"shortdecription" json:"shortdecription"`
|
|
||||||
Active int32 `db:"active" json:"active"`
|
|
||||||
Country string `db:"country" json:"country"`
|
|
||||||
Grouppriority int32 `db:"grouppriority" json:"grouppriority"`
|
|
||||||
Deleted bool `db:"deleted" json:"deleted"`
|
|
||||||
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"`
|
||||||
Salonid int32 `db:"salonid" json:"salonid"`
|
Salonid int32 `db:"salonid" json:"salonid"`
|
||||||
|
|||||||
@ -1264,6 +1264,43 @@ func (q *Queries) CreateWebHook(ctx context.Context, arg CreateWebHookParams) er
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const createYclientsAccount = `-- name: CreateYclientsAccount :one
|
||||||
|
insert into YclientsAccounts (AccountID,SalonID,Title,Country,ShortDecription,Active) values ($1,$2,$3,$4,$5,$6) RETURNING id, accountid, salonid, title, shortdecription, active, country, deleted, createdat
|
||||||
|
`
|
||||||
|
|
||||||
|
type CreateYclientsAccountParams struct {
|
||||||
|
Accountid string `db:"accountid" json:"accountid"`
|
||||||
|
Salonid int32 `db:"salonid" json:"salonid"`
|
||||||
|
Title string `db:"title" json:"title"`
|
||||||
|
Country string `db:"country" json:"country"`
|
||||||
|
Shortdecription string `db:"shortdecription" json:"shortdecription"`
|
||||||
|
Active int32 `db:"active" json:"active"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (q *Queries) CreateYclientsAccount(ctx context.Context, arg CreateYclientsAccountParams) (Yclientsaccount, error) {
|
||||||
|
row := q.db.QueryRowContext(ctx, createYclientsAccount,
|
||||||
|
arg.Accountid,
|
||||||
|
arg.Salonid,
|
||||||
|
arg.Title,
|
||||||
|
arg.Country,
|
||||||
|
arg.Shortdecription,
|
||||||
|
arg.Active,
|
||||||
|
)
|
||||||
|
var i Yclientsaccount
|
||||||
|
err := row.Scan(
|
||||||
|
&i.ID,
|
||||||
|
&i.Accountid,
|
||||||
|
&i.Salonid,
|
||||||
|
&i.Title,
|
||||||
|
&i.Shortdecription,
|
||||||
|
&i.Active,
|
||||||
|
&i.Country,
|
||||||
|
&i.Deleted,
|
||||||
|
&i.Createdat,
|
||||||
|
)
|
||||||
|
return i, err
|
||||||
|
}
|
||||||
|
|
||||||
const decrementManual = `-- name: DecrementManual :one
|
const decrementManual = `-- name: DecrementManual :one
|
||||||
UPDATE privileges p SET amount = amount - 1 FROM account a
|
UPDATE privileges p SET amount = amount - 1 FROM account a
|
||||||
WHERE p.account_id = a.id AND a.user_id = $1 AND p.privilegeID = $2 AND p.amount > 0
|
WHERE p.account_id = a.id AND a.user_id = $1 AND p.privilegeID = $2 AND p.amount > 0
|
||||||
@ -2383,70 +2420,6 @@ func (q *Queries) GetBitrixTokenById(ctx context.Context, accountid string) (Bit
|
|||||||
return i, err
|
return i, err
|
||||||
}
|
}
|
||||||
|
|
||||||
const getCompanyYclientsWithPagination = `-- name: GetCompanyYclientsWithPagination :many
|
|
||||||
WITH user_data AS (
|
|
||||||
SELECT SalonID FROM YclientsAccounts WHERE YclientsAccounts.AccountID = $1 AND YclientsAccounts.Deleted = false
|
|
||||||
)
|
|
||||||
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
|
|
||||||
JOIN user_data a ON u.SalonID = a.SalonID
|
|
||||||
WHERE u.Deleted = false
|
|
||||||
ORDER BY u.ID OFFSET ($2 - 1) * $3 LIMIT $3
|
|
||||||
`
|
|
||||||
|
|
||||||
type GetCompanyYclientsWithPaginationParams struct {
|
|
||||||
Accountid string `db:"accountid" json:"accountid"`
|
|
||||||
Column2 interface{} `db:"column_2" json:"column_2"`
|
|
||||||
Limit int32 `db:"limit" json:"limit"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type GetCompanyYclientsWithPaginationRow struct {
|
|
||||||
ID int64 `db:"id" json:"id"`
|
|
||||||
Salonid int32 `db:"salonid" json:"salonid"`
|
|
||||||
Title string `db:"title" json:"title"`
|
|
||||||
Shortdecription string `db:"shortdecription" json:"shortdecription"`
|
|
||||||
Active int32 `db:"active" json:"active"`
|
|
||||||
Country string `db:"country" json:"country"`
|
|
||||||
Grouppriority int32 `db:"grouppriority" json:"grouppriority"`
|
|
||||||
Deleted bool `db:"deleted" json:"deleted"`
|
|
||||||
Createdat time.Time `db:"createdat" json:"createdat"`
|
|
||||||
TotalCount int64 `db:"total_count" json:"total_count"`
|
|
||||||
}
|
|
||||||
|
|
||||||
func (q *Queries) GetCompanyYclientsWithPagination(ctx context.Context, arg GetCompanyYclientsWithPaginationParams) ([]GetCompanyYclientsWithPaginationRow, error) {
|
|
||||||
rows, err := q.db.QueryContext(ctx, getCompanyYclientsWithPagination, arg.Accountid, arg.Column2, arg.Limit)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
defer rows.Close()
|
|
||||||
var items []GetCompanyYclientsWithPaginationRow
|
|
||||||
for rows.Next() {
|
|
||||||
var i GetCompanyYclientsWithPaginationRow
|
|
||||||
if err := rows.Scan(
|
|
||||||
&i.ID,
|
|
||||||
&i.Salonid,
|
|
||||||
&i.Title,
|
|
||||||
&i.Shortdecription,
|
|
||||||
&i.Active,
|
|
||||||
&i.Country,
|
|
||||||
&i.Grouppriority,
|
|
||||||
&i.Deleted,
|
|
||||||
&i.Createdat,
|
|
||||||
&i.TotalCount,
|
|
||||||
); 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 getCurrentBitrixCompany = `-- name: GetCurrentBitrixCompany :one
|
const getCurrentBitrixCompany = `-- name: GetCurrentBitrixCompany :one
|
||||||
SELECT id, accountid, bitrixid, deleted, createdat, subdomain FROM BitrixAccounts WHERE AccountID = $1 AND Deleted = false
|
SELECT id, accountid, bitrixid, deleted, createdat, subdomain FROM BitrixAccounts WHERE AccountID = $1 AND Deleted = false
|
||||||
`
|
`
|
||||||
@ -2488,7 +2461,7 @@ func (q *Queries) GetCurrentCompany(ctx context.Context, accountid string) (Acco
|
|||||||
|
|
||||||
const getCurrentYclientsCompany = `-- name: GetCurrentYclientsCompany :one
|
const getCurrentYclientsCompany = `-- name: GetCurrentYclientsCompany :one
|
||||||
|
|
||||||
SELECT id, accountid, salonid, name, country, deleted, createdat FROM YclientsAccounts WHERE AccountID = $1 AND Deleted = false
|
SELECT id, accountid, salonid, title, shortdecription, active, country, deleted, createdat FROM YclientsAccounts WHERE AccountID = $1 AND Deleted = false
|
||||||
`
|
`
|
||||||
|
|
||||||
// Yclients
|
// Yclients
|
||||||
@ -2499,7 +2472,9 @@ func (q *Queries) GetCurrentYclientsCompany(ctx context.Context, accountid strin
|
|||||||
&i.ID,
|
&i.ID,
|
||||||
&i.Accountid,
|
&i.Accountid,
|
||||||
&i.Salonid,
|
&i.Salonid,
|
||||||
&i.Name,
|
&i.Title,
|
||||||
|
&i.Shortdecription,
|
||||||
|
&i.Active,
|
||||||
&i.Country,
|
&i.Country,
|
||||||
&i.Deleted,
|
&i.Deleted,
|
||||||
&i.Createdat,
|
&i.Createdat,
|
||||||
@ -3652,6 +3627,7 @@ 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 SalonID FROM YclientsAccounts WHERE YclientsAccounts.AccountID = $1 AND YclientsAccounts.Deleted = false
|
SELECT SalonID FROM YclientsAccounts WHERE YclientsAccounts.AccountID = $1 AND YclientsAccounts.Deleted = false
|
||||||
)
|
)
|
||||||
@ -3685,6 +3661,15 @@ type GetServicesYclientsWithPaginationRow struct {
|
|||||||
TotalCount int64 `db:"total_count" json:"total_count"`
|
TotalCount int64 `db:"total_count" json:"total_count"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// -- name: GetCompanyYclientsWithPagination :many
|
||||||
|
// WITH user_data AS (
|
||||||
|
// SELECT SalonID FROM YclientsAccounts WHERE YclientsAccounts.AccountID = $1 AND YclientsAccounts.Deleted = false
|
||||||
|
// )
|
||||||
|
// SELECT u.*, COUNT(*) OVER() as total_count
|
||||||
|
// FROM YclientsCompany u
|
||||||
|
// JOIN user_data a ON u.SalonID = a.SalonID
|
||||||
|
// WHERE u.Deleted = false
|
||||||
|
// ORDER BY u.ID OFFSET ($2 - 1) * $3 LIMIT $3;
|
||||||
func (q *Queries) GetServicesYclientsWithPagination(ctx context.Context, arg GetServicesYclientsWithPaginationParams) ([]GetServicesYclientsWithPaginationRow, error) {
|
func (q *Queries) GetServicesYclientsWithPagination(ctx context.Context, arg GetServicesYclientsWithPaginationParams) ([]GetServicesYclientsWithPaginationRow, error) {
|
||||||
rows, err := q.db.QueryContext(ctx, getServicesYclientsWithPagination, arg.Accountid, arg.Column2, arg.Limit)
|
rows, err := q.db.QueryContext(ctx, getServicesYclientsWithPagination, arg.Accountid, arg.Column2, arg.Limit)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
@ -12,14 +12,16 @@ type YclientsToken struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type YclientsAccount struct {
|
type YclientsAccount struct {
|
||||||
ID int64 `json:"id"`
|
ID int64 `json:"id"`
|
||||||
AccountID string `json:"accountID"` // ID аккаунта нас
|
AccountID string `json:"accountID"` // ID аккаунта нас
|
||||||
SalonID int32 `json:"salon_id"` // ID "аккаунта который ГЛАВНЫЙ"
|
SalonID int32 `json:"salon_id"` // ID "аккаунта который ГЛАВНЫЙ"
|
||||||
Name string `json:"name"`
|
Title string `json:"title"`
|
||||||
Country string `json:"country"`
|
ShortDecription string `json:"shortDecription"`
|
||||||
Deleted bool `json:"deleted"`
|
Active int32 `json:"active"`
|
||||||
CreatedAt time.Time `json:"createdAt"`
|
Country string `json:"country"`
|
||||||
Stale bool `json:"stale"`
|
Deleted bool `json:"deleted"`
|
||||||
|
CreatedAt time.Time `json:"createdAt"`
|
||||||
|
Stale bool `json:"stale"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type YclientsAccountUser struct {
|
type YclientsAccountUser struct {
|
||||||
@ -37,22 +39,22 @@ type UserListYclientsResp struct {
|
|||||||
Items []YclientsAccountUser `json:"items"`
|
Items []YclientsAccountUser `json:"items"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type YclientsCompany struct {
|
//type YclientsCompany struct {
|
||||||
ID int64 `json:"id"`
|
// ID int64 `json:"id"`
|
||||||
SalonID int32 `json:"salon_id"` // ID "аккаунта который ГЛАВНЫЙ"
|
// SalonID int32 `json:"salon_id"` // ID "аккаунта который ГЛАВНЫЙ"
|
||||||
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 {
|
||||||
Count int64 `json:"count"`
|
// Count int64 `json:"count"`
|
||||||
Items []YclientsCompany `json:"items"`
|
// Items []YclientsCompany `json:"items"`
|
||||||
}
|
//}
|
||||||
|
|
||||||
type YclientsServices struct {
|
type YclientsServices struct {
|
||||||
ID int64 `json:"id"`
|
ID int64 `json:"id"`
|
||||||
|
|||||||
@ -103,25 +103,27 @@ 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,
|
||||||
SalonID: row.Salonid,
|
SalonID: row.Salonid,
|
||||||
Name: row.Name,
|
Title: row.Title,
|
||||||
Country: row.Country,
|
Country: row.Country,
|
||||||
Deleted: row.Deleted,
|
ShortDecription: row.Shortdecription,
|
||||||
CreatedAt: row.Createdat,
|
Active: row.Active,
|
||||||
|
Deleted: row.Deleted,
|
||||||
|
CreatedAt: row.Createdat,
|
||||||
}
|
}
|
||||||
|
|
||||||
//_, err = r.queries.CheckExpiredYclientsToken(ctx, accountID)
|
_, err = r.GetYclientsUserToken(ctx, accountID)
|
||||||
//if err != nil {
|
if err != nil {
|
||||||
// if err == sql.ErrNoRows {
|
if err == sql.ErrNoRows {
|
||||||
// user.Stale = false
|
user.Stale = true
|
||||||
// return &user, nil
|
return &user, nil
|
||||||
// }
|
}
|
||||||
// return nil, err
|
return nil, err
|
||||||
//}
|
}
|
||||||
|
|
||||||
user.Stale = true
|
user.Stale = false
|
||||||
|
|
||||||
return &user, nil
|
return &user, nil
|
||||||
}
|
}
|
||||||
@ -166,47 +168,72 @@ func (r *YclientsRepository) GettingUserWithPagination(ctx context.Context, req
|
|||||||
return &resp, nil
|
return &resp, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// company
|
func (r *YclientsRepository) CreateAccount(ctx context.Context, account model.YclientsAccount) (*model.YclientsAccount, error) {
|
||||||
|
row, err := r.queries.CreateYclientsAccount(ctx, sqlcgen.CreateYclientsAccountParams{
|
||||||
func (r *YclientsRepository) GettingCompanyWithPagination(ctx context.Context, req *model.PaginationReq, accountID string) (*model.CompanyListYclientsResp, error) {
|
Accountid: account.AccountID,
|
||||||
rows, err := r.queries.GetCompanyYclientsWithPagination(ctx, sqlcgen.GetCompanyYclientsWithPaginationParams{
|
Salonid: account.SalonID,
|
||||||
Accountid: accountID,
|
Title: account.Title,
|
||||||
Column2: req.Page,
|
Country: account.Country,
|
||||||
Limit: req.Size,
|
Shortdecription: account.ShortDecription,
|
||||||
|
Active: account.Active,
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
var users []model.YclientsCompany
|
|
||||||
var count int64
|
|
||||||
for _, row := range rows {
|
|
||||||
users = append(users, model.YclientsCompany{
|
|
||||||
ID: row.ID,
|
|
||||||
SalonID: row.Salonid,
|
|
||||||
Title: row.Title,
|
|
||||||
ShortDecription: row.Shortdecription,
|
|
||||||
Active: row.Active,
|
|
||||||
Country: row.Country,
|
|
||||||
GroupPriority: row.Grouppriority,
|
|
||||||
Deleted: row.Deleted,
|
|
||||||
CreatedAt: row.Createdat,
|
|
||||||
})
|
|
||||||
count = row.TotalCount
|
|
||||||
}
|
|
||||||
|
|
||||||
resp := model.CompanyListYclientsResp{
|
return &model.YclientsAccount{
|
||||||
Count: count,
|
ID: row.ID,
|
||||||
Items: users,
|
AccountID: row.Accountid,
|
||||||
}
|
SalonID: row.Salonid,
|
||||||
|
Title: row.Title,
|
||||||
return &resp, nil
|
Country: row.Country,
|
||||||
}
|
ShortDecription: row.Shortdecription,
|
||||||
|
Active: row.Active,
|
||||||
// todo
|
Deleted: row.Deleted,
|
||||||
func (r *YclientsRepository) UpdateCompany() {
|
CreatedAt: row.Createdat,
|
||||||
|
}, nil
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// company
|
||||||
|
//func (r *YclientsRepository) GettingCompanyWithPagination(ctx context.Context, req *model.PaginationReq, accountID string) (*model.CompanyListYclientsResp, error) {
|
||||||
|
// rows, err := r.queries.GetCompanyYclientsWithPagination(ctx, sqlcgen.GetCompanyYclientsWithPaginationParams{
|
||||||
|
// Accountid: accountID,
|
||||||
|
// Column2: req.Page,
|
||||||
|
// Limit: req.Size,
|
||||||
|
// })
|
||||||
|
// if err != nil {
|
||||||
|
// return nil, err
|
||||||
|
// }
|
||||||
|
// var users []model.YclientsCompany
|
||||||
|
// var count int64
|
||||||
|
// for _, row := range rows {
|
||||||
|
// users = append(users, model.YclientsCompany{
|
||||||
|
// ID: row.ID,
|
||||||
|
// SalonID: row.Salonid,
|
||||||
|
// Title: row.Title,
|
||||||
|
// ShortDecription: row.Shortdecription,
|
||||||
|
// Active: row.Active,
|
||||||
|
// Country: row.Country,
|
||||||
|
// GroupPriority: row.Grouppriority,
|
||||||
|
// Deleted: row.Deleted,
|
||||||
|
// CreatedAt: row.Createdat,
|
||||||
|
// })
|
||||||
|
// count = row.TotalCount
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// resp := model.CompanyListYclientsResp{
|
||||||
|
// Count: count,
|
||||||
|
// Items: users,
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// return &resp, nil
|
||||||
|
//}
|
||||||
|
//
|
||||||
|
//func (r *YclientsRepository) UpdateCompany() {
|
||||||
|
//
|
||||||
|
//}
|
||||||
|
|
||||||
// services
|
// services
|
||||||
|
|
||||||
func (r *YclientsRepository) GettingServicesWithPagination(ctx context.Context, req *model.PaginationReq, accountID string) (*model.ServicesListYclientsResp, error) {
|
func (r *YclientsRepository) GettingServicesWithPagination(ctx context.Context, req *model.PaginationReq, accountID string) (*model.ServicesListYclientsResp, error) {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user