ermcpCommon.go 749 B

123456789101112131415161718192021222324252627282930313233343536
  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. // IErmcp 通用接口
  13. type IErmcp interface {
  14. calc() // 相关计算和数据处理
  15. buildSql() string // 生成sql语句
  16. GetDataEx() (interface{}, error) // 获取数据接口
  17. }
  18. // DecryptField 解密字段
  19. func DecryptField(oriStr string) string {
  20. key := "0d299ce2d4105282f7471074cb0f9f9d"
  21. key2, _ := hex.DecodeString(key)
  22. if oriStr == "" {
  23. return oriStr
  24. }
  25. d, _ := hex.DecodeString(oriStr)
  26. if dst, err := utils.AESDecrypt(d, key2); err == nil {
  27. return string(dst)
  28. }
  29. return oriStr
  30. }