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 250ab93 commit 400b037
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 10 deletions.
5 changes: 3 additions & 2 deletions platform-auth-server/model/model.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ type PlatSystemVariablesListPageData struct {
}

type QueryUserParam struct {
Pageable *PageInfo `json:"pageable"` // 分页信息,默认为空
UserName string `json:"userName"`
UserName string `json:"userName"`
StartIndex int `json:"startIndex"`
PageSize int `json:"pageSize"`
}
8 changes: 4 additions & 4 deletions platform-auth-server/service/db/repository.go
Original file line number Diff line number Diff line change
Expand Up @@ -224,11 +224,11 @@ func (UserRepository) QueryUsers(param model.QueryUserParam) (int, []*model.SysU
var err error
var count int
if strings.TrimSpace(param.UserName) != "" {
err = Engine.Where("is_deleted = ?", false).And("is_active = ?", true).And("is_blocked = ?", false).And("username like ?", "%"+param.UserName+"%").Limit(param.Pageable.PageSize, param.Pageable.StartIndex).Find(&users)
Engine.SQL("select count(1) from auth_sys_user where is_deleted = false and is_active = true and is_blocked = false and username like ?", "%"+param.UserName+"%").Find(&count)
err = Engine.Where("is_deleted = ?", false).And("is_active = ?", true).And("is_blocked = ?", false).And("username like ?", "%"+param.UserName+"%").Limit(param.PageSize, param.StartIndex).Find(&users)
Engine.SQL("select count(1) from auth_sys_user where is_deleted = false and is_active = true and is_blocked = false and username like ?", "%"+param.UserName+"%").Get(&count)
} else {
err = Engine.Where("is_deleted = ?", false).And("is_active = ?", true).And("is_blocked = ?", false).Limit(param.Pageable.PageSize, param.Pageable.StartIndex).Find(&users)
Engine.SQL("select count(1) from auth_sys_user where is_deleted = false and is_active = true and is_blocked = false ").Find(&count)
err = Engine.Where("is_deleted = ?", false).And("is_active = ?", true).And("is_blocked = ?", false).Limit(param.PageSize, param.StartIndex).Find(&users)
Engine.SQL("select count(1) from auth_sys_user where is_deleted = false and is_active = true and is_blocked = false").Get(&count)
}
if err != nil {
return count, nil, err
Expand Down
4 changes: 2 additions & 2 deletions platform-auth-server/service/user_management_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -811,8 +811,8 @@ func (UserManagementService) RetrieveAllActiveUsers() ([]*model.SimpleLocalUserD

func (UserManagementService) QueryUserPage(param model.QueryUserParam) (page model.PageInfo, data []*model.SimpleLocalUserDto, err error) {
page = model.PageInfo{
StartIndex: param.Pageable.StartIndex,
PageSize: param.Pageable.StartIndex,
StartIndex: param.StartIndex,
PageSize: param.PageSize,
}
var count int
var userEntities []*model.SysUserEntity
Expand Down
5 changes: 3 additions & 2 deletions platform-core/models/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,9 @@ type QueryRequestParam struct {
}

type QueryUserParam struct {
Pageable *PageInfo `json:"pageable"` // 分页信息,默认为空
UserName string `json:"userName"`
UserName string `json:"userName"`
StartIndex int `json:"startIndex"`
PageSize int `json:"pageSize"`
}

type TransFiltersParam struct {
Expand Down

0 comments on commit 400b037

Please sign in to comment.