reprogl
33 строки · 533.0 Байт
1package repositories2
3import (4"database/sql"5"errors"6
7"xelbot.com/reprogl/models"8)
9
10type SystemParametersRepository struct {11DB *sql.DB12}
13
14func (sp *SystemParametersRepository) FindByKey(key string) (string, error) {15query := `16SELECT
17sp.value
18FROM sys_parameters AS sp
19WHERE sp.optionkey = ?`
20
21var value string22
23err := sp.DB.QueryRow(query, key).Scan(&value)24if err != nil {25if errors.Is(err, sql.ErrNoRows) {26return value, models.RecordNotFound27} else {28return value, err29}30}31
32return value, nil33}
34