servicecontext.go 409 B

1234567891011121314151617181920
  1. package svc
  2. import (
  3. "shorturl/rpc/transform/internal/config"
  4. "shorturl/rpc/transform/model"
  5. "github.com/tal-tech/go-zero/core/stores/sqlx"
  6. )
  7. type ServiceContext struct {
  8. c config.Config
  9. Model *model.ShorturlModel
  10. }
  11. func NewServiceContext(c config.Config) *ServiceContext {
  12. return &ServiceContext{
  13. c: c,
  14. Model: model.NewShorturlModel(sqlx.NewMysql(c.DataSource), c.Cache, c.Table),
  15. }
  16. }