Files
ssq-desk/internal/module/ssq_module.go
2026-01-14 14:17:38 +08:00

43 lines
816 B
Go
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

package module
import (
"context"
"ssq-desk/internal/api"
)
// SsqModule 双色球查询模块
type SsqModule struct {
BaseModule
ssqAPI *api.SsqAPI
}
// NewSsqModule 创建双色球查询模块
func NewSsqModule() (*SsqModule, error) {
// 延迟初始化,等到 Init() 方法调用时再创建 API此时数据库已初始化
return &SsqModule{
BaseModule: BaseModule{
name: "ssq",
api: nil, // 延迟初始化
},
ssqAPI: nil, // 延迟初始化
}, nil
}
// Init 初始化模块
func (m *SsqModule) Init(ctx context.Context) error {
if m.ssqAPI == nil {
ssqAPI, err := api.NewSsqAPI()
if err != nil {
return err
}
m.ssqAPI = ssqAPI
m.api = ssqAPI
}
return nil
}
// SsqAPI 返回 SSQ API类型安全
func (m *SsqModule) SsqAPI() *api.SsqAPI {
return m.ssqAPI
}