123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128 |
- 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.ChartClassifyItems, 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: false,
- //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
- }
- item = GetChartClassifyTreeRecursiveAndInsert(classifyItemsList, 0, chartClassifyItemListMap)
- //根据sort值排序
- //sort.Sort(item)
- }
- return
- }
|