/** * @Author: zou.yingbin * @Create : 2021/3/30 14:51 * @Modify : 2021/3/30 14:51 * @Note : Ermcp定义一些公共的方法或变量 */ package models import ( "encoding/hex" "fmt" "math" "mtp2_if/utils" ) type ReportType int // IErmcp 通用接口 type IErmcp interface { calc() // 相关计算和数据处理 buildSql() string // 生成sql语句 GetDataEx() (interface{}, error) // 获取数据接口 } // DecryptField 解密字段 func DecryptField(oriStr string) string { nLen := len(oriStr) if nLen < 32 || nLen%16 != 0 { // 非加密字符串 return oriStr } key := "0d299ce2d4105282f7471074cb0f9f9d" key2, _ := hex.DecodeString(key) if oriStr == "" { return oriStr } d, _ := hex.DecodeString(oriStr) if dst, err := utils.AESDecrypt(d, key2); err == nil { return string(dst) } return oriStr } // DecodeStr 类似于问号表达式, true返回第1个 false返回第2个 func DecodeStr(condition bool, strTrue, strFalse string) string { if condition { return strTrue } return strFalse } // InStr func InStr(param ...interface{}) string { var str string for i := range param { if len(str) > 0 { str += "," } str += fmt.Sprintf("%v", param[i]) } return str } type ZOOMFUN func(vList ...*float64) // NewZoomFun 创建缩放函数 func NewZoomFun(decimalplace int) ZOOMFUN { return func(vList ...*float64) { for i := range vList { *vList[i] = *vList[i] / math.Pow10(decimalplace) } } } // ZoomByDecimal func ZoomByDecimal(decimalplace int, vList ...*float64) { for i := range vList { *vList[i] = *vList[i] / math.Pow10(decimalplace) } }