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

55 lines
746 B
Go

package blink
import (
"fmt"
)
type GameLink struct {
link
tblpid string //项目id
tblgid string //游戏id
}
func NewGameLink(host, tblpid string, opts ...GameLinkOption) GameLink {
l := GameLink{
link: link{
host: host,
},
tblpid: tblpid,
}
for _, opt := range opts {
opt(&l)
}
return l
}
// AddOption 追加参数
func (l GameLink) AddOption(opts ...GameLinkOption) GameLink {
for _, opt := range opts {
opt(&l)
}
return l
}
// Link 游戏链接
func (l GameLink) Link() string {
return l.params(l.host)
}
// 参数
func (l GameLink) params(link string) (url string) {
url = fmt.Sprintf(
"%s&%s=%s",
link,
gameProjectIdKey,
l.tblpid,
)
url = queryAddStr(url, gameLinkIdKey, l.tblgid)
return
}