main.go 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  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("Belong", new(cust.CustBelongHeader), "")
  23. s.RegisterName("FollowUp", new(plat.FollowUpHandler), "")
  24. s.RegisterName("FollowUpComment", new(plat.FollowUpCommentHandler), "")
  25. s.RegisterName("FollowUpFile", new(plat.FollowUpFileHandler), "")
  26. s.RegisterName("Task", new(plat.TaskHandler), "")
  27. s.RegisterName("TaskComment", new(plat.TaskCommentHandler), "")
  28. s.RegisterName("TaskLog", new(plat.TaskLogHandler), "")
  29. s.RegisterName("TaskProgress", new(plat.TaskProgressHandler), "")
  30. // 注册服务对象
  31. //s.RegisterName("Auth", new(handler.Auth), "")
  32. // 注册文件处理Service对象
  33. //dynamic.BeanFactory.BeanRegister(service.NewRoleService())
  34. // 注册auth处理
  35. s.AuthFunc = handleAuth
  36. // 运行服务
  37. if err := s.Serve("tcp", srvAddr); err != nil {
  38. g.Log().Fatal(err)
  39. }
  40. }
  41. // AuthExcludePaths 设定不需要认证的路径
  42. var AuthExcludePaths = []string{
  43. "/Auth/Login",
  44. "/Role/GetRoleList",
  45. "/Common/GetCaptchaImg",
  46. "/Model/*",
  47. "/Organize/GetOrgTreeList",
  48. "/User/SendResetPasswordEmail",
  49. "/User/ResetPasswordFromEmail",
  50. }
  51. // 处理Auth
  52. func handleAuth(ctx context.Context, req *protocol.Message, token string) error {
  53. return micro_srv.HandleAuth(ctx, req, token, AuthExcludePaths)
  54. }