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.
34 lines
770 B
34 lines
770 B
package service
|
|
|
|
import (
|
|
"context"
|
|
"practice_Go/internal/model/do"
|
|
"practice_Go/internal/model/entity"
|
|
)
|
|
|
|
// 1.定义接口
|
|
type IClubs interface {
|
|
GetClubs(ctx context.Context) (clubs []entity.GoClubs, err error)
|
|
GetClubShows(ctx context.Context) (shows []entity.GoShows, err error)
|
|
AddClub(ctx context.Context, club do.GoShows) (err error)
|
|
EditClub(ctx context.Context, club do.GoClubs) (err error)
|
|
DeleteClub(ctx context.Context) (err error)
|
|
}
|
|
|
|
// 2.定义接口变量
|
|
var localClub IClubs
|
|
|
|
// 3.定义获取接口实例的函数
|
|
func GetClubs() IClubs {
|
|
if localClub == nil {
|
|
panic("IClubs接口未实现或未注册")
|
|
} else {
|
|
return localClub
|
|
|
|
}
|
|
}
|
|
|
|
// 4.定义一个接口实现的注册方法
|
|
func RegisterClubs(club IClubs) {
|
|
localClub = club
|
|
}
|