package main import ( "context" "github.com/golang/glog" "lims_adapter/handler" "lims_adapter/service/timers" "net/http" _ "lims_adapter/boot" "dashoo.cn/micro_libary/micro_srv" "github.com/gogf/gf/frame/g" "github.com/robfig/cron" "github.com/smallnest/rpcx/protocol" ) func main() { go swaggerui() // 定时任务 c := cron.New() spec := "0 0 1 * * ?" // 每日1点执行 if err := c.AddJob(spec, timers.Timer{}); err != nil { glog.Error(err.Error()) } c.Start() srvAddr := g.Config().GetString("setting.bind-addr") basePath := g.Config().GetString("setting.srv-name") // 创建总服务包 s := micro_srv.CreateAndInitService(basePath) // 注册服务对象 s.RegisterName("Meeting", new(handler.Meeting), "") s.RegisterName("Reservation", new(handler.Reservation), "") s.RegisterName("Equipment", new(handler.Equipment), "") s.RegisterName("System", new(handler.System), "") s.RegisterName("Result", new(handler.Result), "") s.RegisterName("Account", new(handler.Account), "") s.RegisterName("SettleAccountBill", new(handler.SettleAccountBillController), "") s.RegisterName("SettleAccountMain", new(handler.SettleAccountMainController), "") s.RegisterName("SettleAccountDetail", new(handler.SettleAccountDetailController), "") s.RegisterName("InstrumentSurcharge", new(handler.InstrumentSurchargeController), "") s.RegisterName("Test", new((handler.TestController)), "") s.RegisterName("LearningSkill", new((handler.LearningSkill)), "") // 注册auth处理 s.AuthFunc = handleAuth // 运行服务 if err := s.Serve("tcp", srvAddr); err != nil { g.Log().Fatal(err) } } // AuthExcludePaths 设定不需要认证的路径 //var AuthExcludePaths = []string{} // 处理Auth func handleAuth(ctx context.Context, req *protocol.Message, token string) error { return micro_srv.HandleAuth(ctx, req, token, nil) } func swaggerui() { defer func() { if r := recover(); r != nil { glog.Error(r) } }() glog.Error(http.ListenAndServe(":8080", http.FileServer(http.Dir("./swaggerui/")))) }