message.go 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  1. package data_manage_permission
  2. import (
  3. "eta/eta_mobile/models/data_manage/data_manage_permission"
  4. "eta/eta_mobile/utils"
  5. )
  6. type MessageDetailItem struct {
  7. DataPermissionMoveRecordId int64 ` orm:"column(data_permission_move_record_id);pk"` // 数据操作记录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. // GetMessageDetail
  21. // @Description: 获取消息详情
  22. // @author: Roc
  23. // @datetime 2024-04-07 10:07:06
  24. // @param messageInfo *data_manage_permission.DataPermissionMessage
  25. // @param source int
  26. // @param subSource int
  27. // @param startSize int
  28. // @param pageSize int
  29. // @return resp interface{}
  30. // @return err error
  31. func GetMessageDetail(messageInfo *data_manage_permission.DataPermissionMessage, source, subSource, startSize, pageSize int) (total int, resp interface{}, err error) {
  32. switch messageInfo.OpType {
  33. // 操作类型,1:单个资产转移,2:资产模块转移,3:资产授权,4:资产分类授权
  34. case 1, 2:
  35. tmpTotal, list, tmpErr := data_manage_permission.GetDataPermissionMoveRecordListByOpUniqueCode(messageInfo.OpUniqueCode, source, subSource, startSize, pageSize)
  36. if tmpErr != nil {
  37. err = tmpErr
  38. return
  39. }
  40. total = tmpTotal
  41. resp, err = formatMessageDetailItemByDataPermissionMoveRecord(list)
  42. case 3:
  43. tmpTotal, list, tmpErr := data_manage_permission.GetDataPermissionNoAuthRecordListByUserId(messageInfo.ReceiveUserId, messageInfo.Source, messageInfo.SubSource, startSize, pageSize)
  44. if tmpErr != nil {
  45. err = tmpErr
  46. return
  47. }
  48. total = tmpTotal
  49. resp, err = formatMessageDetailItemByDataPermissionNoAuthRecord(list)
  50. case 4:
  51. tmpTotal, list, tmpErr := data_manage_permission.GetDataPermissionClassifyNoAuthRecordListByUserId(messageInfo.ReceiveUserId, messageInfo.Source, messageInfo.SubSource, startSize, pageSize)
  52. if tmpErr != nil {
  53. err = tmpErr
  54. return
  55. }
  56. total = tmpTotal
  57. resp, err = formatMessageDetailItemByDataPermissionClassifyNoAuthRecord(list)
  58. }
  59. return
  60. }
  61. // formatMessageDetailItemByDataPermissionMoveRecord
  62. // @Description: 根据转移指标权限数据格式化列表数据
  63. // @author: Roc
  64. // @datetime 2024-04-07 20:20:09
  65. // @param items []*data_manage_permission.DataPermissionMoveRecord
  66. // @return resp []*MessageDetailItem
  67. // @return err error
  68. func formatMessageDetailItemByDataPermissionMoveRecord(items []*data_manage_permission.DataPermissionMoveRecord) (resp []*MessageDetailItem, err error) {
  69. resp = make([]*MessageDetailItem, 0)
  70. for _, v := range items {
  71. resp = append(resp, &MessageDetailItem{
  72. DataPermissionMoveRecordId: v.DataPermissionMoveRecordId,
  73. Source: v.Source,
  74. SubSource: v.SubSource,
  75. OpUniqueCode: v.OpUniqueCode,
  76. DataId: v.DataId,
  77. DataCode: v.DataCode,
  78. DataName: v.DataName,
  79. OriginalUserId: v.OriginalUserId,
  80. OriginalUserName: v.OriginalUserName,
  81. NewUserId: v.NewUserId,
  82. NewUserName: v.NewUserName,
  83. CreateTime: utils.TimeTransferString(utils.FormatDateTime, v.CreateTime),
  84. })
  85. }
  86. return
  87. }
  88. // formatMessageDetailItemByDataPermissionNoAuthRecord
  89. // @Description: 根据资产授权数据权限格式化列表数据
  90. // @author: Roc
  91. // @datetime 2024-04-07 20:20:00
  92. // @param items []*data_manage_permission.DataPermissionNoAuthRecord
  93. // @return resp []*MessageDetailItem
  94. // @return err error
  95. func formatMessageDetailItemByDataPermissionNoAuthRecord(items []*data_manage_permission.DataPermissionNoAuthRecord) (resp []*MessageDetailItem, err error) {
  96. resp = make([]*MessageDetailItem, 0)
  97. for _, v := range items {
  98. resp = append(resp, &MessageDetailItem{
  99. DataPermissionMoveRecordId: v.DataPermissionNoAuthRecordId,
  100. Source: v.Source,
  101. SubSource: v.SubSource,
  102. OpUniqueCode: v.OpUniqueCode,
  103. DataId: v.DataId,
  104. DataCode: v.DataCode,
  105. DataName: v.DataName,
  106. //OriginalUserId: v.OriginalUserId,
  107. //OriginalUserName: v.OriginalUserName,
  108. //NewUserId: v.NewUserId,
  109. //NewUserName: v.NewUserName,
  110. CreateTime: utils.TimeTransferString(utils.FormatDateTime, v.CreateTime),
  111. })
  112. }
  113. return
  114. }
  115. // formatMessageDetailItemByDataPermissionClassifyNoAuthRecord
  116. // @Description: 根据资产分类授权数据权限格式化列表数据
  117. // @author: Roc
  118. // @datetime 2024-04-07 20:19:39
  119. // @param items []*data_manage_permission.DataPermissionClassifyNoAuthRecord
  120. // @return resp []*MessageDetailItem
  121. // @return err error
  122. func formatMessageDetailItemByDataPermissionClassifyNoAuthRecord(items []*data_manage_permission.DataPermissionClassifyNoAuthRecord) (resp []*MessageDetailItem, err error) {
  123. resp = make([]*MessageDetailItem, 0)
  124. for _, v := range items {
  125. resp = append(resp, &MessageDetailItem{
  126. DataPermissionMoveRecordId: v.DataPermissionClassifyNoAuthRecordId,
  127. Source: v.Source,
  128. SubSource: v.SubSource,
  129. OpUniqueCode: v.OpUniqueCode,
  130. DataId: v.ClassifyId,
  131. DataCode: v.ClassifyId,
  132. DataName: v.ClassifyName,
  133. //OriginalUserId: v.OriginalUserId,
  134. //OriginalUserName: v.OriginalUserName,
  135. //NewUserId: v.NewUserId,
  136. //NewUserName: v.NewUserName,
  137. CreateTime: utils.TimeTransferString(utils.FormatDateTime, v.CreateTime),
  138. })
  139. }
  140. return
  141. }