数据过滤同时增加脱敏

This commit is contained in:
2024-04-07 22:37:14 +08:00
parent 14290e2ec6
commit bf45f6dac4
2 changed files with 31 additions and 2 deletions

View File

@@ -7,7 +7,10 @@
// Date : 2023-05-23 14:25
package data_mask
import "git.zhangdeman.cn/zhangdeman/data_mask/strategy"
import (
"errors"
"git.zhangdeman.cn/zhangdeman/data_mask/strategy"
)
var (
maskInstanceTable = make(map[string]IDataMask)
@@ -47,3 +50,19 @@ func Execute(data string, maskType string) string {
}
return dataMaskInstance.Mask(data)
}
// ExecuteWithError 严格执行
//
// Author : go_developer@163.com<白茶清欢>
//
// Date : 22:33 2024/4/7
func ExecuteWithError(data string, maskType string) (string, error) {
dataMaskInstance, exist := maskInstanceTable[maskType]
if !exist {
return "", errors.New(maskType + " : data mask type is not found")
}
if nil == dataMaskInstance {
return "", errors.New(maskType + " : data mask type instance is nil")
}
return Execute(data, maskType), nil
}