feat: CR login, register, subscribe
This commit is contained in:
@@ -0,0 +1,11 @@
|
||||
package staffrepository
|
||||
|
||||
import authdomain "github.com/ardeman/project-legalgo-go/internal/domain/auth"
|
||||
|
||||
func (ur *StaffRepository) Create(spec *authdomain.Staff) (*authdomain.Staff, error) {
|
||||
if err := ur.DB.Create(&spec).Error; err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return spec, nil
|
||||
}
|
||||
@@ -3,12 +3,12 @@ package staffrepository
|
||||
import (
|
||||
"errors"
|
||||
|
||||
staffmodel "github.com/ardeman/project-legalgo-go/database/staff"
|
||||
authdomain "github.com/ardeman/project-legalgo-go/internal/domain/auth"
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
func (sr *StaffRepository) GetStaff(email string) (*staffmodel.Staff, error) {
|
||||
var staff staffmodel.Staff
|
||||
func (sr *StaffRepository) GetStaffByEmail(email string) (*authdomain.LoginRepoResponse, error) {
|
||||
var staff authdomain.LoginRepoResponse
|
||||
|
||||
if email == "" {
|
||||
return nil, errors.New("email is empty")
|
||||
|
||||
@@ -2,17 +2,18 @@ package staffrepository
|
||||
|
||||
import (
|
||||
"github.com/ardeman/project-legalgo-go/database"
|
||||
staffmodel "github.com/ardeman/project-legalgo-go/database/staff"
|
||||
authdomain "github.com/ardeman/project-legalgo-go/internal/domain/auth"
|
||||
)
|
||||
|
||||
type StaffRepository struct {
|
||||
DB *database.DB
|
||||
}
|
||||
|
||||
type StaffInterface interface {
|
||||
GetStaff(string) (*staffmodel.Staff, error)
|
||||
type StaffIntf interface {
|
||||
GetStaffByEmail(string) (*authdomain.LoginRepoResponse, error)
|
||||
Create(*authdomain.Staff) (*authdomain.Staff, error)
|
||||
}
|
||||
|
||||
func New(db *database.DB) StaffInterface {
|
||||
func New(db *database.DB) StaffIntf {
|
||||
return &StaffRepository{db}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user