serviceContext.go 406 B

1234567891011121314151617181920212223
  1. package svc
  2. import (
  3. "git.rtzhtech.cn/iss/public-lib/config"
  4. "git.rtzhtech.cn/iss/public-lib/dao"
  5. )
  6. var SvcCtx *ServiceContext
  7. type ServiceContext struct {
  8. Config config.Config
  9. *dao.Query
  10. }
  11. func NewServiceContext(c *config.Config) (*ServiceContext, error) {
  12. conn, err := dao.ConnectDb(c)
  13. dao.TableInfo(c)
  14. SvcCtx = &ServiceContext{
  15. Config: *c,
  16. Query: dao.Use(conn),
  17. }
  18. return SvcCtx, err
  19. }