package data import ( "eta_gn/eta_api/models/data_manage" "strconv" "strings" ) // GetAllShareChartListByFromUserId // @Description: 根据共享人id获取所有的图表列表 // @author: Roc // @datetime 2024-12-03 10:01:49 // @param sysUserId int // @return item []*data_manage.ShareChartInfoQuery // @return err error func GetAllShareChartListByFromUserId(sysUserId int) (item []*data_manage.ShareChartInfoQuery, err error) { obj := data_manage.ChartInfoShare{} item, err = obj.GetAllSharedChartInfoListByFromUserId(sysUserId) if err != nil { return } return } // GetAllShareChartListByReceivedUserId // @Description: 根据接收人id获取所有的图表列表 // @author: Roc // @datetime 2024-12-03 10:01:49 // @param sysUserId int // @return item []*data_manage.ShareChartInfoQuery // @return err error func GetAllShareChartListByReceivedUserId(sysUserId int) (item []*data_manage.ShareChartInfoQuery, err error) { obj := data_manage.ChartInfoShare{} item, err = obj.GetAllSharedChartInfoListByReceivedUserId(sysUserId) if err != nil { return } return } // GetChartClassifyItemListByShareChartInfoQueryList // @Description: 根据共享的图表来获取分类和图表的树形结构 // @author: Roc // @datetime 2024-12-03 11:12:26 // @param items []*data_manage.ShareChartInfoQuery // @return item data_manage.ChartClassifyItemList // @return err error func GetChartClassifyItemListByShareChartInfoQueryList(items []*data_manage.ShareChartInfoQuery) (item []*data_manage.UserShareChartClassifyItem, err error) { // 所有分类 chartClassifyItemListMap := make(map[int][]*data_manage.ChartClassifyItems) classifyIdList := make([]int, 0) for _, v := range items { chartClassifyItem := &data_manage.ChartClassifyItems{ ChartClassifyId: v.ChartClassifyId, ChartInfoId: v.ChartInfoId, ChartClassifyName: v.ChartName, ChartClassifyNameEn: v.ChartNameEn, //ParentId: 0, //Level: 0, Sort: v.Sort, UniqueCode: v.UniqueCode, Source: v.Source, //SourceName: "", SysUserId: v.SysUserId, SysUserRealName: v.SysUserRealName, DateType: v.DateType, StartDate: v.StartDate, EndDate: v.EndDate, ChartType: v.ChartType, Calendar: v.Calendar, SeasonStartDate: v.SeasonStartDate, SeasonEndDate: v.SeasonEndDate, //Children: nil, Button: data_manage.ChartClassifyItemsButton{}, IsJoinPermission: v.IsJoinPermission, HaveOperaAuth: true, //ChartClassifyIdPath: "", } chartClassifyItemList, ok := chartClassifyItemListMap[v.ChartClassifyId] if !ok { chartClassifyItemList = make([]*data_manage.ChartClassifyItems, 0) } chartClassifyItemListMap[v.ChartClassifyId] = append(chartClassifyItemList, chartClassifyItem) classifyIdList = append(classifyIdList, v.ChartClassifyId) } // 组成一个分类树形结构 { // 根据分类id获取分类 classifyItemsList, tmpErr := data_manage.GetChartClassifyItemsByIdList(classifyIdList) if tmpErr != nil { err = tmpErr return } allClassifyIdList := make([]int, 0) // 获取分类的完整路径id集合(子级、父级、顶级) allClassifyIdStrList := make([]string, 0) for _, v := range classifyItemsList { allClassifyIdStrList = append(allClassifyIdStrList, v.ChartClassifyIdPath) } if len(allClassifyIdStrList) > 0 { allClassifyIdStrList = strings.Split(strings.Join(allClassifyIdStrList, ","), ",") } for _, v := range allClassifyIdStrList { classifyId, tmpErr := strconv.Atoi(v) if tmpErr != nil { err = tmpErr return } allClassifyIdList = append(allClassifyIdList, classifyId) } classifyItemsList, err = data_manage.GetChartClassifyItemsByIdList(allClassifyIdList) if err != nil { return } tmpList := GetChartClassifyTreeRecursiveAndInsert(classifyItemsList, 0, chartClassifyItemListMap) // 再转一下就好了 obj := data_manage.ChartClassifyItems{} item = obj.ToUserShareChartClassifyItemByList(tmpList) //根据sort值排序 //sort.Sort(item) } return } // GetAllEditSharedChartInfoIdListByReceivedUserId // @Description: 获取所有我收到的共享的、可以编辑的图表id列表 // @author: Roc // @datetime 2024-12-25 14:17:10 // @param userId int // @return editShareChartInfoIdList []int // @return err error func GetAllEditSharedChartInfoIdListByReceivedUserId(userId int, chartInfoIdList []int) (editShareChartInfoIdList []int, err error) { shareObj := data_manage.ChartInfoShare{} editShareChartInfoIdList, err = shareObj.GetAllEditSharedChartInfoIdListByReceivedUserId(userId, chartInfoIdList) return } // GetAllEditSharedChartInfoIdMapByReceivedUserId // @Description: 获取所有我收到的共享的、可以编辑的图表id map // @author: Roc // @datetime 2024-12-25 14:19:22 // @param userId int // @return editShareChartInfoIdMap map[int]bool // @return err error func GetAllEditSharedChartInfoIdMapByReceivedUserId(userId int) (editShareChartInfoIdMap map[int]bool, err error) { editShareChartInfoIdMap = make(map[int]bool) idList, err := GetAllEditSharedChartInfoIdListByReceivedUserId(userId, []int{}) if err != nil { return } for _, v := range idList { editShareChartInfoIdMap[v] = true } return } // GetAllEditSharedChartInfoIdMapByReceivedUserIdAndChartInfoIdList // @Description: 获取所有我收到的共享的、可以编辑的图表id map // @author: Roc // @datetime 2024-12-25 14:19:22 // @param userId int // @return editShareChartInfoIdMap map[int]bool // @return err error func GetAllEditSharedChartInfoIdMapByReceivedUserIdAndChartInfoIdList(userId int, chartInfoIdList []int) (editShareChartInfoIdMap map[int]bool, err error) { editShareChartInfoIdMap = make(map[int]bool) idList, err := GetAllEditSharedChartInfoIdListByReceivedUserId(userId, chartInfoIdList) if err != nil { return } for _, v := range idList { editShareChartInfoIdMap[v] = true } return }