This commit is contained in:
钱纯净
2025-04-01 18:50:00 +08:00
parent 0f75b402bc
commit 5c0bc2a772
3 changed files with 21 additions and 11 deletions

View File

@@ -3,7 +3,6 @@ package tdx
import (
"github.com/injoyai/ios/client"
"github.com/robfig/cron/v3"
"path/filepath"
"time"
)
@@ -16,11 +15,11 @@ func NewManage(cfg *ManageConfig, op ...client.Option) (*Manage, error) {
if cfg == nil {
cfg = &ManageConfig{}
}
if cfg.CodesDir == "" {
cfg.CodesDir = DefaultDatabaseDir
if cfg.CodesFilename == "" {
cfg.CodesFilename = DefaultDatabaseDir + "/codes.db"
}
if cfg.WorkdayDir == "" {
cfg.WorkdayDir = DefaultDatabaseDir
if cfg.WorkdayFileName == "" {
cfg.WorkdayFileName = DefaultDatabaseDir + "/workday.db"
}
if cfg.Dial == nil {
cfg.Dial = DialDefault
@@ -32,7 +31,7 @@ func NewManage(cfg *ManageConfig, op ...client.Option) (*Manage, error) {
return nil, err
}
codesClient.Wait.SetTimeout(time.Second * 5)
codes, err := NewCodes(codesClient, filepath.Join(cfg.CodesDir, "codes.db"))
codes, err := NewCodes(codesClient, cfg.CodesFilename)
if err != nil {
return nil, err
}
@@ -51,7 +50,7 @@ func NewManage(cfg *ManageConfig, op ...client.Option) (*Manage, error) {
return nil, err
}
workdayClient.Wait.SetTimeout(time.Second * 5)
workday, err := NewWorkday(workdayClient, filepath.Join(cfg.WorkdayDir, "workday.db"))
workday, err := NewWorkday(workdayClient, cfg.WorkdayFileName)
if err != nil {
return nil, err
}
@@ -83,8 +82,8 @@ func (this *Manage) AddWorkdayTask(spec string, f func(m *Manage)) {
}
type ManageConfig struct {
Number int //客户端数量
CodesDir string //代码数据库位置
WorkdayDir string //工作日数据库位置
Dial func(op ...client.Option) (cli *Client, err error) //默认连接方式
Number int //客户端数量
CodesFilename string //代码数据库位置
WorkdayFileName string //工作日数据库位置
Dial func(op ...client.Option) (cli *Client, err error) //默认连接方式
}