From 5831eefd4f2797545681d267c5d10726d9302dfe Mon Sep 17 00:00:00 2001 From: renzhiyuan <465386466@qq.com> Date: Mon, 5 Jan 2026 15:52:16 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BC=98=E5=8C=96=E7=99=BB=E5=BD=95?= =?UTF-8?q?=E9=85=8D=E7=BD=AE=E5=92=8CAPI=E8=B0=83=E7=94=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- config/config.yaml | 20 +++++++--- config/config_env.yaml | 1 - config/config_test.yaml | 10 ++++- internal/biz/ding_talk_bot.go | 37 ++++++++++--------- internal/domain/repo/repos.go | 5 ++- .../statistics_ours_product/client.go | 12 ++++-- .../statistics_ours_product/client_test.go | 26 ++++++++++--- .../recharge/statistics_ours_product.go | 11 ++++-- internal/pkg/lsxd/login.go | 18 ++++----- internal/pkg/lsxd/login_test.go | 15 ++++---- internal/server/cron.go | 12 +++--- internal/services/cron.go | 2 +- internal/services/dtalk_bot_test.go | 2 +- 13 files changed, 104 insertions(+), 67 deletions(-) diff --git a/config/config.yaml b/config/config.yaml index 5585caf..f577673 100644 --- a/config/config.yaml +++ b/config/config.yaml @@ -21,19 +21,27 @@ vllm: coze: base_url: "https://api.coze.cn" - api_secret: "sat_AqvFcdNgesP8megy1ItTscWFXRcsHRzmM4NJ1KNavfcdT0EPwYuCPkDqGhItpx13" + redis: + host: 47.97.27.195:6379 + type: node + pass: + lansexiongdi@666i_secret: "sat_AqvFcdNgesP8megy1ItTscWFXRcsHRzmM4NJ1KNavfcdT0EPwYuCPkDqGhItpx13" +lsxd: + # 统一登录 + login_url: "http://api.test.user.1688sup.com/v1/login/phone" + phone: "0zmINhJBwsDJYTmeaxXK4A==" + password: "LSSGoWhc63NpZc1rq3LT8g==" + check_token_url: "http://api.test.user.1688sup.com/v1/user/welcome" + + sys: session_len: 6 channel_pool_len: 100 channel_pool_size: 32 llm_pool_len: 5 heartbeat_interval: 30 -redis: - host: 47.97.27.195:6379 - type: node - pass: lansexiongdi@666 key: report-api pollSize: 5 #连接池大小,不配置,或配置为0表示不启用连接池 minIdleConns: 2 #最小空闲连接数 @@ -128,7 +136,7 @@ eino_tools: # 我们的商品统计 rechargeStatisticsOursProduct: base_url: "http://admin.lanseds.cn/admin/statistics/oursProduct" - api_key: "eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJ1c2VyQ2VudGVyIiwiZXhwIjoxNzY3MTc5ODgzLCJuYmYiOjE3NjcxNjkwODMsImp0aSI6IjEiLCJQaG9uZSI6IjE4MjAwMTYwMTQzIiwiVXNlck5hbWUiOiJsc3hkIiwiUmVhbE5hbWUiOiLotoXnuqfnrqHnkIblkZgiLCJBY2NvdW50VHlwZSI6MiwiR3JvdXBDb2RlcyI6IkxTWEREU19TWVNURU0sU1RBVElTVElDQUxTWVNURU1fQURNSU4sUEhZU0lDQUxHT09EU19BRE1JTiIsIkRpbmdVc2VySWQiOiIifQ.ELNF1Iv6yEwA12nCbXGKwXCw-F5Gq4GI2t2nqo1PlSkFdQ5Oz5s5NwV0RUXA66LxCggI-9IjBtFI1MvBHpvTHq9QRlm-HKzVTMcOBkEtKEfCCI6SPKVTAZyntTJlWPKG3u-CJUotT5YW0j2rU1VcpA7uGEiY7gs5VPUOZ80R1uGJ7HBSqVI2DRqar6STa1xryygdCjK7qamUM2d6aJ6r9VPTBt-JO6dkDdw3KHs3wl-PGM3wcbXHZ2aC18WFd_PxLmtjqErpxTEkdUBCnUHOSKDePG0henDJq71Nh3yRdRmY9VvszHMyIxJA2BVGPIPUT_Y5aewaaEMQVEjhiBnn-Q" + excel2pic: base_url: "http://192.168.6.109:8010/api/v1/convert" diff --git a/config/config_env.yaml b/config/config_env.yaml index c56d1d3..f43c683 100644 --- a/config/config_env.yaml +++ b/config/config_env.yaml @@ -132,7 +132,6 @@ eino_tools: # 我们的商品统计 rechargeStatisticsOursProduct: base_url: "http://admin.1688sup.cn:8001/admin/statistics/oursProduct" - api_key: "eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJ1c2VyQ2VudGVyIiwiZXhwIjoxNzY3MDc3NzcwLCJuYmYiOjE3NjcwNzU5NzAsImp0aSI6IjEiLCJQaG9uZSI6IjE4MDAwMDAwMDAwIiwiVXNlck5hbWUiOiJsc3hkIiwiUmVhbE5hbWUiOiLotoXnuqfnrqHnkIblkZgiLCJBY2NvdW50VHlwZSI6MSwiR3JvdXBDb2RlcyI6IlZDTF9DQVNISUVSLFZDTF9PUEVSQVRFLFZDTF9BRE1JTixWQ0xfQUFBLFZDTF9WQ0xfT1BFUkFULFZDTF9JTlZPSUNFLENSTV9BRE1JTixMSUFOTElBTl9BRE1JTixNQVJLRVRNQUcyX0FETUlOLFBIT05FQklMTF9BRE1JTixRSUFOWkhVX1NVUFBFUl9BRE0sTUFSS0VUSU5HU0FBU19TVVBFUkFETUlOLENBUkRfQ09ERSxDQVJEX1BST0NVUkVNRU5ULE1BUktFVElOR1NZU1RFTV9TVVBFUixTVEFUSVNUSUNBTFNZU1RFTV9BRE1JTixaTFRYX0FETUlOLFpMVFhfT1BFUkFURSIsIkRpbmdVc2VySWQiOiIxNjIwMjYxMjMwMjg5MzM4MzQifQ.Nuw_aR6iSPmhhh9E5rhyTxHBsgWtaTZvbnc7SFTnUBJXTQvYahnk0LyZaVpsVw6FB3cU0F5xOdX3rmGyWyaiszWO6yi-o1oxGMXwhf39fMiWT2xUI6pAn9Ync8DmZ4tOMCNUTdEk4CaQFzrTwJs0c-VR4yW6LgoPmNPvUVZ-KwmusUpnPz5j9RsJItzIWE3bpGGsfB54e2UERcZdbo9BXxCZIBbpAYKBKdl73KuI8SNaXgKvGTrJ6hEN4ESpnbisJVwT5pp_kuChJlcfjHTHFsEf4RJDjN9gTrtDbBWZyY3OmO2ukqYAM7tZPs6TXJwvQGJQsFRVZUBGxS1nD_6DzQ" excel2pic: base_url: "http://192.168.6.109:8010/api/v1/convert" diff --git a/config/config_test.yaml b/config/config_test.yaml index 19a7745..fea7ffe 100644 --- a/config/config_test.yaml +++ b/config/config_test.yaml @@ -24,6 +24,13 @@ coze: api_secret: "sat_AqvFcdNgesP8megy1ItTscWFXRcsHRzmM4NJ1KNavfcdT0EPwYuCPkDqGhItpx13" +lsxd: + # 统一登录 + login_url: "http://api.test.user.1688sup.com/v1/login/phone" + phone: "0zmINhJBwsDJYTmeaxXK4A==" + password: "LSSGoWhc63NpZc1rq3LT8g==" + check_token_url: "http://api.test.user.1688sup.com/v1/user/welcome" + sys: session_len: 6 channel_pool_len: 100 @@ -127,8 +134,7 @@ eino_tools: # == 电商充值系统 == # 我们的商品统计 rechargeStatisticsOursProduct: - base_url: "http://admin.lanseds.cn/admin/statistics/oursProduct" - api_key: "eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJ1c2VyQ2VudGVyIiwiZXhwIjoxNzY3MTc5ODgzLCJuYmYiOjE3NjcxNjkwODMsImp0aSI6IjEiLCJQaG9uZSI6IjE4MjAwMTYwMTQzIiwiVXNlck5hbWUiOiJsc3hkIiwiUmVhbE5hbWUiOiLotoXnuqfnrqHnkIblkZgiLCJBY2NvdW50VHlwZSI6MiwiR3JvdXBDb2RlcyI6IkxTWEREU19TWVNURU0sU1RBVElTVElDQUxTWVNURU1fQURNSU4sUEhZU0lDQUxHT09EU19BRE1JTiIsIkRpbmdVc2VySWQiOiIifQ.ELNF1Iv6yEwA12nCbXGKwXCw-F5Gq4GI2t2nqo1PlSkFdQ5Oz5s5NwV0RUXA66LxCggI-9IjBtFI1MvBHpvTHq9QRlm-HKzVTMcOBkEtKEfCCI6SPKVTAZyntTJlWPKG3u-CJUotT5YW0j2rU1VcpA7uGEiY7gs5VPUOZ80R1uGJ7HBSqVI2DRqar6STa1xryygdCjK7qamUM2d6aJ6r9VPTBt-JO6dkDdw3KHs3wl-PGM3wcbXHZ2aC18WFd_PxLmtjqErpxTEkdUBCnUHOSKDePG0henDJq71Nh3yRdRmY9VvszHMyIxJA2BVGPIPUT_Y5aewaaEMQVEjhiBnn-Q" + base_url: "http://admin.1688sup.cn:8001/admin/statistics/oursProduct" excel2pic: base_url: "http://192.168.6.109:8010/api/v1/convert" diff --git a/internal/biz/ding_talk_bot.go b/internal/biz/ding_talk_bot.go index 175fab4..56c08a2 100644 --- a/internal/biz/ding_talk_bot.go +++ b/internal/biz/ding_talk_bot.go @@ -633,27 +633,28 @@ func (d *DingTalkBotBiz) HandleStreamRes(ctx context.Context, data *chatbot.BotC func (d *DingTalkBotBiz) GetReportLists(ctx context.Context, group *model.AiBotGroup) (reports []*bbxt.ReportRes, err error) { - reportList, err := bbxt.NewBbxtTools() - if err != nil { - return - } - var product []string - if group.ProductName != "" { - product = strings.Split(group.ProductName, ",") - } - //[]string{"官方-爱奇艺-星钻季卡", "官方-爱奇艺-星钻半年卡", "官方--腾讯-年卡", "官方--爱奇艺-月卡"} - reports, err = reportList.DailyReport(time.Now(), bbxt.DownWardValue, product, bbxt.SumFilter, d.ossClient) - if err != nil { + //var product []string + //if group.ProductName != "" { + // product = strings.Split(group.ProductName, ",") + //} + + //reportList, err := bbxt.NewBbxtTools() + //if err != nil { + // return + //} + + //reports, err = reportList.DailyReport(time.Now(), bbxt.DownWardValue, product, bbxt.SumFilter, d.ossClient) + //if err != nil { + // return + //} + //product = []string{"优酷周卡", "优酷季卡", "优酷年卡", "爱奇艺黄金会员天卡"} + //追加电商充值系统统计 - 返回统一使用[]*bbxt.ReportRes + rechargeReports, err := d.rechargeDailyReport(ctx, time.Now(), nil, d.ossClient) + if err != nil || len(rechargeReports) == 0 { return } - // 追加电商充值系统统计 - 返回统一使用 []*bbxt.ReportRes - //rechargeReports, err := d.rechargeDailyReport(ctx, time.Now(), product, d.ossClient) - //if err != nil || len(rechargeReports) == 0 { - // return - //} - // - //reports = append(reports, rechargeReports...) + reports = append(reports, rechargeReports...) return } diff --git a/internal/domain/repo/repos.go b/internal/domain/repo/repos.go index 0350d95..8f1f6c0 100644 --- a/internal/domain/repo/repos.go +++ b/internal/domain/repo/repos.go @@ -4,18 +4,21 @@ import ( "ai_scheduler/internal/config" "ai_scheduler/internal/data/impl" "ai_scheduler/internal/pkg/utils_oss" + "ai_scheduler/utils" ) // Repos 聚合所有 Repository type Repos struct { Session SessionRepo OssClient *utils_oss.Client + Rdb *utils.Rdb } -func NewRepos(sessionImpl *impl.SessionImpl, cfg *config.Config) *Repos { +func NewRepos(sessionImpl *impl.SessionImpl, cfg *config.Config, rdb *utils.Rdb) *Repos { ossClient, _ := utils_oss.NewClient(cfg) return &Repos{ Session: NewSessionAdapter(sessionImpl), OssClient: ossClient, + Rdb: rdb, } } diff --git a/internal/domain/tools/recharge/statistics_ours_product/client.go b/internal/domain/tools/recharge/statistics_ours_product/client.go index a9706b9..514e190 100644 --- a/internal/domain/tools/recharge/statistics_ours_product/client.go +++ b/internal/domain/tools/recharge/statistics_ours_product/client.go @@ -3,6 +3,8 @@ package statistics_ours_product import ( "ai_scheduler/internal/config" "ai_scheduler/internal/pkg/l_request" + "ai_scheduler/internal/pkg/lsxd" + "ai_scheduler/utils" "context" "encoding/json" "fmt" @@ -14,14 +16,16 @@ type Client struct { cfg config.ToolConfig } +// New 是一个客户端构造函数,接收一个 config.ToolConfig 类型的配置参数 +// 返回一个初始化后的 Client 指针 func New(cfg config.ToolConfig) *Client { return &Client{ - cfg: cfg, + cfg: cfg, // 将传入的配置参数赋值给 Client 结构体的 cfg 字段 } } // Call 调用我们的商品统计接口 -func (c *Client) Call(ctx context.Context, req StatisticsOursProductRequest) ([]StatisticsOursProductItem, error) { +func (c *Client) Call(ctx context.Context, req StatisticsOursProductRequest, rdb *utils.Rdb, lsxdcfg *config.LSXDConfig) ([]StatisticsOursProductItem, error) { // 构建 URL 参数 var queryParams []string @@ -44,9 +48,9 @@ func (c *Client) Call(ctx context.Context, req StatisticsOursProductRequest) ([] queryString := strings.Join(queryParams, "&") fullURL := fmt.Sprintf("%s?%s", c.cfg.BaseURL, queryString) - + token := lsxd.NewLogin(lsxdcfg, rdb).GetToken(ctx) headers := map[string]string{ - "Authorization": fmt.Sprintf("Bearer %s", c.cfg.APIKey), + "Authorization": fmt.Sprintf("Bearer %s", token), } reqObj := l_request.Request{ diff --git a/internal/domain/tools/recharge/statistics_ours_product/client_test.go b/internal/domain/tools/recharge/statistics_ours_product/client_test.go index 4789fba..cc464a5 100644 --- a/internal/domain/tools/recharge/statistics_ours_product/client_test.go +++ b/internal/domain/tools/recharge/statistics_ours_product/client_test.go @@ -2,17 +2,33 @@ package statistics_ours_product import ( "ai_scheduler/internal/config" + "ai_scheduler/utils" "context" "testing" ) func TestClient_Call(t *testing.T) { - cfg := config.ToolConfig{ - BaseURL: "http://admin.1688sup.cn:8001/admin/statistics/oursProduct", - APIKey: "eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJ1c2VyQ2VudGVyIiwiZXhwIjoxNzY3MDc3NzcwLCJuYmYiOjE3NjcwNzU5NzAsImp0aSI6IjEiLCJQaG9uZSI6IjE4MDAwMDAwMDAwIiwiVXNlck5hbWUiOiJsc3hkIiwiUmVhbE5hbWUiOiLotoXnuqfnrqHnkIblkZgiLCJBY2NvdW50VHlwZSI6MSwiR3JvdXBDb2RlcyI6IlZDTF9DQVNISUVSLFZDTF9PUEVSQVRFLFZDTF9BRE1JTixWQ0xfQUFBLFZDTF9WQ0xfT1BFUkFULFZDTF9JTlZPSUNFLENSTV9BRE1JTixMSUFOTElBTl9BRE1JTixNQVJLRVRNQUcyX0FETUlOLFBIT05FQklMTF9BRE1JTixRSUFOWkhVX1NVUFBFUl9BRE0sTUFSS0VUSU5HU0FBU19TVVBFUkFETUlOLENBUkRfQ09ERSxDQVJEX1BST0NVUkVNRU5ULE1BUktFVElOR1NZU1RFTV9TVVBFUixTVEFUSVNUSUNBTFNZU1RFTV9BRE1JTixaTFRYX0FETUlOLFpMVFhfT1BFUkFURSIsIkRpbmdVc2VySWQiOiIxNjIwMjYxMjMwMjg5MzM4MzQifQ.Nuw_aR6iSPmhhh9E5rhyTxHBsgWtaTZvbnc7SFTnUBJXTQvYahnk0LyZaVpsVw6FB3cU0F5xOdX3rmGyWyaiszWO6yi-o1oxGMXwhf39fMiWT2xUI6pAn9Ync8DmZ4tOMCNUTdEk4CaQFzrTwJs0c-VR4yW6LgoPmNPvUVZ-KwmusUpnPz5j9RsJItzIWE3bpGGsfB54e2UERcZdbo9BXxCZIBbpAYKBKdl73KuI8SNaXgKvGTrJ6hEN4ESpnbisJVwT5pp_kuChJlcfjHTHFsEf4RJDjN9gTrtDbBWZyY3OmO2ukqYAM7tZPs6TXJwvQGJQsFRVZUBGxS1nD_6DzQ", + rdb := utils.NewRdb(&config.Config{ + Redis: config.Redis{ + Host: "47.97.27.195:6379", + Pass: "lansexiongdi@666", + Key: "report-api-test", + }, + }) + + configEino := config.ToolConfig{ + BaseURL: "http://admin.1688sup.cn:8001/admin/statistics/oursProduct", + APIKey: "OFJ8UpqOlI7+w3Qklf36ZA==", + APISecret: "tEbFegH/DRRh6LutFb7o3g==", + } + configLSXD := &config.LSXDConfig{ + LoginURL: "http://api.test.user.1688sup.com/v1/login/phone", + Phone: "0zmINhJBwsDJYTmeaxXK4A==", + Password: "LSSGoWhc63NpZc1rq3LT8g==", + CheckTokenURL: "http://api.test.user.1688sup.com/v1/user/welcome", } - client := New(cfg) + client := New(configEino) req := StatisticsOursProductRequest{ Page: 1, @@ -24,7 +40,7 @@ func TestClient_Call(t *testing.T) { // 由于没有真实的后端环境和 Token,这里注释掉实际调用 // 在开发环境中,你可以取消注释并填入有效的 Token 进行测试 - res, err := client.Call(context.Background(), req) + res, err := client.Call(context.Background(), req, rdb, configLSXD) if err != nil { t.Logf("Call failed: %v", err) } else { diff --git a/internal/domain/workflow/recharge/statistics_ours_product.go b/internal/domain/workflow/recharge/statistics_ours_product.go index 19a6351..549ade4 100644 --- a/internal/domain/workflow/recharge/statistics_ours_product.go +++ b/internal/domain/workflow/recharge/statistics_ours_product.go @@ -8,6 +8,7 @@ import ( "ai_scheduler/internal/domain/tools/recharge/statistics_ours_product" "ai_scheduler/internal/domain/workflow/runtime" "ai_scheduler/internal/pkg/utils_oss" + "ai_scheduler/utils" "context" "errors" "fmt" @@ -24,7 +25,7 @@ const WorkflowIDStatisticsOursProduct = "recharge.statisticsOursProduct" func init() { runtime.Register(WorkflowIDStatisticsOursProduct, func(d *runtime.Deps) (runtime.Workflow, error) { - return &statisticsOursProduct{cfg: d.Conf, toolManager: d.ToolManager, ossClient: d.Repos.OssClient}, nil + return &statisticsOursProduct{cfg: d.Conf, toolManager: d.ToolManager, ossClient: d.Repos.OssClient, rdb: d.Repos.Rdb}, nil }) } @@ -32,6 +33,7 @@ type statisticsOursProduct struct { cfg *config.Config toolManager *toolManager.Manager ossClient *utils_oss.Client + rdb *utils.Rdb } type StatisticsOursProductWorkflowInput struct { @@ -103,7 +105,8 @@ func (w *statisticsOursProduct) buildWorkflow(ctx context.Context) (compose.Runn // formatContext 整理上下文参数 func (w *statisticsOursProduct) formatContext(ctx context.Context, input *StatisticsOursProductWorkflowInput) (*StatisticsOursProductContext, error) { - startTime := input.Time.Format("2006010200") + //startTime := input.Time.Format("2006010200") + startTime := "2025010500" endTime := input.Time.Format("2006010215") endTimeStr := input.Time.Format("1.2号15点") @@ -122,7 +125,7 @@ func (w *statisticsOursProduct) callStatisticsTool(ctx context.Context, state *S Serial: []string{state.StartTime, state.EndTime}, } - dataList, err := w.toolManager.Recharge.StatisticsOursProduct.Call(ctx, req) + dataList, err := w.toolManager.Recharge.StatisticsOursProduct.Call(ctx, req, w.rdb, &w.cfg.LSXD) if err != nil { log.Errorf("调用统计我们的商品工具失败: %v", err) return nil, fmt.Errorf("获取统计我们的商品数据失败") @@ -138,7 +141,7 @@ func (w *statisticsOursProduct) callStatisticsTool(ctx context.Context, state *S func (w *statisticsOursProduct) generateExcelAndUpload(ctx context.Context, state *StatisticsOursProductContext) (*StatisticsOursProductContext, error) { // 1. 获取模板路径 - cwd, _ := filepath.Abs(".") + cwd, _ := filepath.Abs("../../") templatePath := filepath.Join(cwd, "tmpl", "excel_temp", "recharge_statistics_ours_product.xlsx") fileName := fmt.Sprintf("statistics_ours_product_%d%d", time.Now().Unix(), rand.Intn(1000)) diff --git a/internal/pkg/lsxd/login.go b/internal/pkg/lsxd/login.go index 04dc821..e7be08b 100644 --- a/internal/pkg/lsxd/login.go +++ b/internal/pkg/lsxd/login.go @@ -19,21 +19,19 @@ import ( ) type Login struct { - config *config.Config + config *config.LSXDConfig redisCli *redis.Client mu sync.Mutex } -func NewLogin(config *config.Config, rdb *utils.Rdb) *Login { +func NewLogin(config *config.LSXDConfig, rdb *utils.Rdb) *Login { return &Login{ config: config, redisCli: rdb.Rdb, } } -func (l *Login) GetToken() string { - ctx, cancel := context.WithTimeout(context.Background(), 15*time.Second) - defer cancel() +func (l *Login) GetToken(ctx context.Context) string { token, err := l.getCachedToken(ctx) if err != nil { @@ -74,7 +72,7 @@ func (l *Login) GetToken() string { // 校验token是否有效 func (l *Login) checkTokenValid(ctx context.Context, token string) bool { // 欢迎页校验token有效 - checkTokenURL := l.config.LSXD.CheckTokenURL + checkTokenURL := l.config.CheckTokenURL if checkTokenURL == "" { return token != "" } @@ -96,9 +94,9 @@ func (l *Login) checkTokenValid(ctx context.Context, token string) bool { // 调用登录接口获取token func (l *Login) login(ctx context.Context) (string, error) { // 1.获取配置 - loginURL := l.config.LSXD.LoginURL - phone := l.config.LSXD.Phone - password := l.config.LSXD.Password + loginURL := l.config.LoginURL + phone := l.config.Phone + password := l.config.Password // 2.调用登录接口获取token if loginURL == "" { @@ -111,7 +109,7 @@ func (l *Login) login(ctx context.Context) (string, error) { reqBody := map[string]any{ "phone": phone, "password": password, - "code": "123456", + "code": "456789", } bodyBytes, err := json.Marshal(reqBody) if err != nil { diff --git a/internal/pkg/lsxd/login_test.go b/internal/pkg/lsxd/login_test.go index 6b15133..299899c 100644 --- a/internal/pkg/lsxd/login_test.go +++ b/internal/pkg/lsxd/login_test.go @@ -3,6 +3,7 @@ package lsxd import ( "ai_scheduler/internal/config" "ai_scheduler/utils" + "context" "testing" ) @@ -16,15 +17,13 @@ func TestGetToken(t *testing.T) { }, }) - login := NewLogin(&config.Config{ - LSXD: config.LSXDConfig{ - LoginURL: "http://api.test.user.1688sup.com/v1/login/phone", - Phone: "0zmINhJBwsDJYTmeaxXK4A==", - Password: "LSSGoWhc63NpZc1rq3LT8g==", - CheckTokenURL: "http://api.test.user.1688sup.com/v1/user/welcome", - }, + login := NewLogin(&config.LSXDConfig{ + LoginURL: "http://api.test.user.1688sup.com/v1/login/phone", + Phone: "OFJ8UpqOlI7+w3Qklf36ZA==", + Password: "tEbFegH/DRRh6LutFb7o3g==", + CheckTokenURL: "http://api.test.user.1688sup.com/v1/user/welcome", }, rdb) - token := login.GetToken() + token := login.GetToken(context.Background()) if token == "" { t.Errorf("token is empty") } diff --git a/internal/server/cron.go b/internal/server/cron.go index b096dc8..798de27 100644 --- a/internal/server/cron.go +++ b/internal/server/cron.go @@ -66,13 +66,13 @@ func (c *CronServer) Run(ctx context.Context) { } c.log.Infof("任务[%d]:%s执行结束", jobID, job.Name) }() - + c.log.Infof("任务[%d]:%s执ddd", jobID, job.Name) // 为每次执行创建新的上下文 - ctx := context.Background() - err := job.Func(ctx) - if err != nil { - c.log.Errorf("任务[%d]:%s执行失败: %s", jobID, job.Name, err.Error()) - } + //ctx := context.Background() + //err := job.Func(ctx) + //if err != nil { + // c.log.Errorf("任务[%d]:%s执行失败: %s", jobID, job.Name, err.Error()) + //} }) if err != nil { c.log.Errorf("添加任务失败:%s", err.Error()) diff --git a/internal/services/cron.go b/internal/services/cron.go index 47cbc70..4358781 100644 --- a/internal/services/cron.go +++ b/internal/services/cron.go @@ -22,7 +22,7 @@ func NewCronService(config *config.Config, dingTalkBotBiz *biz.DingTalkBotBiz) * func (d *CronService) CronReportSend(ctx context.Context) error { - groupId := 29 + groupId := 28 groupInfo, err := d.dingTalkBotBiz.GetGroupInfo(ctx, groupId) if err != nil { return err diff --git a/internal/services/dtalk_bot_test.go b/internal/services/dtalk_bot_test.go index bd0ceef..c0a18ce 100644 --- a/internal/services/dtalk_bot_test.go +++ b/internal/services/dtalk_bot_test.go @@ -63,7 +63,7 @@ func run() { // 初始化Redis数据库连接 rdb := utils.NewRdb(configConfig) // 初始化仓库层 - repos := repo.NewRepos(sessionImpl, configConfig) + repos := repo.NewRepos(sessionImpl, configConfig, rdb) // 初始化包级别的Redis连接 pkgRdb := pkg.NewRdb(configConfig)