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
32 lines
776 B
package service
|
|
|
|
import (
|
|
"context"
|
|
"practice_Go/internal/model/do"
|
|
"practice_Go/internal/model/entity"
|
|
)
|
|
|
|
// 1.定义接口
|
|
type IShows interface {
|
|
GetShows(ctx context.Context) (shows []entity.GoShows, err error)
|
|
GetVideos(ctx context.Context) (videos []entity.GoShows, err error)
|
|
AddShow(ctx context.Context, show do.GoShows) (err error)
|
|
EditShow(ctx context.Context, show do.GoShows) (err error)
|
|
DeleteShow(ctx context.Context) (err error) //id通过路径中获取
|
|
}
|
|
|
|
// 2.定义接口变量
|
|
var localShow IShows
|
|
|
|
// 3.定义获取接口实例的函数
|
|
func GetShows() IShows {
|
|
if localShow == nil {
|
|
panic("IShows未实现或未注册")
|
|
}
|
|
return localShow
|
|
}
|
|
|
|
// 4.定义一个接口实现的注册方法
|
|
func RegisterShows(show IShows) {
|
|
localShow = show
|
|
}
|