test get list user passed
This commit is contained in:
parent
c3d20a9d5f
commit
c90d1dfb31
@ -7,14 +7,12 @@ type RequestGetListUsers struct {
|
||||
|
||||
type ResponseGetListUsers struct {
|
||||
TotalItems int `json:"_total_items"`
|
||||
//Page int `json:"_page"`
|
||||
//PageCount int `json:"_page_count"`
|
||||
Links LinksSelf `json:"_links"`
|
||||
Embedded EmbeddedGetListUsers `json:"_embedded"`
|
||||
}
|
||||
|
||||
type EmbeddedGetListUsers struct {
|
||||
Users []Users `json:"users"`
|
||||
Users []Users `json:"items"`
|
||||
}
|
||||
|
||||
type SelfLink struct {
|
||||
@ -34,10 +32,9 @@ type Users struct {
|
||||
ConfirmLinkSentAt int `json:"confirm_link_sent_at"`
|
||||
Lang string `json:"lang"`
|
||||
FullName string `json:"full_name"`
|
||||
Groups Groups `json:"groups"`
|
||||
//Rights Rights `json:"rights"`
|
||||
Groups []Groups `json:"groups"`
|
||||
Links SelfLink `json:"_links"`
|
||||
Embedded Embedded `json:"_embedded"`
|
||||
Rights Rights `json:"_embedded"`
|
||||
}
|
||||
|
||||
type Rights struct {
|
||||
@ -51,9 +48,9 @@ type Rights struct {
|
||||
IsAdmin bool `json:"is_admin"`
|
||||
IsFree bool `json:"is_free"`
|
||||
IsActive bool `json:"is_active"`
|
||||
GroupID *int `json:"group_id,omitempty"`
|
||||
RoleID *int `json:"role_id,omitempty"`
|
||||
Role *string `json:"role,omitempty"`
|
||||
GroupID int `json:"group_id,omitempty"`
|
||||
RoleID int `json:"role_id,omitempty"`
|
||||
Role string `json:"role,omitempty"`
|
||||
}
|
||||
|
||||
type Leads struct {
|
||||
|
@ -34,6 +34,7 @@ func NewDataUpdaterWC(deps Deps) *DataUpdater {
|
||||
func (wc *DataUpdater) Start(ctx context.Context) {
|
||||
nextStart := calculateTime()
|
||||
ticker := time.NewTicker(time.Second * time.Duration(nextStart))
|
||||
//ticker := time.NewTicker(10 * time.Second)
|
||||
defer ticker.Stop()
|
||||
|
||||
for {
|
||||
@ -234,7 +235,6 @@ func (wc *DataUpdater) UserUpdater(ctx context.Context, allTokens []model.Token)
|
||||
for _, token := range allTokens {
|
||||
page := 1
|
||||
limit := 250
|
||||
for {
|
||||
userData, err := wc.amoClient.GetUserList(models.RequestGetListUsers{
|
||||
Page: page,
|
||||
Limit: limit,
|
||||
@ -252,7 +252,6 @@ func (wc *DataUpdater) UserUpdater(ctx context.Context, allTokens []model.Token)
|
||||
|
||||
page++
|
||||
}
|
||||
}
|
||||
|
||||
for accountID, users := range listUser {
|
||||
mainAccount, err := wc.repo.AmoRepo.GetCurrentAccount(ctx, accountID)
|
||||
@ -261,14 +260,23 @@ func (wc *DataUpdater) UserUpdater(ctx context.Context, allTokens []model.Token)
|
||||
}
|
||||
for _, user := range users {
|
||||
if user.ID == mainAccount.AmoID {
|
||||
|
||||
err := wc.repo.AmoRepo.CheckMainUser(ctx, model.User{
|
||||
Name: user.Name,
|
||||
Role: int32(user.Rights.RoleID),
|
||||
Group: int32(user.Rights.GroupID),
|
||||
Email: user.Email,
|
||||
AmoID: user.ID,
|
||||
})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
err := wc.repo.AmoRepo.CheckAndUpdateUsers(ctx, model.User{
|
||||
AmoID: user.ID,
|
||||
Name: user.FullName,
|
||||
Group: int32(*user.Embedded.Rights.GroupID),
|
||||
Role: int32(*user.Embedded.Rights.RoleID),
|
||||
Group: int32(user.Rights.GroupID),
|
||||
Role: int32(user.Rights.RoleID),
|
||||
Email: user.Email,
|
||||
Amouserid: mainAccount.Amouserid,
|
||||
})
|
||||
|
Loading…
Reference in New Issue
Block a user