| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566 |
- package main
- import (
- "context"
- "dashoo.cn/micro/app/handler/plat"
- "dashoo.cn/micro/app/handler/base"
- "dashoo.cn/micro/app/handler/cust"
- "dashoo.cn/opms_libary/micro_srv"
- "github.com/gogf/gf/frame/g"
- "github.com/smallnest/rpcx/protocol"
- )
- func main() {
- srvAddr := g.Config().GetString("setting.bind-addr")
- basePath := g.Config().GetString("setting.srv-name")
- // 创建总服务包
- s := micro_srv.CreateAndInitService(basePath)
- s.RegisterName("Product", new(base.ProductHandler), "")
- s.RegisterName("Distributor", new(base.DistributorHandler), "")
- s.RegisterName("District", new(base.DistrictHandler), "")
- s.RegisterName("Region", new(base.RegionHandler), "")
- s.RegisterName("Customer", new(cust.CustomerHeader), "")
- s.RegisterName("Contant", new(cust.CustomerContantHeader), "")
- s.RegisterName("Belong", new(cust.CustBelongHeader), "")
- s.RegisterName("FollowUp", new(plat.FollowUpHandler), "")
- s.RegisterName("FollowUpComment", new(plat.FollowUpCommentHandler), "")
- s.RegisterName("FollowUpFile", new(plat.FollowUpFileHandler), "")
- s.RegisterName("Task", new(plat.TaskHandler), "")
- s.RegisterName("TaskComment", new(plat.TaskCommentHandler), "")
- s.RegisterName("TaskLog", new(plat.TaskLogHandler), "")
- s.RegisterName("TaskProgress", new(plat.TaskProgressHandler), "")
- // 注册服务对象
- //s.RegisterName("Auth", new(handler.Auth), "")
- // 注册文件处理Service对象
- //dynamic.BeanFactory.BeanRegister(service.NewRoleService())
- // 注册auth处理
- s.AuthFunc = handleAuth
- // 运行服务
- if err := s.Serve("tcp", srvAddr); err != nil {
- g.Log().Fatal(err)
- }
- }
- // AuthExcludePaths 设定不需要认证的路径
- var AuthExcludePaths = []string{
- "/Auth/Login",
- "/Role/GetRoleList",
- "/Common/GetCaptchaImg",
- "/Model/*",
- "/Organize/GetOrgTreeList",
- "/User/SendResetPasswordEmail",
- "/User/ResetPasswordFromEmail",
- }
- // 处理Auth
- func handleAuth(ctx context.Context, req *protocol.Message, token string) error {
- return micro_srv.HandleAuth(ctx, req, token, AuthExcludePaths)
- }
|