123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189 |
- 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
- }
|