-
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
re-implemented the interface in a whole project to avoide import cycl…
…e and renamed the files properly
- Loading branch information
1 parent
db0565d
commit e113db5
Showing
67 changed files
with
1,505 additions
and
1,172 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 |
---|---|---|
@@ -1,2 +1,2 @@ | ||
github: ibilalkayy | ||
github: ibilalkayy | ||
buy_me_a_coffee: ibilalkayy |
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 |
---|---|---|
@@ -1,15 +1,15 @@ | ||
FROM golang:1.22.0-alpine3.19 | ||
|
||
RUN mkdir -p /app | ||
WORKDIR /app | ||
|
||
COPY go.mod /app | ||
COPY go.sum /app | ||
|
||
COPY . /app | ||
|
||
RUN go mod download | ||
|
||
RUN go build -o flow . | ||
|
||
FROM golang:1.22.0-alpine3.19 | ||
|
||
RUN mkdir -p /app | ||
WORKDIR /app | ||
|
||
COPY go.mod /app | ||
COPY go.sum /app | ||
|
||
COPY . /app | ||
|
||
RUN go mod download | ||
|
||
RUN go build -o flow . | ||
|
||
CMD ["sh", "-c", "./flow && while true; do echo 'App is running'; sleep 10; done"] |
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 |
---|---|---|
@@ -1,35 +1,54 @@ | ||
package budget_handler | ||
|
||
import ( | ||
"log" | ||
|
||
conversion "github.com/ibilalkayy/flow/common" | ||
"github.com/ibilalkayy/flow/entities" | ||
"github.com/ibilalkayy/flow/framework_drivers/db/budget_db" | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
// createCmd represents the create command | ||
var CreateCmd = &cobra.Command{ | ||
Use: "create", | ||
Short: "Create the budget of different categories", | ||
Run: func(cmd *cobra.Command, args []string) { | ||
var c conversion.MyConversion | ||
var m budget_db.MyBudgetDatabase | ||
|
||
category, _ := cmd.Flags().GetString("category") | ||
amount, _ := cmd.Flags().GetString("amount") | ||
amountInt := c.StringToInt(amount) | ||
|
||
bv := entities.BudgetVariables{Category: category, Amount: amountInt} | ||
err := m.CreateBudget(&bv) | ||
if err != nil { | ||
log.Fatal(err) | ||
} | ||
}, | ||
} | ||
|
||
func init() { | ||
CreateCmd.Flags().StringP("category", "c", "", "Write the category like groceries, utilities, etc") | ||
CreateCmd.Flags().StringP("amount", "a", "", "Write the total amount for that category") | ||
} | ||
package budget_handler | ||
|
||
import ( | ||
"log" | ||
|
||
conversion "github.com/ibilalkayy/flow/common" | ||
"github.com/ibilalkayy/flow/entities" | ||
"github.com/ibilalkayy/flow/framework/db" | ||
"github.com/ibilalkayy/flow/framework/db/budget_db" | ||
"github.com/ibilalkayy/flow/framework/db/total_amount_db" | ||
"github.com/ibilalkayy/flow/handler" | ||
"github.com/ibilalkayy/flow/interfaces" | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
// createCmd represents the create command | ||
var CreateCmd = &cobra.Command{ | ||
Use: "create", | ||
Short: "Create the budget of different categories", | ||
Run: func(cmd *cobra.Command, args []string) { | ||
category, _ := cmd.Flags().GetString("category") | ||
amount, _ := cmd.Flags().GetString("amount") | ||
|
||
myConnection := &db.MyConnection{} | ||
myBudget := &budget_db.MyBudgetDB{} | ||
myTotalDB := &total_amount_db.MyTotalAmountDB{} | ||
myCommon := &conversion.MyCommon{} | ||
deps := interfaces.Dependencies{ | ||
Connect: myConnection, | ||
TotalAmount: myTotalDB, | ||
TotalAmountCategory: myTotalDB, | ||
ManageBudget: myBudget, | ||
Common: myCommon, | ||
} | ||
handle := handler.NewHandler(deps) | ||
myConnection.Handler = handle | ||
myBudget.Handler = handle | ||
myTotalDB.Handler = handle | ||
myCommon.Handler = handle | ||
|
||
amountInt := handle.Deps.Common.StringToInt(amount) | ||
bv := entities.BudgetVariables{Category: category, Amount: amountInt} | ||
|
||
err := handle.Deps.ManageBudget.CreateBudget(&bv) | ||
if err != nil { | ||
log.Fatal(err) | ||
} | ||
}, | ||
} | ||
|
||
func init() { | ||
CreateCmd.Flags().StringP("category", "c", "", "Write the category like groceries, utilities, etc") | ||
CreateCmd.Flags().StringP("amount", "a", "", "Write the total amount for that category") | ||
} |
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 |
---|---|---|
@@ -1,28 +1,45 @@ | ||
package budget_handler | ||
|
||
import ( | ||
"log" | ||
|
||
"github.com/ibilalkayy/flow/framework_drivers/db/budget_db" | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
// GetCmd represents the get command | ||
var GetCmd = &cobra.Command{ | ||
Use: "get", | ||
Short: "Get the budget data in CSV", | ||
Run: func(cmd *cobra.Command, args []string) { | ||
filepath, _ := cmd.Flags().GetString("filepath") | ||
filename, _ := cmd.Flags().GetString("filename") | ||
var m budget_db.MyBudgetDatabase | ||
err := m.GetBudgetData(filepath, filename) | ||
if err != nil { | ||
log.Fatal(err) | ||
} | ||
}, | ||
} | ||
|
||
func init() { | ||
GetCmd.Flags().StringP("filepath", "p", "", "Give the file path to store the data") | ||
GetCmd.Flags().StringP("filename", "n", "", "Give the CSV file name to store the data") | ||
} | ||
package budget_handler | ||
|
||
import ( | ||
"log" | ||
|
||
conversion "github.com/ibilalkayy/flow/common" | ||
"github.com/ibilalkayy/flow/framework/db" | ||
"github.com/ibilalkayy/flow/framework/db/budget_db" | ||
"github.com/ibilalkayy/flow/handler" | ||
"github.com/ibilalkayy/flow/interfaces" | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
// GetCmd represents the get command | ||
var GetCmd = &cobra.Command{ | ||
Use: "get", | ||
Short: "Get the budget data in CSV", | ||
Run: func(cmd *cobra.Command, args []string) { | ||
filepath, _ := cmd.Flags().GetString("filepath") | ||
filename, _ := cmd.Flags().GetString("filename") | ||
|
||
myConnection := &db.MyConnection{} | ||
myBudget := &budget_db.MyBudgetDB{} | ||
myCommon := &conversion.MyCommon{} | ||
deps := interfaces.Dependencies{ | ||
Connect: myConnection, | ||
ManageBudget: myBudget, | ||
Common: myCommon, | ||
} | ||
handle := handler.NewHandler(deps) | ||
myConnection.Handler = handle | ||
myBudget.Handler = handle | ||
myCommon.Handler = handle | ||
|
||
err := handle.Deps.ManageBudget.GetBudgetData(filepath, filename) | ||
if err != nil { | ||
log.Fatal(err) | ||
} | ||
}, | ||
} | ||
|
||
func init() { | ||
GetCmd.Flags().StringP("filepath", "p", "", "Give the file path to store the data") | ||
GetCmd.Flags().StringP("filename", "n", "", "Give the CSV file name to store the data") | ||
} |
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 |
---|---|---|
@@ -1,27 +1,39 @@ | ||
package budget_handler | ||
|
||
import ( | ||
"log" | ||
|
||
"github.com/ibilalkayy/flow/framework_drivers/db/budget_db" | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
// RemoveCmd represents the remove command | ||
var RemoveCmd = &cobra.Command{ | ||
Use: "remove", | ||
Short: "Remove the budget details", | ||
Run: func(cmd *cobra.Command, args []string) { | ||
var m budget_db.MyBudgetDatabase | ||
|
||
category, _ := cmd.Flags().GetString("category") | ||
err := m.RemoveBudget(category) | ||
if err != nil { | ||
log.Fatal(err) | ||
} | ||
}, | ||
} | ||
|
||
func init() { | ||
RemoveCmd.Flags().StringP("category", "c", "", "Write the category name to remove") | ||
} | ||
package budget_handler | ||
|
||
import ( | ||
"log" | ||
|
||
"github.com/ibilalkayy/flow/framework/db" | ||
"github.com/ibilalkayy/flow/framework/db/budget_db" | ||
"github.com/ibilalkayy/flow/handler" | ||
"github.com/ibilalkayy/flow/interfaces" | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
// RemoveCmd represents the remove command | ||
var RemoveCmd = &cobra.Command{ | ||
Use: "remove", | ||
Short: "Remove the budget details", | ||
Run: func(cmd *cobra.Command, args []string) { | ||
category, _ := cmd.Flags().GetString("category") | ||
|
||
myConnection := &db.MyConnection{} | ||
myBudget := &budget_db.MyBudgetDB{} | ||
deps := interfaces.Dependencies{ | ||
Connect: myConnection, | ||
ManageBudget: myBudget, | ||
} | ||
handle := handler.NewHandler(deps) | ||
myConnection.Handler = handle | ||
myBudget.Handler = handle | ||
|
||
err := handle.Deps.ManageBudget.RemoveBudget(category) | ||
if err != nil { | ||
log.Fatal(err) | ||
} | ||
}, | ||
} | ||
|
||
func init() { | ||
RemoveCmd.Flags().StringP("category", "c", "", "Write the category name to remove") | ||
} |
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
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 |
---|---|---|
@@ -1,29 +1,41 @@ | ||
package budget_handler | ||
|
||
import ( | ||
"fmt" | ||
"log" | ||
|
||
"github.com/ibilalkayy/flow/framework_drivers/db/budget_db" | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
// ViewCmd represents the view command | ||
var ViewCmd = &cobra.Command{ | ||
Use: "view", | ||
Short: "View the budget details", | ||
Run: func(cmd *cobra.Command, args []string) { | ||
var m budget_db.MyBudgetDatabase | ||
|
||
category, _ := cmd.Flags().GetString("category") | ||
details, err := m.ViewBudget(category) | ||
if err != nil { | ||
log.Fatal(err) | ||
} | ||
fmt.Println(details[0]) | ||
}, | ||
} | ||
|
||
func init() { | ||
ViewCmd.Flags().StringP("category", "c", "", "Write the category name to show the specific details") | ||
} | ||
package budget_handler | ||
|
||
import ( | ||
"fmt" | ||
"log" | ||
|
||
"github.com/ibilalkayy/flow/framework/db" | ||
"github.com/ibilalkayy/flow/framework/db/budget_db" | ||
"github.com/ibilalkayy/flow/handler" | ||
"github.com/ibilalkayy/flow/interfaces" | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
// ViewCmd represents the view command | ||
var ViewCmd = &cobra.Command{ | ||
Use: "view", | ||
Short: "View the budget details", | ||
Run: func(cmd *cobra.Command, args []string) { | ||
category, _ := cmd.Flags().GetString("category") | ||
|
||
myConnection := &db.MyConnection{} | ||
myBudget := &budget_db.MyBudgetDB{} | ||
deps := interfaces.Dependencies{ | ||
Connect: myConnection, | ||
ManageBudget: myBudget, | ||
} | ||
handle := handler.NewHandler(deps) | ||
myConnection.Handler = handle | ||
myBudget.Handler = handle | ||
|
||
details, err := handle.Deps.ManageBudget.ViewBudget(category) | ||
if err != nil { | ||
log.Fatal(err) | ||
} | ||
fmt.Println(details[0]) | ||
}, | ||
} | ||
|
||
func init() { | ||
ViewCmd.Flags().StringP("category", "c", "", "Write the category name to show the specific details") | ||
} |
Oops, something went wrong.