mirror of
https://github.com/usual2970/certimate.git
synced 2025-06-08 13:39:53 +00:00
32 lines
711 B
Go
32 lines
711 B
Go
package repository
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/usual2970/certimate/internal/domain"
|
|
"github.com/usual2970/certimate/internal/utils/app"
|
|
)
|
|
|
|
type SettingRepository struct{}
|
|
|
|
func NewSettingRepository() *SettingRepository {
|
|
return &SettingRepository{}
|
|
}
|
|
|
|
func (s *SettingRepository) GetByName(ctx context.Context, name string) (*domain.Setting, error) {
|
|
resp, err := app.GetApp().Dao().FindFirstRecordByFilter("settings", "name='"+name+"'")
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
rs := &domain.Setting{
|
|
ID: resp.GetString("id"),
|
|
Name: resp.GetString("name"),
|
|
Content: resp.GetString("content"),
|
|
Created: resp.GetTime("created"),
|
|
Updated: resp.GetTime("updated"),
|
|
}
|
|
|
|
return rs, nil
|
|
}
|