Skip to content

Commit

Permalink
feat: add user model and repository along with datafx provider
Browse files Browse the repository at this point in the history
- Introduced `User` model with various fields such as Id, Kind, Name, Email, Phone, and timestamps.
- Defined `UserKind` constants for user roles: Admin, Editor, Regular.
- Created `UserRepository` interface with `CreateUser` and `GetUserById` methods.
- Implemented `UserRepositoryImpl`.
- Added `datafx` package with `DataProvider` interface and `DataProviderImpl` struct.
- Integrated `datafx.Module` into the main `bliss.Module`.
  • Loading branch information
eser committed Aug 18, 2024
1 parent fb58de2 commit a930e5d
Show file tree
Hide file tree
Showing 5 changed files with 94 additions and 0 deletions.
30 changes: 30 additions & 0 deletions pkg/app/data/models/user.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package models

import "time"

type UserKind string

const (
UserKindAdmin UserKind = "admin"
UserKindEditor UserKind = "editor"
UserKindRegular UserKind = "regular"
)

type User struct {
Id string
Kind UserKind

Name string
Email string
Phone *string

IndividualProfileId *string
GithubRemoteId *string
GithubHandle *string
XRemoteId *string
XHandle *string

CreatedAt time.Time
UpdatedAt *time.Time
DeletedAt *time.Time
}
26 changes: 26 additions & 0 deletions pkg/app/data/repositories/user.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package repositories

import (
"context"

"github.com/eser/go-service/pkg/app/data/models"
)

type UserRepository interface {
CreateUser(ctx context.Context, user *models.User) (*models.User, error)
GetUserById(ctx context.Context, id string) (*models.User, error)
}

type UserRepositoryImpl struct{}

func NewUserRepository() UserRepository { //nolint:ireturn
return &UserRepositoryImpl{}
}

func (r *UserRepositoryImpl) CreateUser(ctx context.Context, user *models.User) (*models.User, error) {
return nil, nil //nolint:nilnil
}

func (r *UserRepositoryImpl) GetUserById(ctx context.Context, id string) (*models.User, error) {
return nil, nil //nolint:nilnil
}
25 changes: 25 additions & 0 deletions pkg/bliss/datafx/mod.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package datafx

import (
"go.uber.org/fx"
)

//nolint:gochecknoglobals
var Module = fx.Module(
"data",
fx.Provide(
New,
),
)

type Result struct {
fx.Out

DataProvider DataProvider
}

func New() (Result, error) {
return Result{ //nolint:exhaustruct
DataProvider: NewDataProvider(),
}, nil
}
11 changes: 11 additions & 0 deletions pkg/bliss/datafx/provider.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package datafx

type DataProvider interface {
// CreateUnitOfWork() UnitOfWork
}

type DataProviderImpl struct{}

func NewDataProvider() DataProvider { //nolint:ireturn
return &DataProviderImpl{}
}
2 changes: 2 additions & 0 deletions pkg/bliss/mod.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package bliss

import (
"github.com/eser/go-service/pkg/bliss/configfx"
"github.com/eser/go-service/pkg/bliss/datafx"
"github.com/eser/go-service/pkg/bliss/httpfx"
"github.com/eser/go-service/pkg/bliss/logfx"
"go.uber.org/fx"
Expand All @@ -14,4 +15,5 @@ var Module = fx.Module(
logfx.Module,
configfx.Module,
httpfx.Module,
datafx.Module,
)

0 comments on commit a930e5d

Please sign in to comment.