servicecontext.go 379 B

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