main.go 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. package main
  2. import (
  3. "context"
  4. "dashoo.cn/micro/app/handler/plat"
  5. "dashoo.cn/micro/app/handler/base"
  6. "dashoo.cn/micro/app/handler/cust"
  7. "dashoo.cn/opms_libary/micro_srv"
  8. "github.com/gogf/gf/frame/g"
  9. "github.com/smallnest/rpcx/protocol"
  10. )
  11. func main() {
  12. srvAddr := g.Config().GetString("setting.bind-addr")
  13. basePath := g.Config().GetString("setting.srv-name")
  14. // 创建总服务包
  15. s := micro_srv.CreateAndInitService(basePath)
  16. s.RegisterName("Product", new(base.ProductHandler), "")
  17. s.RegisterName("Distributor", new(base.DistributorHandler), "")
  18. s.RegisterName("District", new(base.DistrictHandler), "")
  19. s.RegisterName("Region", new(base.RegionHandler), "")
  20. s.RegisterName("Customer", new(cust.CustomerHeader), "")
  21. s.RegisterName("Contant", new(cust.CustomerContantHeader), "")
  22. s.RegisterName("FollowUp", new(plat.FollowUpHandler), "")
  23. s.RegisterName("FollowUpComment", new(plat.FollowUpCommentHandler), "")
  24. s.RegisterName("FollowUpFile", new(plat.FollowUpFileHandler), "")
  25. s.RegisterName("Task", new(plat.TaskHandler), "")
  26. s.RegisterName("TaskComment", new(plat.TaskCommentHandler), "")
  27. s.RegisterName("TaskLog", new(plat.TaskLogHandler), "")
  28. s.RegisterName("TaskProgress", new(plat.TaskProgressHandler), "")
  29. // 注册服务对象
  30. //s.RegisterName("Auth", new(handler.Auth), "")
  31. // 注册文件处理Service对象
  32. //dynamic.BeanFactory.BeanRegister(service.NewRoleService())
  33. // 注册auth处理
  34. s.AuthFunc = handleAuth
  35. // 运行服务
  36. if err := s.Serve("tcp", srvAddr); err != nil {
  37. g.Log().Fatal(err)
  38. }
  39. }
  40. // AuthExcludePaths 设定不需要认证的路径
  41. var AuthExcludePaths = []string{
  42. "/Auth/Login",
  43. "/Role/GetRoleList",
  44. "/Common/GetCaptchaImg",
  45. "/Model/*",
  46. "/Organize/GetOrgTreeList",
  47. "/User/SendResetPasswordEmail",
  48. "/User/ResetPasswordFromEmail",
  49. }
  50. // 处理Auth
  51. func handleAuth(ctx context.Context, req *protocol.Message, token string) error {
  52. return micro_srv.HandleAuth(ctx, req, token, AuthExcludePaths)
  53. }