common.go 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. package models
  2. import "hongze/hongze_edb_lib/utils"
  3. // BaseEdbInfoInterface 基础指标接口
  4. type BaseEdbInfoInterface interface {
  5. Add(params AddCalculateBatchParams) (edbInfo *EdbInfo, err error, errMsg string)
  6. Edit(params EditCalculateBatchParams) (err error, errMsg string)
  7. Refresh(params RefreshParams) (err error, errMsg string)
  8. GetSourceName() string
  9. }
  10. // AddCalculateBatchParams 添加的请求参
  11. type AddCalculateBatchParams struct {
  12. Req *EdbInfoCalculateBatchSaveReq
  13. FromEdbInfo *EdbInfo
  14. EdbCode string
  15. UniqueCode string
  16. SysUserId int
  17. SysUserRealName string
  18. }
  19. // EditCalculateBatchParams 编辑的请求参
  20. type EditCalculateBatchParams struct {
  21. Req *EdbInfoCalculateBatchEditReq
  22. EdbInfo *EdbInfo
  23. FromEdbInfo *EdbInfo
  24. }
  25. // RefreshParams 编辑的请求参
  26. type RefreshParams struct {
  27. EdbInfo *EdbInfo
  28. FromEdbInfo *EdbInfo
  29. StartDate string
  30. EndDate string
  31. }
  32. // GetBaseEdbInfoModel 获取普通指标的model
  33. func GetBaseEdbInfoModel(source int) (baseEdbInfoModel BaseEdbInfoInterface) {
  34. switch source {
  35. case utils.DATA_SOURCE_CALCULATE_LJZZJ:
  36. baseEdbInfoModel = Ljzzj{}
  37. case utils.DATA_SOURCE_CALCULATE_LJZ:
  38. baseEdbInfoModel = Ljz{}
  39. case utils.DATA_SOURCE_CALCULATE_LJZNCZJ:
  40. baseEdbInfoModel = LjzNczj{}
  41. default:
  42. }
  43. return
  44. }
  45. // BatchSaveCalculateBatchParams 编辑的请求参
  46. type BatchSaveCalculateBatchParams struct {
  47. Req EdbInfoCalculateBatchSaveReq
  48. EdbInfo *EdbInfo
  49. FromEdbInfo *EdbInfo
  50. EdbCode string
  51. UniqueCode string
  52. SysUserId int
  53. SysUserRealName string
  54. }
  55. // BasePredictEdbInfoInterface 基础指标接口
  56. type BasePredictEdbInfoInterface interface {
  57. Add(params BatchSaveCalculateBatchParams) (edbInfo *EdbInfo, latestDateStr string, latestValue float64, err error, errMsg string)
  58. Edit(params BatchSaveCalculateBatchParams) (latestDateStr string, latestValue float64, err error, errMsg string)
  59. Refresh(params RefreshParams) (latestDateStr string, latestValue float64, err error, errMsg string)
  60. GetSourceName() string
  61. }
  62. // GetBasePredictEdbInfoModel 获取预测指标的model
  63. func GetBasePredictEdbInfoModel(source int) (baseEdbInfoModel BasePredictEdbInfoInterface) {
  64. switch source {
  65. case utils.DATA_SOURCE_PREDICT_CALCULATE_LJZZJ:
  66. baseEdbInfoModel = PredictLjzzj{}
  67. case utils.DATA_SOURCE_PREDICT_CALCULATE_LJZ:
  68. baseEdbInfoModel = PredictLjz{}
  69. case utils.DATA_SOURCE_PREDICT_CALCULATE_LJZNCZJ:
  70. baseEdbInfoModel = PredictLjzNczj{}
  71. default:
  72. }
  73. return
  74. }