ermcpCommon.go 853 B

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