fix: 修复validAuthDate验证器未定义错误
This commit is contained in:
@@ -104,29 +104,6 @@ func (s *ProductApplicationServiceImpl) DeleteProduct(ctx context.Context, cmd *
|
|||||||
func (s *ProductApplicationServiceImpl) ListProducts(ctx context.Context, filters map[string]interface{}, options interfaces.ListOptions) (*responses.ProductListResponse, error) {
|
func (s *ProductApplicationServiceImpl) ListProducts(ctx context.Context, filters map[string]interface{}, options interfaces.ListOptions) (*responses.ProductListResponse, error) {
|
||||||
// 检查是否有用户ID,如果有则使用带订阅状态的方法
|
// 检查是否有用户ID,如果有则使用带订阅状态的方法
|
||||||
if userID, ok := filters["user_id"].(string); ok && userID != "" {
|
if userID, ok := filters["user_id"].(string); ok && userID != "" {
|
||||||
// 测试日志系统 - 主动记录错误信息
|
|
||||||
s.logger.Error("测试错误日志记录",
|
|
||||||
zap.String("method", "ListProducts"),
|
|
||||||
zap.String("error_type", "test_error"),
|
|
||||||
zap.String("error_message", "这是一个测试错误,用于验证日志系统"),
|
|
||||||
zap.Int("products_count", 0),
|
|
||||||
zap.Int64("total", 0),
|
|
||||||
zap.String("test_scenario", "主动错误记录测试"),
|
|
||||||
)
|
|
||||||
|
|
||||||
// 测试日志系统 - 记录一些信息
|
|
||||||
s.logger.Info("准备测试日志系统",
|
|
||||||
zap.String("method", "ListProducts"),
|
|
||||||
zap.Int("products_count", 0),
|
|
||||||
zap.Int64("total", 0),
|
|
||||||
)
|
|
||||||
|
|
||||||
// 测试日志系统 - 模拟空指针异常
|
|
||||||
s.logger.Warn("即将触发空指针异常进行测试")
|
|
||||||
|
|
||||||
// // 模拟空指针异常,用于测试
|
|
||||||
// var testPtr *int
|
|
||||||
// _ = *testPtr // 这里会触发空指针异常
|
|
||||||
return s.ListProductsWithSubscriptionStatus(ctx, filters, options)
|
return s.ListProductsWithSubscriptionStatus(ctx, filters, options)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -79,6 +79,7 @@ func RegisterCustomValidators(validate *validator.Validate) {
|
|||||||
|
|
||||||
// 授权日期验证器
|
// 授权日期验证器
|
||||||
validate.RegisterValidation("auth_date", validateAuthDate)
|
validate.RegisterValidation("auth_date", validateAuthDate)
|
||||||
|
validate.RegisterValidation("validAuthDate", validateAuthDate)
|
||||||
|
|
||||||
// 授权书URL验证器
|
// 授权书URL验证器
|
||||||
validate.RegisterValidation("authorization_url", validateAuthorizationURL)
|
validate.RegisterValidation("authorization_url", validateAuthorizationURL)
|
||||||
|
|||||||
Reference in New Issue
Block a user