diff --git a/platform-auth-server/service/user_management_service.go b/platform-auth-server/service/user_management_service.go index 2c8e7ba2ab..b1ae34a527 100644 --- a/platform-auth-server/service/user_management_service.go +++ b/platform-auth-server/service/user_management_service.go @@ -810,38 +810,36 @@ func (UserManagementService) RetrieveAllActiveUsers() ([]*model.SimpleLocalUserD } func (UserManagementService) QueryUserPage(param model.QueryUserParam) (page model.PageInfo, data []*model.SimpleLocalUserDto, err error) { - page.PageSize = param.Pageable.PageSize - page.StartIndex = param.Pageable.StartIndex - count, userEntities, err := db.UserRepositoryInstance.QueryUsers(param) - if err != nil { + page = model.PageInfo{ + StartIndex: param.Pageable.StartIndex, + PageSize: param.Pageable.StartIndex, + } + var count int + var userEntities []*model.SysUserEntity + if count, userEntities, err = db.UserRepositoryInstance.QueryUsers(param); err != nil { log.Logger.Error("failed to find all active users", log.Error(err)) - return page, nil, err + return } page.TotalRows = count result := make([]*model.SimpleLocalUserDto, 0) if len(userEntities) == 0 { - return page, nil, nil + return } for _, user := range userEntities { userDto := convertToSimpleLocalUserDto(user, "") - - userRoles, err := db.UserRoleRsRepositoryInstance.FindAllByUserId(user.Id) - if err != nil { - log.Logger.Error("failed to find all UserRoleRs", log.String("userId", user.Id), - log.Error(err)) - return page, nil, err + var userRoles []*model.UserRoleRsEntity + if userRoles, err = db.UserRoleRsRepositoryInstance.FindAllByUserId(user.Id); err != nil { + log.Logger.Error("failed to find all UserRoleRs", log.String("userId", user.Id), log.Error(err)) + return } if len(userRoles) > 0 { for _, userRole := range userRoles { - + var found bool role := &model.SysRoleEntity{} - found, err := db.Engine.ID(userRole.RoleId).Get(role) - if err != nil { - log.Logger.Error("failed to get role", log.String("roleId", userRole.RoleId), - log.Error(err)) - return page, nil, err + if found, err = db.Engine.ID(userRole.RoleId).Get(role); err != nil { + log.Logger.Error("failed to get role", log.String("roleId", userRole.RoleId), log.Error(err)) + return } - if found { roleDto := &model.SimpleLocalRoleDto{ ID: role.Id, @@ -850,14 +848,14 @@ func (UserManagementService) QueryUserPage(param model.QueryUserParam) (page mod Email: role.EmailAddress, Status: role.GetRoleDeletedStatus(), } - userDto.AddRoles([]*model.SimpleLocalRoleDto{roleDto}) } } } result = append(result, userDto) } - return page, result, nil + data = result + return } // @Transactional