feat: handler for get /users is implemented
All checks were successful
Build and Deploy Go App / build (push) Successful in 7m0s
Build and Deploy Go App / deploy (push) Successful in 44s

This commit is contained in:
Iron_Felix 2025-12-05 20:15:05 +03:00
parent fe18c0d865
commit 6a5994e33e
2 changed files with 67 additions and 0 deletions

View file

@ -485,3 +485,39 @@ func (s Server) GetUserTitle(ctx context.Context, request oapi.GetUserTitleReque
return oapi.GetUserTitle200JSONResponse(oapi_usertitle), nil
}
// GetUsers implements oapi.StrictServerInterface.
func (s *Server) GetUsers(ctx context.Context, request oapi.GetUsersRequestObject) (oapi.GetUsersResponseObject, error) {
params := sqlc.SearchUserParams{
Word: request.Params.Word,
Cursor: request.Params.CursorId,
Limit: request.Params.Limit,
}
_users, err := s.db.SearchUser(ctx, params)
if err != nil {
log.Errorf("%v", err)
return oapi.GetUsers500Response{}, nil
}
if len(_users) == 0 {
return oapi.GetUsers204Response{}, nil
}
var users []oapi.User
var cursor int64
for _, user := range _users {
oapi_user := oapi.User{ // maybe its possible to make one sqlc type and use one map func iinstead of this shit
// add image
CreationDate: &user.CreationDate,
DispName: user.DispName,
Id: &user.ID,
Mail: StringToEmail(user.Mail),
Nickname: user.Nickname,
UserDesc: user.UserDesc,
}
users = append(users, oapi_user)
cursor = user.ID
}
return oapi.GetUsers200JSONResponse{Data: users, Cursor: cursor}, nil
}