2023-04-28 02:35:30 +03:00
|
|
|
package file
|
2023-04-25 13:06:02 +03:00
|
|
|
|
|
|
|
import (
|
2023-04-29 03:24:01 +03:00
|
|
|
"os"
|
|
|
|
"path"
|
|
|
|
"strings"
|
2023-04-25 13:06:02 +03:00
|
|
|
|
2023-04-28 02:35:30 +03:00
|
|
|
"gitstore.ru/tolikproh/sirius/internal/service"
|
2023-04-25 13:06:02 +03:00
|
|
|
)
|
|
|
|
|
2023-04-29 03:24:01 +03:00
|
|
|
func FileConvert(srcFilePathName string) error {
|
2023-04-25 14:48:32 +03:00
|
|
|
|
2023-04-29 03:24:01 +03:00
|
|
|
srcDir, srcFileName := path.Split(srcFilePathName)
|
2023-04-25 13:06:02 +03:00
|
|
|
|
2023-04-29 03:24:01 +03:00
|
|
|
dstFileName := strings.Split(srcFileName, ".")[0] + ".xlsx"
|
2023-04-25 13:06:02 +03:00
|
|
|
|
2023-04-29 03:24:01 +03:00
|
|
|
buffer, err := os.ReadFile(srcDir + srcFileName)
|
2023-04-25 13:06:02 +03:00
|
|
|
if err != nil {
|
2023-04-29 03:24:01 +03:00
|
|
|
return err
|
2023-04-25 13:06:02 +03:00
|
|
|
}
|
|
|
|
|
2023-04-28 02:35:30 +03:00
|
|
|
respBuff, err := service.SiriusConv(buffer)
|
2023-04-25 13:06:02 +03:00
|
|
|
if err != nil {
|
2023-04-29 03:24:01 +03:00
|
|
|
return err
|
2023-04-25 13:06:02 +03:00
|
|
|
}
|
|
|
|
|
2023-04-29 03:24:01 +03:00
|
|
|
err = os.WriteFile(srcDir+dstFileName, respBuff.Bytes(), 0644)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
2023-04-25 13:06:02 +03:00
|
|
|
|
2023-04-29 03:24:01 +03:00
|
|
|
return nil
|
2023-04-25 13:06:02 +03:00
|
|
|
}
|