mirror of
https://github.com/usual2970/certimate.git
synced 2025-08-10 03:11:46 +00:00
refactor: clean code
This commit is contained in:
@@ -2,6 +2,8 @@ package repository
|
||||
|
||||
import (
|
||||
"context"
|
||||
"database/sql"
|
||||
"errors"
|
||||
|
||||
"github.com/pocketbase/dbx"
|
||||
"github.com/usual2970/certimate/internal/app"
|
||||
@@ -14,9 +16,16 @@ func NewSettingsRepository() *SettingsRepository {
|
||||
return &SettingsRepository{}
|
||||
}
|
||||
|
||||
func (s *SettingsRepository) GetByName(ctx context.Context, name string) (*domain.Settings, error) {
|
||||
record, err := app.GetApp().Dao().FindFirstRecordByFilter("settings", "name={:name}", dbx.Params{"name": name})
|
||||
func (r *SettingsRepository) GetByName(ctx context.Context, name string) (*domain.Settings, error) {
|
||||
record, err := app.GetApp().Dao().FindFirstRecordByFilter(
|
||||
"settings",
|
||||
"name={:name}",
|
||||
dbx.Params{"name": name},
|
||||
)
|
||||
if err != nil {
|
||||
if errors.Is(err, sql.ErrNoRows) {
|
||||
return nil, domain.ErrRecordNotFound
|
||||
}
|
||||
return nil, err
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user