feat(schema): #48 monthly_budget em categories + category_id em achievements
- Migration 018: ADD COLUMN monthly_budget NUMERIC(12,2) em categories - Migration 018: ADD COLUMN category_id INTEGER REFERENCES categories(id) ON DELETE CASCADE em achievements - Remove conquistas hardcoded veleiro_under_500 e health_3months do banco - Reset game state do profile_id=1 - Atualiza CategoryRepository, CategoryInput e Category model para incluir monthly_budget
This commit is contained in:
@@ -32,14 +32,14 @@ func (s *CategoryService) Create(ctx context.Context, in model.CategoryInput) (*
|
||||
if err := validateInput(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return s.repo.Create(ctx, strings.TrimSpace(in.Name), in.Color, in.IsTax)
|
||||
return s.repo.Create(ctx, strings.TrimSpace(in.Name), in.Color, in.IsTax, in.MonthlyBudget)
|
||||
}
|
||||
|
||||
func (s *CategoryService) Update(ctx context.Context, id int, in model.CategoryInput) (*model.Category, error) {
|
||||
if err := validateInput(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return s.repo.Update(ctx, id, strings.TrimSpace(in.Name), in.Color, in.IsTax)
|
||||
return s.repo.Update(ctx, id, strings.TrimSpace(in.Name), in.Color, in.IsTax, in.MonthlyBudget)
|
||||
}
|
||||
|
||||
func (s *CategoryService) Delete(ctx context.Context, id int) error {
|
||||
|
||||
@@ -33,13 +33,13 @@ func (m *mockCategoryRepo) GetByID(_ context.Context, id int) (*model.Category,
|
||||
return nil, repository.ErrNotFound
|
||||
}
|
||||
|
||||
func (m *mockCategoryRepo) Create(_ context.Context, name, color string, _ bool) (*model.Category, error) {
|
||||
func (m *mockCategoryRepo) Create(_ context.Context, name, color string, _ bool, _ *float64) (*model.Category, error) {
|
||||
c := model.Category{ID: len(m.categories) + 1, Name: name, Color: color}
|
||||
m.categories = append(m.categories, c)
|
||||
return &c, nil
|
||||
}
|
||||
|
||||
func (m *mockCategoryRepo) Update(_ context.Context, id int, name, color string, _ bool) (*model.Category, error) {
|
||||
func (m *mockCategoryRepo) Update(_ context.Context, id int, name, color string, _ bool, _ *float64) (*model.Category, error) {
|
||||
for i, c := range m.categories {
|
||||
if c.ID == id {
|
||||
m.categories[i].Name = name
|
||||
|
||||
Reference in New Issue
Block a user