Skip to content

A Q&A platform software for teams at any scales. Whether it's a community forum, help center, or knowledge management platform, you can always count on Apache Answer.

fix: remove is admin query condition

LinkinStar7513a4412ee3
diff --git a/internal/repo/user/user_repo.go b/internal/repo/user/user_repo.go
index fc18c46b..10324baa 100644
--- a/internal/repo/user/user_repo.go
+++ b/internal/repo/user/user_repo.go
@@ -122,7 +122,7 @@ func (ur *userRepo) UpdateInfo(ctx context.Context, userInfo *entity.User) (err
// GetByUserID get user info by user id
func (ur *userRepo) GetByUserID(ctx context.Context, userID string) (userInfo *entity.User, exist bool, err error) {
userInfo = &entity.User{}
- exist, err = ur.data.DB.Where("id = ?", userID).UseBool("is_admin").Get(userInfo)
+ exist, err = ur.data.DB.Where("id = ?", userID).Get(userInfo)
if err != nil {
err = errors.InternalServer(reason.DatabaseError).WithError(err).WithStack()
}
@@ -131,7 +131,7 @@ func (ur *userRepo) GetByUserID(ctx context.Context, userID string) (userInfo *e
func (ur *userRepo) BatchGetByID(ctx context.Context, ids []string) ([]*entity.User, error) {
list := make([]*entity.User, 0)
- err := ur.data.DB.In("id", ids).UseBool("is_admin").Find(&list)
+ err := ur.data.DB.In("id", ids).Find(&list)
if err != nil {
return nil, errors.InternalServer(reason.DatabaseError).WithError(err).WithStack()
}
@@ -141,7 +141,7 @@ func (ur *userRepo) BatchGetByID(ctx context.Context, ids []string) ([]*entity.U
// GetByUsername get user by username
func (ur *userRepo) GetByUsername(ctx context.Context, username string) (userInfo *entity.User, exist bool, err error) {
userInfo = &entity.User{}
- exist, err = ur.data.DB.Where("username = ?", username).UseBool("is_admin").Get(userInfo)
+ exist, err = ur.data.DB.Where("username = ?", username).Get(userInfo)
if err != nil {
err = errors.InternalServer(reason.DatabaseError).WithError(err).WithStack()
}
@@ -151,7 +151,7 @@ func (ur *userRepo) GetByUsername(ctx context.Context, username string) (userInf
// GetByEmail get user by email
func (ur *userRepo) GetByEmail(ctx context.Context, email string) (userInfo *entity.User, exist bool, err error) {
userInfo = &entity.User{}
- exist, err = ur.data.DB.Where("e_mail = ?", email).UseBool("is_admin").Get(userInfo)
+ exist, err = ur.data.DB.Where("e_mail = ?", email).Get(userInfo)
if err != nil {
err = errors.InternalServer(reason.DatabaseError).WithError(err).WithStack()
}