diff --git a/internal/db/models/user_dao.go b/internal/db/models/user_dao.go index da31c5e6..35ef50b1 100644 --- a/internal/db/models/user_dao.go +++ b/internal/db/models/user_dao.go @@ -202,7 +202,7 @@ func (this *UserDAO) UpdateUserLogin(tx *dbs.Tx, userId int64, username string, } // CountAllEnabledUsers 计算用户数量 -func (this *UserDAO) CountAllEnabledUsers(tx *dbs.Tx, clusterId int64, keyword string) (int64, error) { +func (this *UserDAO) CountAllEnabledUsers(tx *dbs.Tx, clusterId int64, keyword string, isVerifying bool) (int64, error) { query := this.Query(tx) query.State(UserStateEnabled) if clusterId > 0 { @@ -212,11 +212,22 @@ func (this *UserDAO) CountAllEnabledUsers(tx *dbs.Tx, clusterId int64, keyword s query.Where("(username LIKE :keyword OR fullname LIKE :keyword OR mobile LIKE :keyword OR email LIKE :keyword OR tel LIKE :keyword OR remark LIKE :keyword)"). Param("keyword", "%"+keyword+"%") } + if isVerifying { + query.Attr("isVerified", 0) + } + return query.Count() +} + +// CountAllVerifyingUsers 获取等待审核的用户数 +func (this *UserDAO) CountAllVerifyingUsers(tx *dbs.Tx) (int64, error) { + query := this.Query(tx) + query.State(UserStateEnabled) + query.Attr("isVerified", 0) return query.Count() } // ListEnabledUsers 列出单页用户 -func (this *UserDAO) ListEnabledUsers(tx *dbs.Tx, clusterId int64, keyword string, offset int64, size int64) (result []*User, err error) { +func (this *UserDAO) ListEnabledUsers(tx *dbs.Tx, clusterId int64, keyword string, isVerifying bool, offset int64, size int64) (result []*User, err error) { query := this.Query(tx) query.State(UserStateEnabled) if clusterId > 0 { @@ -226,6 +237,9 @@ func (this *UserDAO) ListEnabledUsers(tx *dbs.Tx, clusterId int64, keyword strin query.Where("(username LIKE :keyword OR fullname LIKE :keyword OR mobile LIKE :keyword OR email LIKE :keyword OR tel LIKE :keyword OR remark LIKE :keyword)"). Param("keyword", "%"+keyword+"%") } + if isVerifying { + query.Attr("isVerified", 0) + } _, err = query. DescPk(). Offset(offset). diff --git a/internal/rpc/services/service_admin.go b/internal/rpc/services/service_admin.go index 1f40b97a..b6afe082 100644 --- a/internal/rpc/services/service_admin.go +++ b/internal/rpc/services/service_admin.go @@ -520,7 +520,7 @@ func (this *AdminService) ComposeAdminDashboard(ctx context.Context, req *pb.Com result.CountAuditingServers = countAuditingServers // 用户数 - countUsers, err := models.SharedUserDAO.CountAllEnabledUsers(tx, 0, "") + countUsers, err := models.SharedUserDAO.CountAllEnabledUsers(tx, 0, "", false) if err != nil { return nil, err } diff --git a/internal/rpc/services/service_server_stat_board.go b/internal/rpc/services/service_server_stat_board.go index c69c4910..7fd0c8d8 100644 --- a/internal/rpc/services/service_server_stat_board.go +++ b/internal/rpc/services/service_server_stat_board.go @@ -74,7 +74,7 @@ func (this *ServerStatBoardService) ComposeServerStatNodeClusterBoard(ctx contex } result.CountInactiveNodes = countInactiveNodes - countUsers, err := models.SharedUserDAO.CountAllEnabledUsers(tx, req.NodeClusterId, "") + countUsers, err := models.SharedUserDAO.CountAllEnabledUsers(tx, req.NodeClusterId, "", false) if err != nil { return nil, err } diff --git a/internal/rpc/services/service_user.go b/internal/rpc/services/service_user.go index f36ba61c..ea82140b 100644 --- a/internal/rpc/services/service_user.go +++ b/internal/rpc/services/service_user.go @@ -175,7 +175,7 @@ func (this *UserService) CountAllEnabledUsers(ctx context.Context, req *pb.Count tx := this.NullTx() - count, err := models.SharedUserDAO.CountAllEnabledUsers(tx, 0, req.Keyword) + count, err := models.SharedUserDAO.CountAllEnabledUsers(tx, 0, req.Keyword, req.IsVerifying) if err != nil { return nil, err } @@ -191,7 +191,7 @@ func (this *UserService) ListEnabledUsers(ctx context.Context, req *pb.ListEnabl tx := this.NullTx() - users, err := models.SharedUserDAO.ListEnabledUsers(tx, 0, req.Keyword, req.Offset, req.Size) + users, err := models.SharedUserDAO.ListEnabledUsers(tx, 0, req.Keyword, req.IsVerifying, req.Offset, req.Size) if err != nil { return nil, err } @@ -548,12 +548,19 @@ func (this *UserService) ComposeUserGlobalBoard(ctx context.Context, req *pb.Com var result = &pb.ComposeUserGlobalBoardResponse{} var tx = this.NullTx() - totalUsers, err := models.SharedUserDAO.CountAllEnabledUsers(tx, 0, "") + totalUsers, err := models.SharedUserDAO.CountAllEnabledUsers(tx, 0, "", false) if err != nil { return nil, err } result.TotalUsers = totalUsers + // 等待审核的用户 + countVerifyingUsers, err := models.SharedUserDAO.CountAllVerifyingUsers(tx) + if err != nil { + return nil, err + } + result.CountVerifyingUsers = countVerifyingUsers + countTodayUsers, err := models.SharedUserDAO.SumDailyUsers(tx, timeutil.Format("Ymd"), timeutil.Format("Ymd")) if err != nil { return nil, err