Skip to content

Commit

Permalink
#2469 用户添加分页展示&添加用户搜索
Browse files Browse the repository at this point in the history
  • Loading branch information
tangjiawei committed Nov 22, 2024
1 parent 06362ec commit a04ba4c
Showing 1 changed file with 19 additions and 21 deletions.
40 changes: 19 additions & 21 deletions platform-auth-server/service/user_management_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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
Expand Down

0 comments on commit a04ba4c

Please sign in to comment.