123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111 |
- package data_manage_permission
- import (
- "eta_gn/eta_api/models/data_manage/data_manage_permission"
- "eta_gn/eta_api/utils"
- )
- type MessageDetailItem struct {
- DataPermissionMoveRecordId int64 ` orm:"column(data_permission_move_record_id);pk" gorm:"primaryKey" ` // 数据操作记录id
- Source int32 // 数据来源,1:手工数据指标 2:钢联化工数据库 3:ETA指标库 4:ETA预测指标 5:图库 6:ETA表格
- SubSource int32 // 子来源 :ETA表格中的各种表格类型,以及图表的来源(这个是后续的扩展方向)
- OpUniqueCode string // 操作的唯一编码,主要是记录统一操作的日志
- DataId string // 资产id(指标、图表、表格)
- DataCode string // 资产code(指标、图表、表格)
- DataName string // 资产名称(指标、图表、表格)
- OriginalUserId int32 // 原创建人id
- OriginalUserName string // 原创建人名称
- NewUserId int32 // 新创建人id
- NewUserName string // 新创建人名称
- CreateTime string
- }
- func GetMessageDetail(messageInfo *data_manage_permission.DataPermissionMessage, source, subSource, startSize, pageSize int) (total int, resp interface{}, err error) {
- switch messageInfo.OpType {
- case 1, 2:
- tmpTotal, list, tmpErr := data_manage_permission.GetDataPermissionMoveRecordListByOpUniqueCode(messageInfo.OpUniqueCode, source, subSource, startSize, pageSize)
- if tmpErr != nil {
- err = tmpErr
- return
- }
- total = tmpTotal
- resp, err = formatMessageDetailItemByDataPermissionMoveRecord(list)
- case 3:
- tmpTotal, list, tmpErr := data_manage_permission.GetDataPermissionNoAuthRecordListByUserId(messageInfo.ReceiveUserId, messageInfo.Source, messageInfo.SubSource, startSize, pageSize)
- if tmpErr != nil {
- err = tmpErr
- return
- }
- total = tmpTotal
- resp, err = formatMessageDetailItemByDataPermissionNoAuthRecord(list)
- case 4:
- tmpTotal, list, tmpErr := data_manage_permission.GetDataPermissionClassifyNoAuthRecordListByUserId(messageInfo.ReceiveUserId, messageInfo.Source, messageInfo.SubSource, startSize, pageSize)
- if tmpErr != nil {
- err = tmpErr
- return
- }
- total = tmpTotal
- resp, err = formatMessageDetailItemByDataPermissionClassifyNoAuthRecord(list)
- }
- return
- }
- func formatMessageDetailItemByDataPermissionMoveRecord(items []*data_manage_permission.DataPermissionMoveRecord) (resp []*MessageDetailItem, err error) {
- resp = make([]*MessageDetailItem, 0)
- for _, v := range items {
- resp = append(resp, &MessageDetailItem{
- DataPermissionMoveRecordId: v.DataPermissionMoveRecordId,
- Source: v.Source,
- SubSource: v.SubSource,
- OpUniqueCode: v.OpUniqueCode,
- DataId: v.DataId,
- DataCode: v.DataCode,
- DataName: v.DataName,
- OriginalUserId: v.OriginalUserId,
- OriginalUserName: v.OriginalUserName,
- NewUserId: v.NewUserId,
- NewUserName: v.NewUserName,
- CreateTime: utils.TimeTransferString(utils.FormatDateTime, v.CreateTime),
- })
- }
- return
- }
- func formatMessageDetailItemByDataPermissionNoAuthRecord(items []*data_manage_permission.DataPermissionNoAuthRecord) (resp []*MessageDetailItem, err error) {
- resp = make([]*MessageDetailItem, 0)
- for _, v := range items {
- resp = append(resp, &MessageDetailItem{
- DataPermissionMoveRecordId: v.DataPermissionNoAuthRecordId,
- Source: v.Source,
- SubSource: v.SubSource,
- OpUniqueCode: v.OpUniqueCode,
- DataId: v.DataId,
- DataCode: v.DataCode,
- DataName: v.DataName,
- CreateTime: utils.TimeTransferString(utils.FormatDateTime, v.CreateTime),
- })
- }
- return
- }
- func formatMessageDetailItemByDataPermissionClassifyNoAuthRecord(items []*data_manage_permission.DataPermissionClassifyNoAuthRecord) (resp []*MessageDetailItem, err error) {
- resp = make([]*MessageDetailItem, 0)
- for _, v := range items {
- resp = append(resp, &MessageDetailItem{
- DataPermissionMoveRecordId: v.DataPermissionClassifyNoAuthRecordId,
- Source: v.Source,
- SubSource: v.SubSource,
- OpUniqueCode: v.OpUniqueCode,
- DataId: v.ClassifyId,
- DataCode: v.ClassifyId,
- DataName: v.ClassifyName,
- CreateTime: utils.TimeTransferString(utils.FormatDateTime, v.CreateTime),
- })
- }
- return
- }
|