add tysc handlers to kontor-gin
This commit is contained in:
@@ -1,6 +1,10 @@
|
||||
package repository
|
||||
|
||||
import (
|
||||
"context"
|
||||
"kontor-api-gin/internal/models"
|
||||
"log/slog"
|
||||
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
@@ -12,3 +16,23 @@ func NewProfileRepository(db *gorm.DB) *ProfileRepository {
|
||||
repository := &ProfileRepository{db: db}
|
||||
return repository
|
||||
}
|
||||
|
||||
func (repository *ProfileRepository) FindAll(context context.Context) ([]models.Profile, error) {
|
||||
var profiles []models.Profile
|
||||
|
||||
result := repository.db.Find(&profiles)
|
||||
slog.Info("ProfileRepository#FindAll", "count", result.RowsAffected)
|
||||
|
||||
return profiles, nil
|
||||
}
|
||||
|
||||
func (repository *ProfileRepository) FindProfileByEmail(email string) (*models.Profile, error) {
|
||||
var profile models.Profile
|
||||
|
||||
err := repository.db.Model(models.Profile{}).Where("email = ?", email).Take(&profile).Error
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &profile, nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user