-
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add user model and repository along with datafx provider
- 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
Showing
5 changed files
with
94 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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{} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters