|
1 | 1 | package excel_adapter |
2 | 2 |
|
3 | 3 | import ( |
| 4 | + "encoding/json" |
4 | 5 | "fmt" |
5 | 6 | "os" |
6 | | - "path/filepath" |
7 | 7 | "strings" |
8 | 8 |
|
9 | 9 | "github.com/fatih/color" |
10 | 10 |
|
11 | | - ade_linter "github.com/HyperloopUPV-H8/ade-linter" |
12 | 11 | "github.com/HyperloopUPV-H8/h9-backend/internal/excel_adapter/internals" |
13 | 12 | internalModels "github.com/HyperloopUPV-H8/h9-backend/internal/excel_adapter/internals/models" |
14 | 13 | "github.com/HyperloopUPV-H8/h9-backend/internal/excel_adapter/models" |
15 | 14 | trace "github.com/rs/zerolog/log" |
16 | | - "github.com/xuri/excelize/v2" |
17 | 15 | ) |
18 | 16 |
|
19 | 17 | type ExcelAdapterConfig struct { |
@@ -63,24 +61,18 @@ func (adapter ExcelAdapter) GetGlobalInfo() models.GlobalInfo { |
63 | 61 | func fetchDocument(downloadConfig internals.DownloadConfig, parseConfig internals.ParseConfig) internalModels.Document { |
64 | 62 | trace.Info().Str("id", downloadConfig.Id).Str("path", downloadConfig.Path).Str("name", downloadConfig.Name).Msg("fetch document") |
65 | 63 |
|
66 | | - errDownloading := internals.DownloadFile(downloadConfig) |
67 | | - if errDownloading != nil { |
68 | | - trace.Error().Stack().Err(errDownloading).Msg("") |
69 | | - trace.Warn().Str("id", downloadConfig.Id).Str("path", downloadConfig.Path).Str("name", downloadConfig.Name).Msg("using local document") |
70 | | - } |
71 | | - |
72 | | - file, err := excelize.OpenFile(filepath.Join(downloadConfig.Path, downloadConfig.Name)) |
| 64 | + file, err := os.Open(downloadConfig.Path) |
73 | 65 | if err != nil { |
74 | | - trace.Fatal().Stack().Err(err).Msg("") |
| 66 | + trace.Fatal().Stack().Err(err).Msg("Error abriendo el archivo JSON") |
75 | 67 | } |
| 68 | + defer file.Close() |
76 | 69 |
|
77 | | - if !ade_linter.Lint(file) { |
78 | | - if !promptContinue() { |
79 | | - os.Exit(1) |
80 | | - } |
| 70 | + var document internalModels.Document |
| 71 | + if err := json.NewDecoder(file).Decode(&document); err != nil { |
| 72 | + trace.Fatal().Stack().Err(err).Msg("Error decodificando JSON") |
81 | 73 | } |
82 | 74 |
|
83 | | - return internals.GetDocument(file, parseConfig) |
| 75 | + return document |
84 | 76 | } |
85 | 77 |
|
86 | 78 | func promptContinue() bool { |
|
0 commit comments