30 lines
598 B
Go
30 lines
598 B
Go
package profileRepository
|
|
|
|
import (
|
|
"context"
|
|
"database/sql"
|
|
"time"
|
|
|
|
"gitea.cybertalant.ru/VisionCareerMiniapp/MiniappGoService/internal/application/types"
|
|
)
|
|
|
|
func (t *repository) GetUserById(id int64) (*types.User, error) {
|
|
data := new(types.User)
|
|
|
|
query := `
|
|
SELECT * FROM users
|
|
WHERE id = $1
|
|
`
|
|
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
|
|
defer cancel()
|
|
|
|
errGetContext := t.pgDB.GetContext(ctx, data, query, id)
|
|
if errGetContext == sql.ErrNoRows {
|
|
return nil, nil
|
|
} else if errGetContext != nil {
|
|
return nil, errGetContext
|
|
}
|
|
|
|
return data, nil
|
|
}
|