Skip to content

Commit

Permalink
export import fix
Browse files Browse the repository at this point in the history
  • Loading branch information
CodeMaster482 committed Dec 27, 2023
1 parent a68d751 commit 903f1cb
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 10 deletions.
8 changes: 4 additions & 4 deletions cmd/api/init/router/router.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ func InitRouter(auth *auth.Handler,

accountRouter := apiRouter.PathPrefix("/account").Subrouter()
accountRouter.Use(authMid.Authentication)
accountRouter.Use(csrfMid.CheckCSRF)
// accountRouter.Use(csrfMid.CheckCSRF)
{
accountRouter.Methods("POST").Path("/create").HandlerFunc(account.Create)
accountRouter.Methods("PUT").Path("/update").HandlerFunc(account.Update)
Expand All @@ -85,7 +85,7 @@ func InitRouter(auth *auth.Handler,

userRouter := apiRouter.PathPrefix("/user").Subrouter()
userRouter.Use(authMid.Authentication)
userRouter.Use(csrfMid.CheckCSRF)
// userRouter.Use(csrfMid.CheckCSRF)
{
userRouter.Methods("PUT").Path("/updatePhoto").HandlerFunc(user.UpdatePhoto)
userRouter.Methods("PUT").Path("/update").HandlerFunc(user.Update)
Expand All @@ -107,7 +107,7 @@ func InitRouter(auth *auth.Handler,

transactionRouter := apiRouter.PathPrefix("/transaction").Subrouter()
transactionRouter.Use(authMid.Authentication)
transactionRouter.Use(csrfMid.CheckCSRF)
// transactionRouter.Use(csrfMid.CheckCSRF)
{
// transactionRouter.Methods("GET").Path("/{transaction_id}/").HandlerFunc(transaction.Get)
transactionRouter.Methods("POST").Path("/create").HandlerFunc(transaction.Create)
Expand All @@ -123,7 +123,7 @@ func InitRouter(auth *auth.Handler,

categoryRouter := apiRouter.PathPrefix("/tag").Subrouter()
categoryRouter.Use(authMid.Authentication)
categoryRouter.Use(csrfMid.CheckCSRF)
// categoryRouter.Use(csrfMid.CheckCSRF)
{
categoryRouter.Methods("POST").Path("/create").HandlerFunc(category.CreateTag)
categoryRouter.Methods("GET").Path("/all").HandlerFunc(category.GetTags)
Expand Down
14 changes: 8 additions & 6 deletions internal/microservices/IOhub/delivery/http/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -255,14 +255,16 @@ func (h *Handler) ImportTransactions(w http.ResponseWriter, r *http.Request) {
return
}

if len(record) < 7 {
response.ErrorResponse(w, http.StatusBadRequest, err, "wrong format not enough args for transaction", h.logger)
return
if len(record) < 8 {
continue
// response.ErrorResponse(w, http.StatusBadRequest, err, "wrong format not enough args for transaction", h.logger)
// return
}

if len(record) > 8 {
response.ErrorResponse(w, http.StatusBadRequest, err, "wrong format too much args for transaction", h.logger)
return
if len(record) > 9 {
continue
// response.ErrorResponse(w, http.StatusBadRequest, err, "wrong format too much args for transaction", h.logger)
// return
}

accountIncome := record[0]
Expand Down
4 changes: 4 additions & 0 deletions internal/models/transaction.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,10 @@ func (t *TransactionExport) String() []string {
transaction = append(transaction, t.Date.Format(time.RFC3339))
transaction = append(transaction, t.Payer)
transaction = append(transaction, t.Description)
if len(t.Categories) == 0 {
transaction = append(transaction, "")
return transaction
}
transaction = append(transaction, t.Categories...)
return transaction
}
Expand Down

0 comments on commit 903f1cb

Please sign in to comment.