update amo queries
This commit is contained in:
parent
92b755fde5
commit
2fe0379a67
@ -10,7 +10,7 @@ CREATE TABLE IF NOT EXISTS accountsAmo (
|
||||
CreatedAt TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
Subdomain VARCHAR(50) NOT NULL DEFAULT '', -- поддомен - пример https://penadigitaltech.amocrm.ru
|
||||
Country VARCHAR(50) NOT NULL DEFAULT '',
|
||||
DriveURL VARCHAR(255) DEFAULT '' -- URL объктного хранилища
|
||||
DriveURL VARCHAR(255) NOT NULL DEFAULT '' -- URL объктного хранилища
|
||||
);
|
||||
|
||||
CREATE UNIQUE INDEX idx_unique_accountsAmo ON accountsAmo (amoID) WHERE Deleted = false;
|
||||
|
@ -55,7 +55,7 @@ type UserListResp struct {
|
||||
/* - общее количество юзеров, которые у нас закешированы для этого пользователя*/
|
||||
Count int64 `json:"count"`
|
||||
/* - список юзеров, которые были закешированы нашим сервисом*/
|
||||
Items []User `json:"items"`
|
||||
Items []AmoAccountUser `json:"items"`
|
||||
}
|
||||
|
||||
type UserListStepsResp struct {
|
||||
|
@ -39,20 +39,18 @@ func (r *AmoRepository) GettingUserWithPagination(ctx context.Context, req *mode
|
||||
return nil, err
|
||||
}
|
||||
var count int64
|
||||
var users []model.User
|
||||
var users []model.AmoAccountUser
|
||||
for _, row := range rows {
|
||||
user := model.User{
|
||||
user := model.AmoAccountUser{
|
||||
ID: row.ID,
|
||||
Accountid: row.Accountid,
|
||||
AmoID: row.Amoid,
|
||||
AmoUserID: row.Amouserid,
|
||||
Name: row.Name,
|
||||
Email: row.Email,
|
||||
Group: row.Group,
|
||||
Role: row.Role,
|
||||
Createdat: row.Createdat.Time.Unix(),
|
||||
Subdomain: row.Subdomain,
|
||||
Amouserid: row.Amouserid,
|
||||
Country: row.Country,
|
||||
Deleted: row.Deleted,
|
||||
CreatedAt: row.Createdat,
|
||||
}
|
||||
count = row.TotalCount
|
||||
|
||||
@ -75,43 +73,35 @@ func (r *AmoRepository) SoftDeleteAccount(ctx context.Context, accountID string)
|
||||
return nil
|
||||
}
|
||||
|
||||
func (r *AmoRepository) GetCurrentAccount(ctx context.Context, accountID string) (*model.User, error) {
|
||||
row, err := r.queries.GetCurrentAccount(ctx, accountID)
|
||||
func (r *AmoRepository) GetCurrentAccount(ctx context.Context, accountID string) (*model.AmoAccount, error) {
|
||||
row, err := r.queries.GetCurrentCompany(ctx, accountID)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
user := model.User{
|
||||
user := model.AmoAccount{
|
||||
ID: row.ID,
|
||||
Accountid: row.Accountid,
|
||||
AccountID: row.Accountid,
|
||||
AmoID: row.Amoid,
|
||||
Name: row.Name,
|
||||
Email: row.Email,
|
||||
Role: row.Role,
|
||||
Group: row.Group,
|
||||
Createdat: row.Createdat.Time.Unix(),
|
||||
Deleted: row.Deleted,
|
||||
CreatedAt: row.Createdat,
|
||||
Subdomain: row.Subdomain,
|
||||
Amouserid: row.Amouserid,
|
||||
Country: row.Country,
|
||||
DriveURL: row.Driveurl,
|
||||
DriveURL: row.Driveurl.String,
|
||||
}
|
||||
|
||||
return &user, nil
|
||||
}
|
||||
|
||||
func (r *AmoRepository) CreateAccount(ctx context.Context, accountID string, userInfo model.User) error {
|
||||
func (r *AmoRepository) CreateAccount(ctx context.Context, accountID string, userInfo model.AmoAccount) error {
|
||||
err := r.queries.CreateAmoAccount(ctx, sqlcgen.CreateAmoAccountParams{
|
||||
Accountid: accountID,
|
||||
Amoid: userInfo.AmoID,
|
||||
Name: userInfo.Name,
|
||||
Email: userInfo.Email,
|
||||
Role: userInfo.Role,
|
||||
Group: userInfo.Group,
|
||||
Createdat: sql.NullTime{Time: time.Now(), Valid: true},
|
||||
Subdomain: userInfo.Subdomain,
|
||||
Amouserid: userInfo.Amouserid,
|
||||
Country: userInfo.Country,
|
||||
Driveurl: userInfo.DriveURL,
|
||||
Driveurl: sql.NullString{String: userInfo.DriveURL, Valid: true},
|
||||
})
|
||||
|
||||
if err != nil {
|
||||
|
Loading…
Reference in New Issue
Block a user