message.go 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. package data_manage_permission
  2. import (
  3. "eta_gn/eta_api/models/data_manage/data_manage_permission"
  4. "eta_gn/eta_api/utils"
  5. )
  6. type MessageDetailItem struct {
  7. DataPermissionMoveRecordId int64 ` orm:"column(data_permission_move_record_id);pk" gorm:"primaryKey" ` // 数据操作记录id
  8. Source int32 // 数据来源,1:手工数据指标 2:钢联化工数据库 3:ETA指标库 4:ETA预测指标 5:图库 6:ETA表格
  9. SubSource int32 // 子来源 :ETA表格中的各种表格类型,以及图表的来源(这个是后续的扩展方向)
  10. OpUniqueCode string // 操作的唯一编码,主要是记录统一操作的日志
  11. DataId string // 资产id(指标、图表、表格)
  12. DataCode string // 资产code(指标、图表、表格)
  13. DataName string // 资产名称(指标、图表、表格)
  14. OriginalUserId int32 // 原创建人id
  15. OriginalUserName string // 原创建人名称
  16. NewUserId int32 // 新创建人id
  17. NewUserName string // 新创建人名称
  18. CreateTime string
  19. }
  20. func GetMessageDetail(messageInfo *data_manage_permission.DataPermissionMessage, source, subSource, startSize, pageSize int) (total int, resp interface{}, err error) {
  21. switch messageInfo.OpType {
  22. case 1, 2:
  23. tmpTotal, list, tmpErr := data_manage_permission.GetDataPermissionMoveRecordListByOpUniqueCode(messageInfo.OpUniqueCode, source, subSource, startSize, pageSize)
  24. if tmpErr != nil {
  25. err = tmpErr
  26. return
  27. }
  28. total = tmpTotal
  29. resp, err = formatMessageDetailItemByDataPermissionMoveRecord(list)
  30. case 3:
  31. tmpTotal, list, tmpErr := data_manage_permission.GetDataPermissionNoAuthRecordListByUserId(messageInfo.ReceiveUserId, messageInfo.Source, messageInfo.SubSource, startSize, pageSize)
  32. if tmpErr != nil {
  33. err = tmpErr
  34. return
  35. }
  36. total = tmpTotal
  37. resp, err = formatMessageDetailItemByDataPermissionNoAuthRecord(list)
  38. case 4:
  39. tmpTotal, list, tmpErr := data_manage_permission.GetDataPermissionClassifyNoAuthRecordListByUserId(messageInfo.ReceiveUserId, messageInfo.Source, messageInfo.SubSource, startSize, pageSize)
  40. if tmpErr != nil {
  41. err = tmpErr
  42. return
  43. }
  44. total = tmpTotal
  45. resp, err = formatMessageDetailItemByDataPermissionClassifyNoAuthRecord(list)
  46. }
  47. return
  48. }
  49. func formatMessageDetailItemByDataPermissionMoveRecord(items []*data_manage_permission.DataPermissionMoveRecord) (resp []*MessageDetailItem, err error) {
  50. resp = make([]*MessageDetailItem, 0)
  51. for _, v := range items {
  52. resp = append(resp, &MessageDetailItem{
  53. DataPermissionMoveRecordId: v.DataPermissionMoveRecordId,
  54. Source: v.Source,
  55. SubSource: v.SubSource,
  56. OpUniqueCode: v.OpUniqueCode,
  57. DataId: v.DataId,
  58. DataCode: v.DataCode,
  59. DataName: v.DataName,
  60. OriginalUserId: v.OriginalUserId,
  61. OriginalUserName: v.OriginalUserName,
  62. NewUserId: v.NewUserId,
  63. NewUserName: v.NewUserName,
  64. CreateTime: utils.TimeTransferString(utils.FormatDateTime, v.CreateTime),
  65. })
  66. }
  67. return
  68. }
  69. func formatMessageDetailItemByDataPermissionNoAuthRecord(items []*data_manage_permission.DataPermissionNoAuthRecord) (resp []*MessageDetailItem, err error) {
  70. resp = make([]*MessageDetailItem, 0)
  71. for _, v := range items {
  72. resp = append(resp, &MessageDetailItem{
  73. DataPermissionMoveRecordId: v.DataPermissionNoAuthRecordId,
  74. Source: v.Source,
  75. SubSource: v.SubSource,
  76. OpUniqueCode: v.OpUniqueCode,
  77. DataId: v.DataId,
  78. DataCode: v.DataCode,
  79. DataName: v.DataName,
  80. CreateTime: utils.TimeTransferString(utils.FormatDateTime, v.CreateTime),
  81. })
  82. }
  83. return
  84. }
  85. func formatMessageDetailItemByDataPermissionClassifyNoAuthRecord(items []*data_manage_permission.DataPermissionClassifyNoAuthRecord) (resp []*MessageDetailItem, err error) {
  86. resp = make([]*MessageDetailItem, 0)
  87. for _, v := range items {
  88. resp = append(resp, &MessageDetailItem{
  89. DataPermissionMoveRecordId: v.DataPermissionClassifyNoAuthRecordId,
  90. Source: v.Source,
  91. SubSource: v.SubSource,
  92. OpUniqueCode: v.OpUniqueCode,
  93. DataId: v.ClassifyId,
  94. DataCode: v.ClassifyId,
  95. DataName: v.ClassifyName,
  96. CreateTime: utils.TimeTransferString(utils.FormatDateTime, v.CreateTime),
  97. })
  98. }
  99. return
  100. }