main.go 2.0 KB

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