You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

32 lines
776 B

  1. package service
  2. import (
  3. "context"
  4. "practice_Go/internal/model/do"
  5. "practice_Go/internal/model/entity"
  6. )
  7. // 1.定义接口
  8. type IShows interface {
  9. GetShows(ctx context.Context) (shows []entity.GoShows, err error)
  10. GetVideos(ctx context.Context) (videos []entity.GoShows, err error)
  11. AddShow(ctx context.Context, show do.GoShows) (err error)
  12. EditShow(ctx context.Context, show do.GoShows) (err error)
  13. DeleteShow(ctx context.Context) (err error) //id通过路径中获取
  14. }
  15. // 2.定义接口变量
  16. var localShow IShows
  17. // 3.定义获取接口实例的函数
  18. func GetShows() IShows {
  19. if localShow == nil {
  20. panic("IShows未实现或未注册")
  21. }
  22. return localShow
  23. }
  24. // 4.定义一个接口实现的注册方法
  25. func RegisterShows(show IShows) {
  26. localShow = show
  27. }