f
This commit is contained in:
@@ -226,10 +226,30 @@ func (s *ApiApplicationServiceImpl) validateApiCall(ctx context.Context, cmd *co
|
|||||||
|
|
||||||
// 4. 验证IP白名单(非开发环境)
|
// 4. 验证IP白名单(非开发环境)
|
||||||
if !s.config.App.IsDevelopment() && !cmd.Options.IsDebug {
|
if !s.config.App.IsDevelopment() && !cmd.Options.IsDebug {
|
||||||
|
// 添加调试日志
|
||||||
|
s.logger.Info("开始验证白名单",
|
||||||
|
zap.String("userId", apiUser.UserId),
|
||||||
|
zap.String("clientIP", cmd.ClientIP),
|
||||||
|
zap.Bool("isDevelopment", s.config.App.IsDevelopment()),
|
||||||
|
zap.Bool("isDebug", cmd.Options.IsDebug),
|
||||||
|
zap.Int("whiteListCount", len(apiUser.WhiteList)))
|
||||||
|
|
||||||
|
// 输出白名单详细信息(用于调试)
|
||||||
|
for idx, item := range apiUser.WhiteList {
|
||||||
|
s.logger.Info("白名单项",
|
||||||
|
zap.Int("index", idx),
|
||||||
|
zap.String("ipAddress", item.IPAddress),
|
||||||
|
zap.String("remark", item.Remark))
|
||||||
|
}
|
||||||
|
|
||||||
if !apiUser.IsWhiteListed(cmd.ClientIP) {
|
if !apiUser.IsWhiteListed(cmd.ClientIP) {
|
||||||
s.logger.Error("IP不在白名单内", zap.String("userId", apiUser.UserId), zap.String("ip", cmd.ClientIP))
|
s.logger.Error("IP不在白名单内",
|
||||||
|
zap.String("userId", apiUser.UserId),
|
||||||
|
zap.String("ip", cmd.ClientIP),
|
||||||
|
zap.Int("whiteListSize", len(apiUser.WhiteList)))
|
||||||
return nil, ErrInvalidIP
|
return nil, ErrInvalidIP
|
||||||
}
|
}
|
||||||
|
s.logger.Info("白名单验证通过", zap.String("ip", cmd.ClientIP))
|
||||||
}
|
}
|
||||||
|
|
||||||
// 5. 验证钱包状态
|
// 5. 验证钱包状态
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ func convertTianYanChaError(err error) error {
|
|||||||
|
|
||||||
// 检查天眼查服务的错误类型,转换为处理器层的标准错误
|
// 检查天眼查服务的错误类型,转换为处理器层的标准错误
|
||||||
if errors.Is(err, tianyancha.ErrNotFound) {
|
if errors.Is(err, tianyancha.ErrNotFound) {
|
||||||
return errors.Join(processors.ErrNotFound, err)
|
return nil
|
||||||
}
|
}
|
||||||
if errors.Is(err, tianyancha.ErrDatasource) {
|
if errors.Is(err, tianyancha.ErrDatasource) {
|
||||||
return errors.Join(processors.ErrDatasource, err)
|
return errors.Join(processors.ErrDatasource, err)
|
||||||
|
|||||||
@@ -166,6 +166,7 @@ func (t *TianYanChaService) CallAPI(ctx context.Context, apiCode string, params
|
|||||||
Message: tianYanChaResp.Reason,
|
Message: tianYanChaResp.Reason,
|
||||||
Data: tianYanChaResp.Result,
|
Data: tianYanChaResp.Result,
|
||||||
}, nil
|
}, nil
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 成功情况
|
// 成功情况
|
||||||
|
|||||||
@@ -63,4 +63,5 @@ func (r *UserRoutes) Register(router *sharedhttp.GinRouter) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
r.logger.Info("用户路由注册完成")
|
r.logger.Info("用户路由注册完成")
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user