|
|
@@ -146,7 +146,9 @@ func (w *WeatherSceneService) checkWeatherCondition(config WeatherSceneConfig) (
|
|
|
}
|
|
|
results = append(results, utils.CheckValue(condition.TargetValue, weatherInfo[condition.Field], condition.FieldType, condition.Operator))
|
|
|
}
|
|
|
- fmt.Printf("decisionExpr----:%s,results:-------%v", config.DecisionExpr, results)
|
|
|
+ if len(results) == 0 {
|
|
|
+ return false, nil
|
|
|
+ }
|
|
|
switch config.DecisionExpr {
|
|
|
case "and":
|
|
|
for _, v := range results {
|
|
|
@@ -154,14 +156,17 @@ func (w *WeatherSceneService) checkWeatherCondition(config WeatherSceneConfig) (
|
|
|
return false, nil
|
|
|
}
|
|
|
}
|
|
|
+ return true, nil
|
|
|
case "or":
|
|
|
for _, v := range results {
|
|
|
if v {
|
|
|
return true, nil
|
|
|
}
|
|
|
}
|
|
|
+ return false, nil
|
|
|
+ default:
|
|
|
+ return false, errors.New("无效的判断逻辑")
|
|
|
}
|
|
|
- return true, nil
|
|
|
}
|
|
|
|
|
|
func getWeatherInfo(location string) (map[string]interface{}, error) {
|