diff --git a/backend/goals/handler/types.go b/backend/goals/handler/types.go index 084dbf7..de7e34d 100644 --- a/backend/goals/handler/types.go +++ b/backend/goals/handler/types.go @@ -9,42 +9,39 @@ import ( "github.com/google/uuid" ) -type GoalHandler struct { - goalService service.GoalService - traceLogger stacktrace.TraceLogger -} +type ( + GoalHandler struct { + goalService service.GoalService + traceLogger stacktrace.TraceLogger + } + CreateGoalRequest struct { + Title string `json:"title"` + Description string `json:"description"` + CategoryId string `json:"category_id"` + } + CreateGoalCategoryRequest struct { + Title string `json:"title"` + XpPerGoal int `json:"xp_per_goal"` + } + UpdateGoalCategoryRequest struct { + Title options.Option[string] `json:"title"` + XpPerGoal options.Option[int] `json:"xp_per_goal"` + } + UpdateGoalRequest struct { + Title options.Option[string] `json:"title"` + Description options.Option[string] `json:"description"` + CategoryId options.Option[string] `json:"category_id"` + Status options.Option[string] `json:"status"` + } + DeleteGoalRequest struct { + GoalId string `json:"goal_id"` + } +) func NewGoalHandler(goalService service.GoalService, traceLogger stacktrace.TraceLogger) *GoalHandler { return &GoalHandler{goalService, traceLogger} } -type CreateGoalRequest struct { - Title string `json:"title"` - Description string `json:"description"` - CategoryId string `json:"category_id"` -} - -type CreateGoalCategoryRequest struct { - Title string `json:"title"` - XpPerGoal int `json:"xp_per_goal"` -} - -type UpdateGoalCategoryRequest struct { - Title options.Option[string] `json:"title"` - XpPerGoal options.Option[int] `json:"xp_per_goal"` -} - -type UpdateGoalRequest struct { - Title options.Option[string] `json:"title"` - Description options.Option[string] `json:"description"` - CategoryId options.Option[string] `json:"category_id"` - Status options.Option[string] `json:"status"` -} - -type DeleteGoalRequest struct { - GoalId string `json:"goal_id"` -} - const ( TEXT_MAX_LEN = 255 XP_MAX_PER_GOAL = 100 diff --git a/backend/goals/stores/category_store.go b/backend/goals/stores/category_store.go index 290bb46..e295afd 100644 --- a/backend/goals/stores/category_store.go +++ b/backend/goals/stores/category_store.go @@ -11,17 +11,18 @@ import ( "github.com/jmoiron/sqlx" ) -type GoalCategoryStore interface { - CreateGoalCategory(title string, xpPerGoal int, userId uuid.UUID) (*entities.GoalCategory, error) - GetGoalCategoriesByUserId(userId uuid.UUID) ([]*entities.GoalCategory, error) - GetGoalCategoryById(categoryId uuid.UUID) (*entities.GoalCategory, error) - UpdateGoalCategoryById(categoryId uuid.UUID, updates map[string]any) (*entities.GoalCategory, error) - DeleteGoalCategoryById(categoryId uuid.UUID) error -} - -type goalCategoryStore struct { - db *sqlx.DB -} +type ( + GoalCategoryStore interface { + CreateGoalCategory(title string, xpPerGoal int, userId uuid.UUID) (*entities.GoalCategory, error) + GetGoalCategoriesByUserId(userId uuid.UUID) ([]*entities.GoalCategory, error) + GetGoalCategoryById(categoryId uuid.UUID) (*entities.GoalCategory, error) + UpdateGoalCategoryById(categoryId uuid.UUID, updates map[string]any) (*entities.GoalCategory, error) + DeleteGoalCategoryById(categoryId uuid.UUID) error + } + goalCategoryStore struct { + db *sqlx.DB + } +) func NewGoalCategoryStore(db *sqlx.DB) GoalCategoryStore { return &goalCategoryStore{db: db} diff --git a/backend/users/handler/types.go b/backend/users/handler/types.go index a6c1cc9..0aa9f81 100644 --- a/backend/users/handler/types.go +++ b/backend/users/handler/types.go @@ -5,26 +5,25 @@ import ( "strings" ) -type SignupRequest struct { - Email string `json:"email"` - Password string `json:"password"` -} - -type LoginRequest struct { - Email string `json:"email"` - Password string `json:"password"` -} - -type RefreshRequest struct { - UserId string `json:"user_id"` - RefreshToken string `json:"refresh_token"` -} - -type UpdateRequest struct { - Xp options.Option[int] `json:"xp"` - LevelId options.Option[int] `json:"level_id"` - CashAvailable options.Option[int] `json:"cash_available"` -} +type ( + SignupRequest struct { + Email string `json:"email"` + Password string `json:"password"` + } + LoginRequest struct { + Email string `json:"email"` + Password string `json:"password"` + } + RefreshRequest struct { + UserId string `json:"user_id"` + RefreshToken string `json:"refresh_token"` + } + UpdateRequest struct { + Xp options.Option[int] `json:"xp"` + LevelId options.Option[int] `json:"level_id"` + CashAvailable options.Option[int] `json:"cash_available"` + } +) const ( PASSWORD_MIN_LEN = 8 diff --git a/backend/users/stores/store.go b/backend/users/stores/store.go index fcdd3b3..cbac814 100644 --- a/backend/users/stores/store.go +++ b/backend/users/stores/store.go @@ -9,23 +9,24 @@ import ( "github.com/jmoiron/sqlx" ) -type UserStore interface { - CreateUser(email, password string) (*entities.User, error) - GetUserByEmail(email string) (*entities.User, error) - UpdateRefreshToken(id, refreshToken string) (*entities.User, error) - GetUserById(id string) (*entities.User, error) - DeleteUserById(id string) error - UpdateUserById(id uuid.UUID, updates map[string]any) (*entities.User, error) - - GetLevelById(id int) (*entities.Level, error) -} +type ( + UserStore interface { + CreateUser(email, password string) (*entities.User, error) + GetUserByEmail(email string) (*entities.User, error) + UpdateRefreshToken(id, refreshToken string) (*entities.User, error) + GetUserById(id string) (*entities.User, error) + DeleteUserById(id string) error + UpdateUserById(id uuid.UUID, updates map[string]any) (*entities.User, error) + + GetLevelById(id int) (*entities.Level, error) + } + userStore struct { + db *sqlx.DB + } +) const DEFAULT_LEVEL = 1 -type userStore struct { - db *sqlx.DB -} - func NewUserStore(db *sqlx.DB) UserStore { return &userStore{db: db} }