generated from kedaya_haitao/template
Some checks failed
Build image / build (push) Failing after 49s
1. 修改ExportCheapProduct方法,支持直接将Excel数据写入HTTP响应 2. 添加图片下载和嵌入功能,提升Excel报表可视化效果 3. 优化数据查询和处理逻辑,提高导出效率 4. 完善错误处理和日志记录 此次修改避免了临时文件的创建和管理,减少了内存使用,提高了响应速度。
65 lines
1.5 KiB
Go
65 lines
1.5 KiB
Go
package main
|
||
|
||
import (
|
||
"context"
|
||
"flag"
|
||
"os"
|
||
"os/signal"
|
||
|
||
"gitea.timerzz.com/kedaya_haitao/article/service"
|
||
"gitea.timerzz.com/kedaya_haitao/common/pkg/database"
|
||
"gitea.timerzz.com/kedaya_haitao/common/pkg/web"
|
||
"gitea.timerzz.com/kedaya_haitao/common/structs/storage"
|
||
dw_sdk "gitea.timerzz.com/kedaya_haitao/dw-sdk"
|
||
"github.com/gofiber/fiber/v3"
|
||
"github.com/gofiber/fiber/v3/middleware/cors"
|
||
"github.com/gofiber/fiber/v3/middleware/recover"
|
||
"github.com/sirupsen/logrus"
|
||
|
||
"github.com/golang/glog"
|
||
)
|
||
|
||
func main() {
|
||
flag.Parse()
|
||
glog.Info(">>> BEGIN INIT<<<")
|
||
ctx, cancel := signal.NotifyContext(context.Background(), os.Kill, os.Interrupt)
|
||
defer cancel()
|
||
// 初始化数据库
|
||
db, err := database.InitDefaultDatabase()
|
||
if err != nil {
|
||
glog.Fatalf("init database failed: %v", err)
|
||
}
|
||
|
||
client, err := dw_sdk.InitDefaultDWClient()
|
||
if err != nil {
|
||
logrus.Fatalf("初始化redis失败:%v", err)
|
||
}
|
||
// 初始化服务
|
||
r := fiber.New(fiber.Config{ErrorHandler: web.ErrHandle})
|
||
r.Use(cors.New(), recover.New())
|
||
|
||
stg := storage.NewStorage(db)
|
||
_ = stg.Article().AutoMigrate()
|
||
|
||
svc := []web.Register{
|
||
web.NewProbe(),
|
||
service.NewArticle(stg),
|
||
service.NewTools(stg, client), // 添加工具服务
|
||
}
|
||
|
||
for _, s := range svc {
|
||
s.Registry(r)
|
||
}
|
||
|
||
port := os.Getenv("PORT")
|
||
if port == "" {
|
||
port = "80"
|
||
}
|
||
if err = r.Listen(":"+port, fiber.ListenConfig{
|
||
EnablePrintRoutes: true,
|
||
GracefulContext: ctx,
|
||
}); err != nil {
|
||
glog.Warningf("service over: %v", err)
|
||
}
|
||
}
|