ermcpCommon.go 968 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. /**
  2. * @Author: zou.yingbin
  3. * @Create : 2021/3/30 14:51
  4. * @Modify : 2021/3/30 14:51
  5. * @Note : Ermcp定义一些公共的方法或变量
  6. */
  7. package models
  8. import (
  9. "encoding/hex"
  10. "mtp2_if/utils"
  11. )
  12. type ReportType int
  13. // IErmcp 通用接口
  14. type IErmcp interface {
  15. calc() // 相关计算和数据处理
  16. buildSql() string // 生成sql语句
  17. GetDataEx() (interface{}, error) // 获取数据接口
  18. }
  19. // DecryptField 解密字段
  20. func DecryptField(oriStr string) string {
  21. key := "0d299ce2d4105282f7471074cb0f9f9d"
  22. key2, _ := hex.DecodeString(key)
  23. if oriStr == "" {
  24. return oriStr
  25. }
  26. d, _ := hex.DecodeString(oriStr)
  27. if dst, err := utils.AESDecrypt(d, key2); err == nil {
  28. return string(dst)
  29. }
  30. return oriStr
  31. }
  32. // DecodeStr 类似于问号表达式, true返回第1个 false返回第2个
  33. func DecodeStr(condition bool, strTrue, strFalse string) string {
  34. if condition {
  35. return strTrue
  36. }
  37. return strFalse
  38. }