diff --git a/internal/rpc/user/user.go b/internal/rpc/user/user.go index 824b8a9bb..8270c822e 100644 --- a/internal/rpc/user/user.go +++ b/internal/rpc/user/user.go @@ -515,7 +515,7 @@ func (s *userServer) SearchNotificationAccount(ctx context.Context, req *pbuser. return resp, nil } - _, users, err := s.UserDatabase.Page(ctx, req.Pagination) + users, err := s.UserDatabase.FindNotification(ctx, string(constant.AppNotificationAdmin)) if err != nil { return nil, err } diff --git a/pkg/common/db/controller/user.go b/pkg/common/db/controller/user.go index 72bdf6b06..4790a0c52 100644 --- a/pkg/common/db/controller/user.go +++ b/pkg/common/db/controller/user.go @@ -40,6 +40,8 @@ type UserDatabase interface { Find(ctx context.Context, userIDs []string) (users []*relation.UserModel, err error) // Find userInfo By Nickname FindByNickname(ctx context.Context, nickname string) (users []*relation.UserModel, err error) + // Find notificationAccounts + FindNotification(ctx context.Context, level string) (users []*relation.UserModel, err error) // Create Insert multiple external guarantees that the userID is not repeated and does not exist in the db Create(ctx context.Context, users []*relation.UserModel) (err error) // Update update (non-zero value) external guarantee userID exists @@ -140,6 +142,11 @@ func (u *userDatabase) FindByNickname(ctx context.Context, nickname string) (use return u.userDB.TakeByNickname(ctx, nickname) } +// Find notificationAccouts +func (u *userDatabase) FindNotification(ctx context.Context, level string) (users []*relation.UserModel, err error) { + return u.userDB.TakeNotification(ctx, level) +} + // Create Insert multiple external guarantees that the userID is not repeated and does not exist in the db. func (u *userDatabase) Create(ctx context.Context, users []*relation.UserModel) (err error) { return u.tx.Transaction(ctx, func(ctx context.Context) error { diff --git a/pkg/common/db/mgo/user.go b/pkg/common/db/mgo/user.go index 0ca711ad8..770b0208f 100644 --- a/pkg/common/db/mgo/user.go +++ b/pkg/common/db/mgo/user.go @@ -65,6 +65,10 @@ func (u *UserMgo) Take(ctx context.Context, userID string) (user *relation.UserM return mgoutil.FindOne[*relation.UserModel](ctx, u.coll, bson.M{"user_id": userID}) } +func (u *UserMgo) TakeNotification(ctx context.Context, level string) (user []*relation.UserModel, err error) { + return mgoutil.Find[*relation.UserModel](ctx, u.coll, bson.M{"app_manger_level": level}) +} + func (u *UserMgo) TakeByNickname(ctx context.Context, nickname string) (user []*relation.UserModel, err error) { return mgoutil.Find[*relation.UserModel](ctx, u.coll, bson.M{"nickname": nickname}) } diff --git a/pkg/common/db/table/relation/user.go b/pkg/common/db/table/relation/user.go index 8917ba55f..20ed219dd 100644 --- a/pkg/common/db/table/relation/user.go +++ b/pkg/common/db/table/relation/user.go @@ -53,6 +53,7 @@ type UserModelInterface interface { UpdateByMap(ctx context.Context, userID string, args map[string]any) (err error) Find(ctx context.Context, userIDs []string) (users []*UserModel, err error) Take(ctx context.Context, userID string) (user *UserModel, err error) + TakeNotification(ctx context.Context, level string) (user []*UserModel, err error) TakeByNickname(ctx context.Context, nickname string) (user []*UserModel, err error) Page(ctx context.Context, pagination pagination.Pagination) (count int64, users []*UserModel, err error) Exist(ctx context.Context, userID string) (exist bool, err error)