diff --git a/api/engine_handler.go b/api/engine_handler.go index 5da8f60..eff4802 100644 --- a/api/engine_handler.go +++ b/api/engine_handler.go @@ -1,3 +1,15 @@ +// Copyright (c) 2023 +// +// @author 贺鹏Kavin +// 微信公众号:技术岁月 +// https://github.com/skyhackvip/risk_engine +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// package api import ( diff --git a/api/router.go b/api/router.go index 282589c..be7a62e 100644 --- a/api/router.go +++ b/api/router.go @@ -1,3 +1,15 @@ +// Copyright (c) 2023 +// +// @author 贺鹏Kavin +// 微信公众号:技术岁月 +// https://github.com/skyhackvip/risk_engine +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// package api import ( diff --git a/cmd/risk_engine/engine.go b/cmd/risk_engine/engine.go index 0141979..a5aa38c 100644 --- a/cmd/risk_engine/engine.go +++ b/cmd/risk_engine/engine.go @@ -1,3 +1,15 @@ +// Copyright (c) 2023 +// +// @author 贺鹏Kavin +// 微信公众号:技术岁月 +// https://github.com/skyhackvip/risk_engine +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// package main import ( diff --git a/configs/config.go b/configs/config.go index 69d3862..1f8b053 100644 --- a/configs/config.go +++ b/configs/config.go @@ -1,3 +1,15 @@ +// Copyright (c) 2023 +// +// @author 贺鹏Kavin +// 微信公众号:技术岁月 +// https://github.com/skyhackvip/risk_engine +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// package configs import ( diff --git a/configs/const.go b/configs/const.go index 2e34386..29c74cc 100644 --- a/configs/const.go +++ b/configs/const.go @@ -1,3 +1,15 @@ +// Copyright (c) 2023 +// +// @author 贺鹏Kavin +// 微信公众号:技术岁月 +// https://github.com/skyhackvip/risk_engine +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// package configs //all operators diff --git a/core/abtest.go b/core/abtest.go index 27a35ba..e8a4be8 100644 --- a/core/abtest.go +++ b/core/abtest.go @@ -1,3 +1,15 @@ +// Copyright (c) 2023 +// +// @author 贺鹏Kavin +// 微信公众号:技术岁月 +// https://github.com/skyhackvip/risk_engine +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// package core import ( diff --git a/core/common.go b/core/common.go index 35b0f73..45482b1 100644 --- a/core/common.go +++ b/core/common.go @@ -1,3 +1,15 @@ +// Copyright (c) 2023 +// +// @author 贺鹏Kavin +// 微信公众号:技术岁月 +// https://github.com/skyhackvip/risk_engine +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// package core import ( diff --git a/core/conditional.go b/core/conditional.go index 55b530c..e95b7eb 100644 --- a/core/conditional.go +++ b/core/conditional.go @@ -1,3 +1,15 @@ +// Copyright (c) 2023 +// +// @author 贺鹏Kavin +// 微信公众号:技术岁月 +// https://github.com/skyhackvip/risk_engine +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// package core import ( diff --git a/core/dsl.go b/core/dsl.go index 3ff11cb..02cd9a1 100644 --- a/core/dsl.go +++ b/core/dsl.go @@ -1,3 +1,15 @@ +// Copyright (c) 2023 +// +// @author 贺鹏Kavin +// 微信公众号:技术岁月 +// https://github.com/skyhackvip/risk_engine +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// package core import ( diff --git a/core/end.go b/core/end.go index e9df28c..842cdfc 100644 --- a/core/end.go +++ b/core/end.go @@ -1,3 +1,15 @@ +// Copyright (c) 2023 +// +// @author 贺鹏Kavin +// 微信公众号:技术岁月 +// https://github.com/skyhackvip/risk_engine +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// package core import ( diff --git a/core/feature.go b/core/feature.go index 2c5c504..e21ed60 100644 --- a/core/feature.go +++ b/core/feature.go @@ -1,3 +1,15 @@ +// Copyright (c) 2023 +// +// @author 贺鹏Kavin +// 微信公众号:技术岁月 +// https://github.com/skyhackvip/risk_engine +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// package core import ( diff --git a/core/feature_test.go b/core/feature_test.go index ac5da08..0ec4655 100644 --- a/core/feature_test.go +++ b/core/feature_test.go @@ -1,3 +1,15 @@ +// Copyright (c) 2023 +// +// @author 贺鹏Kavin +// 微信公众号:技术岁月 +// https://github.com/skyhackvip/risk_engine +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// package core import ( diff --git a/core/flow.go b/core/flow.go index 3baac40..55fd495 100644 --- a/core/flow.go +++ b/core/flow.go @@ -1,3 +1,15 @@ +// Copyright (c) 2023 +// +// @author 贺鹏Kavin +// 微信公众号:技术岁月 +// https://github.com/skyhackvip/risk_engine +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// package core import ( diff --git a/core/inode.go b/core/inode.go index 7a9e414..ce9e8b0 100644 --- a/core/inode.go +++ b/core/inode.go @@ -1,3 +1,15 @@ +// Copyright (c) 2023 +// +// @author 贺鹏Kavin +// 微信公众号:技术岁月 +// https://github.com/skyhackvip/risk_engine +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// package core //各类型节点实现该接口 diff --git a/core/kernel.go b/core/kernel.go index 42c4c52..a358db7 100644 --- a/core/kernel.go +++ b/core/kernel.go @@ -1,3 +1,15 @@ +// Copyright (c) 2023 +// +// @author 贺鹏Kavin +// 微信公众号:技术岁月 +// https://github.com/skyhackvip/risk_engine +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// package core import ( diff --git a/core/matrix.go b/core/matrix.go index 84e0709..16b6be3 100644 --- a/core/matrix.go +++ b/core/matrix.go @@ -1,3 +1,15 @@ +// Copyright (c) 2023 +// +// @author 贺鹏Kavin +// 微信公众号:技术岁月 +// https://github.com/skyhackvip/risk_engine +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// package core import ( diff --git a/core/pipeline.go b/core/pipeline.go index 40b98e7..2434f1b 100644 --- a/core/pipeline.go +++ b/core/pipeline.go @@ -1,3 +1,15 @@ +// Copyright (c) 2023 +// +// @author 贺鹏Kavin +// 微信公众号:技术岁月 +// https://github.com/skyhackvip/risk_engine +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// package core import ( diff --git a/core/ruleset.go b/core/ruleset.go index 12f27c6..9813e80 100644 --- a/core/ruleset.go +++ b/core/ruleset.go @@ -1,3 +1,15 @@ +// Copyright (c) 2023 +// +// @author 贺鹏Kavin +// 微信公众号:技术岁月 +// https://github.com/skyhackvip/risk_engine +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// package core import ( diff --git a/core/scorecard.go b/core/scorecard.go index cac0469..388ea84 100644 --- a/core/scorecard.go +++ b/core/scorecard.go @@ -1,3 +1,15 @@ +// Copyright (c) 2023 +// +// @author 贺鹏Kavin +// 微信公众号:技术岁月 +// https://github.com/skyhackvip/risk_engine +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// package core import ( diff --git a/core/start.go b/core/start.go index 972d6c8..6dd1f6f 100644 --- a/core/start.go +++ b/core/start.go @@ -1,3 +1,15 @@ +// Copyright (c) 2023 +// +// @author 贺鹏Kavin +// 微信公众号:技术岁月 +// https://github.com/skyhackvip/risk_engine +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// package core import ( diff --git a/core/tree.go b/core/tree.go index 3a480e1..4299985 100644 --- a/core/tree.go +++ b/core/tree.go @@ -1,3 +1,15 @@ +// Copyright (c) 2023 +// +// @author 贺鹏Kavin +// 微信公众号:技术岁月 +// https://github.com/skyhackvip/risk_engine +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// package core import ( diff --git a/core/udf/avg.go b/core/udf/avg.go index 745c7f9..a24128d 100644 --- a/core/udf/avg.go +++ b/core/udf/avg.go @@ -1 +1,13 @@ +// Copyright (c) 2023 +// +// @author 贺鹏Kavin +// 微信公众号:技术岁月 +// https://github.com/skyhackvip/risk_engine +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// package udf diff --git a/core/udf/max.go b/core/udf/max.go index 745c7f9..a24128d 100644 --- a/core/udf/max.go +++ b/core/udf/max.go @@ -1 +1,13 @@ +// Copyright (c) 2023 +// +// @author 贺鹏Kavin +// 微信公众号:技术岁月 +// https://github.com/skyhackvip/risk_engine +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// package udf diff --git a/core/udf/min.go b/core/udf/min.go index 745c7f9..a24128d 100644 --- a/core/udf/min.go +++ b/core/udf/min.go @@ -1 +1,13 @@ +// Copyright (c) 2023 +// +// @author 贺鹏Kavin +// 微信公众号:技术岁月 +// https://github.com/skyhackvip/risk_engine +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// package udf diff --git a/core/udf/sum.go b/core/udf/sum.go index 8d74750..e6fd83f 100644 --- a/core/udf/sum.go +++ b/core/udf/sum.go @@ -1,3 +1,15 @@ +// Copyright (c) 2023 +// +// @author 贺鹏Kavin +// 微信公众号:技术岁月 +// https://github.com/skyhackvip/risk_engine +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// package udf import ( diff --git a/core/udf/udf_test.go b/core/udf/udf_test.go index 7dce557..b0b55f0 100644 --- a/core/udf/udf_test.go +++ b/core/udf/udf_test.go @@ -1,3 +1,15 @@ +// Copyright (c) 2023 +// +// @author 贺鹏Kavin +// 微信公众号:技术岁月 +// https://github.com/skyhackvip/risk_engine +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// package udf import ( diff --git a/global/config.go b/global/config.go index fa17825..3f75235 100644 --- a/global/config.go +++ b/global/config.go @@ -1,3 +1,15 @@ +// Copyright (c) 2023 +// +// @author 贺鹏Kavin +// 微信公众号:技术岁月 +// https://github.com/skyhackvip/risk_engine +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// package global import ( diff --git a/global/strategy.go b/global/strategy.go index 194954d..2263df1 100644 --- a/global/strategy.go +++ b/global/strategy.go @@ -1,3 +1,15 @@ +// Copyright (c) 2023 +// +// @author 贺鹏Kavin +// 微信公众号:技术岁月 +// https://github.com/skyhackvip/risk_engine +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// package global import ( diff --git a/global/udf.go b/global/udf.go index 6350565..f26cbde 100644 --- a/global/udf.go +++ b/global/udf.go @@ -1,3 +1,15 @@ +// Copyright (c) 2023 +// +// @author 贺鹏Kavin +// 微信公众号:技术岁月 +// https://github.com/skyhackvip/risk_engine +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// package global import ( diff --git a/internal/dto/engine.go b/internal/dto/engine.go index a4be986..f2c31cb 100644 --- a/internal/dto/engine.go +++ b/internal/dto/engine.go @@ -1,3 +1,15 @@ +// Copyright (c) 2023 +// +// @author 贺鹏Kavin +// 微信公众号:技术岁月 +// https://github.com/skyhackvip/risk_engine +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// package dto import () diff --git a/internal/errcode/common_error.go b/internal/errcode/common_error.go index ece657c..112ee4c 100644 --- a/internal/errcode/common_error.go +++ b/internal/errcode/common_error.go @@ -1,3 +1,15 @@ +// Copyright (c) 2023 +// +// @author 贺鹏Kavin +// 微信公众号:技术岁月 +// https://github.com/skyhackvip/risk_engine +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// package errcode var ( diff --git a/internal/errcode/dsl_error.go b/internal/errcode/dsl_error.go index 0b7914a..aef0a52 100644 --- a/internal/errcode/dsl_error.go +++ b/internal/errcode/dsl_error.go @@ -1,3 +1,15 @@ +// Copyright (c) 2023 +// +// @author 贺鹏Kavin +// 微信公众号:技术岁月 +// https://github.com/skyhackvip/risk_engine +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// package errcode var DslErrorNotFound = NewError(404, "dsl not found error") diff --git a/internal/errcode/error.go b/internal/errcode/error.go index bb2d719..298ade9 100644 --- a/internal/errcode/error.go +++ b/internal/errcode/error.go @@ -1,3 +1,15 @@ +// Copyright (c) 2023 +// +// @author 贺鹏Kavin +// 微信公众号:技术岁月 +// https://github.com/skyhackvip/risk_engine +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// package errcode import "fmt" diff --git a/internal/errcode/parse_error.go b/internal/errcode/parse_error.go index 058eee8..3775a10 100644 --- a/internal/errcode/parse_error.go +++ b/internal/errcode/parse_error.go @@ -1,3 +1,15 @@ +// Copyright (c) 2023 +// +// @author 贺鹏Kavin +// 微信公众号:技术岁月 +// https://github.com/skyhackvip/risk_engine +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// package errcode var ( diff --git a/internal/log/default_logger.go b/internal/log/default_logger.go index f248e8d..b27a70f 100644 --- a/internal/log/default_logger.go +++ b/internal/log/default_logger.go @@ -1,3 +1,15 @@ +// Copyright (c) 2023 +// +// @author 贺鹏Kavin +// 微信公众号:技术岁月 +// https://github.com/skyhackvip/risk_engine +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// package log import ( diff --git a/internal/log/logger.go b/internal/log/logger.go index 9898e5f..c96d794 100644 --- a/internal/log/logger.go +++ b/internal/log/logger.go @@ -1,3 +1,15 @@ +// Copyright (c) 2023 +// +// @author 贺鹏Kavin +// 微信公众号:技术岁月 +// https://github.com/skyhackvip/risk_engine +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// package log import ( diff --git a/internal/log/logger_test.go b/internal/log/logger_test.go index 8fb6a3f..98213fc 100644 --- a/internal/log/logger_test.go +++ b/internal/log/logger_test.go @@ -1,3 +1,15 @@ +// Copyright (c) 2023 +// +// @author 贺鹏Kavin +// 微信公众号:技术岁月 +// https://github.com/skyhackvip/risk_engine +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// package log import ( diff --git a/internal/operator/array_op.go b/internal/operator/array_op.go index 0ac5464..26338da 100644 --- a/internal/operator/array_op.go +++ b/internal/operator/array_op.go @@ -1,3 +1,15 @@ +// Copyright (c) 2023 +// +// @author 贺鹏Kavin +// 微信公众号:技术岁月 +// https://github.com/skyhackvip/risk_engine +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// package operator // jundge val in arr diff --git a/internal/operator/compare.go b/internal/operator/compare.go index 418e373..e9c67cd 100644 --- a/internal/operator/compare.go +++ b/internal/operator/compare.go @@ -1,3 +1,15 @@ +// Copyright (c) 2023 +// +// @author 贺鹏Kavin +// 微信公众号:技术岁月 +// https://github.com/skyhackvip/risk_engine +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// package operator import ( diff --git a/internal/operator/eval.go b/internal/operator/eval.go index 98b5194..8995936 100644 --- a/internal/operator/eval.go +++ b/internal/operator/eval.go @@ -1,3 +1,15 @@ +// Copyright (c) 2023 +// +// @author 贺鹏Kavin +// 微信公众号:技术岁月 +// https://github.com/skyhackvip/risk_engine +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// package operator import ( diff --git a/internal/udf/avg.go b/internal/udf/avg.go deleted file mode 100644 index 745c7f9..0000000 --- a/internal/udf/avg.go +++ /dev/null @@ -1 +0,0 @@ -package udf diff --git a/internal/udf/max.go b/internal/udf/max.go deleted file mode 100644 index 745c7f9..0000000 --- a/internal/udf/max.go +++ /dev/null @@ -1 +0,0 @@ -package udf diff --git a/internal/udf/min.go b/internal/udf/min.go deleted file mode 100644 index 745c7f9..0000000 --- a/internal/udf/min.go +++ /dev/null @@ -1 +0,0 @@ -package udf diff --git a/internal/udf/sum.go b/internal/udf/sum.go deleted file mode 100644 index 8d74750..0000000 --- a/internal/udf/sum.go +++ /dev/null @@ -1,41 +0,0 @@ -package udf - -import ( - "github.com/skyhackvip/risk_engine/configs" - "github.com/skyhackvip/risk_engine/internal/util" - "reflect" -) - -//sum return float64 -func Sum(v interface{}) (interface{}, error) { - kind, err := util.GetType(v) - switch kind { - case configs.INT: - return util.ToFloat64(v) - case configs.FLOAT: - return util.ToFloat64(v) - case configs.ARRAY: - var rs float64 - if reflect.TypeOf(v).Kind() == reflect.Array { //array like [3]int - varr := reflect.ValueOf(v) - for i := 0; i < varr.Len(); i++ { - df, err := util.RVToFloat64(varr.Index(i)) //if array contains nan, return err - if err != nil { - return nil, err - } - rs += df - } - } else { //slice - vslice := v.([]interface{}) - for _, va := range vslice { - df, err := util.ToFloat64(va) //if slice contains nan, return err - if err != nil { - return nil, err - } - rs += df - } - } - return rs, nil - } - return nil, err -} diff --git a/internal/udf/udf.go b/internal/udf/udf.go index 5a7c2ec..79a625c 100644 --- a/internal/udf/udf.go +++ b/internal/udf/udf.go @@ -1,24 +1,15 @@ +// Copyright (c) 2023 +// +// @author 贺鹏Kavin +// 微信公众号:技术岁月 +// https://github.com/skyhackvip/risk_engine +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// package udf -import ( -// "sync" -) - type Udf func(interface{}) (interface{}, error) - -/* -var udfMap map[string]Udf = make(map[string]Udf) -var mu sync.RWMutex - -func RegisterUdf(key string, fn Udf) { - mu.Lock() - defer mu.Unlock() - udfMap[key] = fn //override if exists -} - -func GetUdf(key string) Udf { - mu.RLock() - defer mu.RUnlock() - return udfMap[key] -} -*/ diff --git a/internal/udf/udf_test.go b/internal/udf/udf_test.go deleted file mode 100644 index 7dce557..0000000 --- a/internal/udf/udf_test.go +++ /dev/null @@ -1,18 +0,0 @@ -package udf - -import ( - "testing" -) - -func TestSum(t *testing.T) { - t.Log(Sum(100)) - t.Log(Sum(100.5)) - t.Log(Sum([]interface{}{3.3, 100, 5.0, 8})) - t.Log(Sum([]interface{}{3.3, 100, 5.0, 8, "88"})) - t.Log(Sum([]interface{}{3.3, 100, 5.0, 8, true})) - t.Log(Sum([]interface{}{3.3, 100, 5.0, 8, "8ab"})) - t.Log(Sum([3]int{3, 4, 5})) - t.Log(Sum([3]float32{3.0, 4.1, 5})) - t.Log(Sum([3]string{"3.0", "4.1", "5"})) - t.Log(Sum([3]string{"3.a", "b.1", "5"})) -} diff --git a/internal/util/time_util.go b/internal/util/time_util.go index 565ec1c..8324a86 100644 --- a/internal/util/time_util.go +++ b/internal/util/time_util.go @@ -1,3 +1,15 @@ +// Copyright (c) 2023 +// +// @author 贺鹏Kavin +// 微信公众号:技术岁月 +// https://github.com/skyhackvip/risk_engine +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// package util import ( diff --git a/internal/util/time_util_test.go b/internal/util/time_util_test.go index 06f7f01..3b91bd0 100644 --- a/internal/util/time_util_test.go +++ b/internal/util/time_util_test.go @@ -1,3 +1,15 @@ +// Copyright (c) 2023 +// +// @author 贺鹏Kavin +// 微信公众号:技术岁月 +// https://github.com/skyhackvip/risk_engine +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// package util import ( diff --git a/internal/util/type_util.go b/internal/util/type_util.go index 7d09d2f..6af2f32 100644 --- a/internal/util/type_util.go +++ b/internal/util/type_util.go @@ -1,3 +1,15 @@ +// Copyright (c) 2023 +// +// @author 贺鹏Kavin +// 微信公众号:技术岁月 +// https://github.com/skyhackvip/risk_engine +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// package util import ( diff --git a/internal/util/type_util_test.go b/internal/util/type_util_test.go index 1b7f920..a2c5586 100644 --- a/internal/util/type_util_test.go +++ b/internal/util/type_util_test.go @@ -1,3 +1,15 @@ +// Copyright (c) 2023 +// +// @author 贺鹏Kavin +// 微信公众号:技术岁月 +// https://github.com/skyhackvip/risk_engine +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// package util import ( diff --git a/service/service.go b/service/service.go index 59662cd..cd7b93a 100644 --- a/service/service.go +++ b/service/service.go @@ -1,3 +1,15 @@ +// Copyright (c) 2023 +// +// @author 贺鹏Kavin +// 微信公众号:技术岁月 +// https://github.com/skyhackvip/risk_engine +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// package service import (