From 053a302c806b05f0f1503ecc8f01f4741d9e083c Mon Sep 17 00:00:00 2001 From: liangzai <2440983361@qq.com> Date: Sat, 16 Aug 2025 13:06:51 +0800 Subject: [PATCH] fix --- app/main/api/etc/main.dev.yaml | 2 ++ app/main/api/etc/main.yaml | 2 ++ app/main/api/internal/config/config.go | 4 +++ .../internal/logic/query/queryservicelogic.go | 25 ++++++++++++------- 4 files changed, 24 insertions(+), 9 deletions(-) diff --git a/app/main/api/etc/main.dev.yaml b/app/main/api/etc/main.dev.yaml index ba41758..9cc251b 100644 --- a/app/main/api/etc/main.dev.yaml +++ b/app/main/api/etc/main.dev.yaml @@ -90,3 +90,5 @@ Tianyuanapi: Key: "2732f526167c2de9b8dc6aa0f24ba8b7" BaseURL: "https://api.tianyuanapi.com" Timeout: 60 +VerifyConfig: + TwoFactor: true diff --git a/app/main/api/etc/main.yaml b/app/main/api/etc/main.yaml index b3e87da..8f5807e 100644 --- a/app/main/api/etc/main.yaml +++ b/app/main/api/etc/main.yaml @@ -77,3 +77,5 @@ Tianyuanapi: Key: "2732f526167c2de9b8dc6aa0f24ba8b7" BaseURL: "https://api.tianyuanapi.com" Timeout: 60 +VerifyConfig: + TwoFactor: true diff --git a/app/main/api/internal/config/config.go b/app/main/api/internal/config/config.go index 3c18d5f..5d5e1f7 100644 --- a/app/main/api/internal/config/config.go +++ b/app/main/api/internal/config/config.go @@ -23,6 +23,7 @@ type Config struct { AdminPromotion AdminPromotion CleanTask CleanTask Tianyuanapi TianyuanapiConfig + VerifyConfig VerifyConfig } // JwtAuth 用于 JWT 鉴权配置 @@ -112,3 +113,6 @@ type TianyuanapiConfig struct { BaseURL string Timeout int64 } +type VerifyConfig struct { + TwoFactor bool +} diff --git a/app/main/api/internal/logic/query/queryservicelogic.go b/app/main/api/internal/logic/query/queryservicelogic.go index 13124b9..5fb4da0 100644 --- a/app/main/api/internal/logic/query/queryservicelogic.go +++ b/app/main/api/internal/logic/query/queryservicelogic.go @@ -77,27 +77,34 @@ func (l *QueryServiceLogic) VerifyCode(mobile string, code string) error { // 三要素验证 func (l *QueryServiceLogic) Verify(Name string, IDCard string, Mobile string) error { - fmt.Println("Mobile", Mobile) - // 下午18点到次日早上8点半调用二要素,其余时间三要素 - now := time.Now() - // 获取当前小时和分钟 - hour := now.Hour() - minute := now.Minute() + // fmt.Println("Mobile", Mobile) + // // 下午18点到次日早上8点半调用二要素,其余时间三要素 + // now := time.Now() + // // 获取当前小时和分钟 + // hour := now.Hour() + // minute := now.Minute() // 判断是否在18:00到次日8:30之间 - if hour >= 18 || (hour < 8) || (hour == 8 && minute < 30) { - // 二要素验证 + // if hour >= 18 || (hour < 8) || (hour == 8 && minute < 30) { + // 二要素验证 + if l.svcCtx.Config.VerifyConfig.TwoFactor { twoFactorsErr := l.VerifyTwoFactors(Name, IDCard) if twoFactorsErr != nil { return twoFactorsErr } } else { - // 三要素验证 threeFactorsErr := l.VerifyThreeFactors(Name, IDCard, Mobile) if threeFactorsErr != nil { return threeFactorsErr } } + // } else { + // // 三要素验证 + // threeFactorsErr := l.VerifyThreeFactors(Name, IDCard, Mobile) + // if threeFactorsErr != nil { + // return threeFactorsErr + // } + // } return nil }