package data_manage import ( "encoding/json" "eta_gn/eta_api/cache" "eta_gn/eta_api/controllers" "eta_gn/eta_api/models" "eta_gn/eta_api/models/data_manage" "eta_gn/eta_api/models/data_manage/request" "eta_gn/eta_api/models/data_manage/response" "eta_gn/eta_api/models/system" "eta_gn/eta_api/services/data" "eta_gn/eta_api/services/elastic" "eta_gn/eta_api/utils" "fmt" "github.com/rdlucklib/rdluck_tools/paging" "sort" "strconv" "strings" ) // ChartInfoShareController 数据管理 type ChartInfoShareController struct { controllers.BaseAuthController } // UserList // @Title 获取图表设置共享的详情 // @Description 获取图表详情接口 // @Param ChartInfoId query int true "图表id" // @Success 200 {object} response.ChartInfoShareUserResp // @router /chart_info/share/user_list [get] func (c *ChartInfoShareController) UserList() { br := new(models.BaseResponse).Init() defer func() { c.Data["json"] = br c.ServeJSON() }() sysUser := c.SysUser if sysUser == nil { br.Msg = "请登录" br.ErrMsg = "请登录,SysUser Is Empty" br.Ret = 408 return } chartInfoId, _ := c.GetInt("ChartInfoId") if chartInfoId <= 0 { br.Msg = "参数错误" br.ErrMsg = "参数错误" return } chartInfo, err := data_manage.GetChartInfoById(chartInfoId) if err != nil { br.Msg = "获取失败" br.ErrMsg = "获取图表信息失败,Err:" + err.Error() return } if chartInfo.SysUserId != sysUser.AdminId { br.Msg = "您没有权限设置共享" br.ErrMsg = "您没有权限设置共享,ChartInfoId:" + strconv.Itoa(chartInfoId) br.IsSendEmail = false return } resp := response.ChartInfoShareUserResp{} obj := data_manage.ChartInfoShare{} list, err := obj.GetListByChartInfoId(chartInfoId) if err != nil { br.Msg = `获取失败` br.ErrMsg = `获取失败:` + err.Error() return } resp.List = list br.Ret = 200 br.Success = true br.Msg = "获取成功" br.Data = resp } // Save // @Title 单个图表设置共享 // @Description 单个图表设置共享 // @Param request body request.SetChartInfoShareReq true "type json string" // @Success 200 {object} data_manage.ChartInfo // @router /chart_info/share/save [post] func (c *ChartInfoShareController) Save() { br := new(models.BaseResponse).Init() defer func() { c.Data["json"] = br c.ServeJSON() }() sysUser := c.SysUser if sysUser == nil { br.Msg = "请登录" br.ErrMsg = "请登录,SysUser Is Empty" br.Ret = 408 return } var req request.SetChartInfoShareReq err := json.Unmarshal(c.Ctx.Input.RequestBody, &req) if err != nil { br.Msg = "参数解析异常!" br.ErrMsg = "参数解析失败,Err:" + err.Error() return } if req.ChartInfoId <= 0 { br.Msg = `请选择图表` br.IsSendEmail = false return } chartItem, err := data_manage.GetChartInfoById(req.ChartInfoId) if err != nil { br.Msg = "查找图表失败" br.ErrMsg = "查找图表失败,Err:" + err.Error() return } if chartItem.ChartInfoId <= 0 { br.Msg = "图表不存在" br.ErrMsg = "图表不存在,ChartInfoId:" + strconv.Itoa(req.ChartInfoId) br.IsSendEmail = false return } if chartItem.SysUserId != c.SysUser.AdminId { br.Msg = "您没有权限设置共享" br.ErrMsg = "您没有权限设置共享,ChartInfoId:" + strconv.Itoa(req.ChartInfoId) br.IsSendEmail = false return } obj := data_manage.ChartInfoShare{} // 如果图表未公开,则判断是否被其他用户使用 if chartItem.PublicStatus != utils.DataPublicSuccess { checkUserIdList := []int{sysUser.AdminId} if len(req.UserIdList) > 0 { checkUserIdList = append(checkUserIdList, req.UserIdList...) } { userIdList, err := obj.GetAllUserIdListByChartInfoIdAndNoShareType(chartItem.ChartInfoId, req.ShareType) if err != nil { br.Msg = "设置失败!" br.ErrMsg = "设置失败,Err:" + err.Error() return } if len(userIdList) > 0 { checkUserIdList = append(checkUserIdList, userIdList...) } } // 校验是否被其他用户关联 noReferenced, otherUserIdList, err, tips := data.CheckChartReferencedByOthers([]int{chartItem.ChartInfoId}, []string{chartItem.UniqueCode}, checkUserIdList) if err != nil { br.Msg = "保存失败" if tips != "" { br.Msg = tips } br.ErrMsg = "设置图表共享失败,查找图表的关联用户失败,Err:" + err.Error() return } if !noReferenced { userNameStr := `` if len(otherUserIdList) > 0 { userNameList := make([]string, 0) userList, err := system.GetAdminListByIdList(otherUserIdList) if err != nil { br.Msg = "保存失败" if tips != "" { br.Msg = tips } br.ErrMsg = "设置图表共享失败,查找用户信息失败,Err:" + err.Error() return } for _, userInfo := range userList { userNameList = append(userNameList, userInfo.RealName) } userNameStr = strings.Join(userNameList, "、") } msg := `图表被其他用户使用,无法设置共享` if userNameStr != "" { msg = fmt.Sprintf(`图表被用户%s使用,无法设置共享`, userNameStr) } if tips != "" { msg = fmt.Sprintf(`%s,用户为:%s,无法设置共享`, tips, userNameStr) } br.Msg = msg br.ErrMsg = "图表被其他用户共享,无法设置共享,ChartInfoId:" + strconv.Itoa(chartItem.ChartInfoId) br.IsSendEmail = false return } } // 修改 err = obj.SaveChartInfoShare([]int{req.ChartInfoId}, req.UserIdList, req.ShareType) if err != nil { br.Msg = `保存失败` br.ErrMsg = `保存失败:` + err.Error() return } // 更新es data.AddOrEditChartInfoToEs(req.ChartInfoId) // 图表收藏操作处理 go cache.AddDataCollectHandler(req.ChartInfoId, utils.DataCollectTypeChart) br.Ret = 200 br.Success = true br.Msg = "保存成功" } // Tree // @Title 获取共享图表的分类/图表树 // @Description 获取共享图表的分类/图表树 // @Success 200 {object} response.ChartShareListResp // @router /chart_info/share/tree [get] func (c *ChartInfoShareController) Tree() { br := new(models.BaseResponse).Init() defer func() { c.Data["json"] = br c.ServeJSON() }() sysUser := c.SysUser if sysUser == nil { br.Msg = "请登录" br.ErrMsg = "请登录,SysUser Is Empty" br.Ret = 408 return } resp := response.ChartShareListResp{} // 我共享的 { sendList, err := data.GetAllShareChartListByFromUserId(sysUser.AdminId) if err != nil { br.Msg = "获取失败" br.ErrMsg = "获取我共享的图表列表信息失败,Err:" + err.Error() return } nodeList, err := data.GetChartClassifyItemListByShareChartInfoQueryList(sendList) if err != nil { br.Msg = "获取失败" br.ErrMsg = "获取我共享出去的图表列表分类结构信息失败,Err:" + err.Error() return } var sortList data_manage.UserShareChartClassifyItemList sortList = nodeList sort.Sort(sortList) resp.Send = sortList } // 我收到的 { sendList, err := data.GetAllShareChartListByReceivedUserId(sysUser.AdminId) if err != nil { br.Msg = "获取失败" br.ErrMsg = "获取我共享的图表列表信息失败,Err:" + err.Error() return } nodeList, err := data.GetChartClassifyItemListByShareChartInfoQueryList(sendList) if err != nil { br.Msg = "获取失败" br.ErrMsg = "获取我收到共享的图表列表分类结构信息失败,Err:" + err.Error() return } receivedMap := make(map[int]int) var receivedList data_manage.UserShareChartClassifyItemList for _, v := range nodeList { index, ok := receivedMap[v.SysUserId] if !ok { index = len(receivedMap) item := &data_manage.UserShareChartClassifyItem{ UserId: v.SysUserId, UserName: v.SysUserRealName, ChartInfoId: 0, ChartClassifyId: v.SysUserId, ChartClassifyName: v.SysUserRealName, ChartClassifyNameEn: v.SysUserRealName, ParentId: 0, Level: 0, Sort: 0, UniqueCode: utils.MD5(fmt.Sprint(v.SysUserId, "_", v.SysUserRealName)), Source: 0, SourceName: "", SysUserId: v.SysUserId, SysUserRealName: v.SysUserRealName, DateType: 0, StartDate: "", EndDate: "", ChartType: 0, Calendar: "", SeasonStartDate: "", SeasonEndDate: "", Children: []*data_manage.UserShareChartClassifyItem{}, Button: data_manage.ChartClassifyItemsButton{}, IsJoinPermission: 0, HaveOperaAuth: true, ChartClassifyIdPath: "", } receivedList = append(receivedList, item) } receivedList[index].Children = append(receivedList[index].Children, v) receivedMap[v.SysUserId] = index } sort.Sort(receivedList) resp.Received = receivedList } br.Ret = 200 br.Success = true br.Msg = "获取成功" br.Data = resp } // List // @Title 图表列表接口 // @Description 图表列表接口 // @Param PageSize query int true "每页数据条数" // @Param CurrentIndex query int true "当前页页码,从1开始" // @Param ClassifyId query int true "分类id" // @Param FilterSource query int false "共享图表的列表数据来源,0:我共享的;1:别人共享给我的" // @Param ClassifyId query int false "分类id" // @Param UserId query int false "所属用户id" // @Success 200 {object} response.ChartInfoChartListResp // @router /chart_info/share/list [get] func (c *ChartInfoShareController) List() { br := new(models.BaseResponse).Init() defer func() { if br.ErrMsg == "" { br.IsSendEmail = false } c.Data["json"] = br c.ServeJSON() }() sysUser := c.SysUser if sysUser == nil { br.Msg = "请登录" br.ErrMsg = "请登录,SysUser Is Empty" br.Ret = 408 return } // 分页 pageSize, _ := c.GetInt("PageSize") currentIndex, _ := c.GetInt("CurrentIndex") filterSource, _ := c.GetInt("FilterSource") var total int page := paging.GetPaging(currentIndex, pageSize, total) var startSize int if pageSize <= 0 { pageSize = utils.PageSize20 } if currentIndex <= 0 { currentIndex = 1 } startSize = paging.StartIndex(currentIndex, pageSize) // 基础图表 var condition string var pars []interface{} condition += ` AND source = ? ` pars = append(pars, utils.CHART_TYPE_CURVE) // 用户筛选 userId, _ := c.GetInt("UserId") if userId > 0 { condition += ` AND b.sys_user_id = ? ` pars = append(pars, userId) } // 分类筛选 classifyId, _ := c.GetInt("ClassifyId") if classifyId > 0 { childClassify, e, _ := data.GetChildChartClassifyByClassifyId(classifyId) if e != nil && !utils.IsErrNoRow(e) { br.Msg = "获取失败" br.ErrMsg = "获取分类信息失败, GetChartClassify,Err:" + e.Error() return } var classifyIds []int for _, v := range childClassify { classifyIds = append(classifyIds, v.ChartClassifyId) } condition += fmt.Sprintf(` AND b.chart_classify_id IN (%s) `, utils.GetOrmInReplace(len(classifyIds))) pars = append(pars, classifyIds) } switch filterSource { case 1: // 别人共享给我的 condition += ` AND a.sys_user_id = ? AND b.sys_user_id != ? ` pars = append(pars, sysUser.AdminId, sysUser.AdminId) default: // 我共享的 condition += ` AND b.sys_user_id = ? ` pars = append(pars, sysUser.AdminId) } obj := data_manage.ChartInfoShare{} dataCount, respList, err := obj.GetShareChartInfoListPageList(condition, pars, startSize, pageSize) if err != nil { br.Msg = "获取失败" br.ErrMsg = fmt.Sprintf("获取分享图表列表失败, %v", err) return } editShareChartInfoIdMap, err := data.GetAllEditSharedChartInfoIdMapByReceivedUserId(c.SysUser.AdminId) if err != nil { br.Msg = "获取失败" br.ErrMsg = "获取所有有编辑权限的分享图表失败,Err:" + err.Error() return } for _, chartInfo := range respList { chartInfo.HaveOperaAuth = true button := data.GetChartOpButton(c.SysUser, chartInfo.SysUserId, chartInfo.ChartInfoId, chartInfo.HaveOperaAuth, editShareChartInfoIdMap) chartInfo.Button.IsEdit = button.OpButton chartInfo.Button.IsCopy = button.DeleteButton } page = paging.GetPaging(currentIndex, pageSize, int(dataCount)) resp := response.ChartInfoChartListResp{ Paging: page, List: respList, } br.Ret = 200 br.Success = true br.Msg = "获取成功" br.Data = resp } // ListByEs // @Title 图表筛选接口 // @Description 图表筛选接口 // @Success 200 {object} data_manage.ChartInfoList // @Param request body request.SearchChartInfoShareReq true "type json string" // @Success 200 {object} data_manage.ChartInfoFilterDataResp // @router /chart_info/share/list/es [post] func (c *ChartInfoShareController) ListByEs() { br := new(models.BaseResponse).Init() defer func() { c.Data["json"] = br c.ServeJSON() }() var req request.SearchChartInfoShareReq err := json.Unmarshal(c.Ctx.Input.RequestBody, &req) if err != nil { br.Msg = "参数解析异常!" br.ErrMsg = "参数解析失败,Err:" + err.Error() return } pageSize := req.PageSize currentIndex := req.CurrentIndex var total int64 var startSize int if pageSize <= 0 { pageSize = utils.PageSize20 } if currentIndex <= 0 { currentIndex = 1 } startSize = paging.StartIndex(currentIndex, pageSize) keyword := req.Keyword keyword = strings.TrimSpace(keyword) //移除字符串首尾空格 sourceList := []int{utils.CHART_TYPE_CURVE} // 图表分享状态:1-未共享;2-已共享。可多选,多选用英文,隔开;默认是未全部 chartShareList := req.ChartShareList if len(chartShareList) <= 0 { chartShareList = []int{} } chartShare := 0 // 0:全部,1:未共享,2:已共享 lenChartShareList := len(chartShareList) if len(chartShareList) > 0 { if lenChartShareList > 1 { chartShare = 0 } else { chartShare = chartShareList[0] } } // 图表类型 chartTypeList := req.ChartTypeList // 直图表所属分类id chartClassifyIdList := req.ClassifyIdList chartAuth := 1 // 选择范围是:只有我的图表 var chartInfoList []*data_manage.ChartInfoView sortMap := make(map[string]string) // 如果没有搜索关键词,则默认根据图表编码倒序排序 if keyword == `` { sortMap["ChartInfoId"] = `desc` } total, chartInfoList, err = elastic.SearchChartInfoDataByShared(keyword, startSize, pageSize, chartShare, sourceList, chartTypeList, chartClassifyIdList, chartAuth, c.SysUser.AdminId, sortMap) if err != nil { chartInfoList = make([]*data_manage.ChartInfoView, 0) } page := paging.GetPaging(currentIndex, pageSize, int(total)) // 因为是ES查找的,所以需要重新查一下图表的信息,主要是为了把是否授权字段找出来 if len(chartInfoList) > 0 { chartTypeMap := make(map[int]*data_manage.ChartType) sysUserIdList := make([]int, 0) chartInfoIdList := make([]int, 0) currChartTypeList := make([]int, 0) for _, v := range chartInfoList { v.ConvertToResp() v.HaveOperaAuth = true chartInfoIdList = append(chartInfoIdList, v.ChartInfoId) currChartTypeList = append(currChartTypeList, v.ChartType) if v.SharedUserIdList != nil && len(v.SharedUserIdList) > 0 { sysUserIdList = append(sysUserIdList, v.SharedUserIdList...) } } // 获取图表数据 tmpChartList, err := data_manage.GetChartInfoByIdList(chartInfoIdList) if err != nil { br.Msg = "获取失败" br.ErrMsg = "获取所有有权限的图表失败,Err:" + err.Error() return } chartInfoMap := make(map[int]*data_manage.ChartInfo) for _, v := range tmpChartList { chartInfoMap[v.ChartInfoId] = v } // 获取用户数据 sysUserMap := make(map[int]string) if len(sysUserIdList) > 0 { sysUserList, err := system.GetAdminListByIdList(sysUserIdList) if err != nil { br.Msg = "获取失败" br.ErrMsg = "获取分享用户列表失败,Err:" + err.Error() return } for _, v := range sysUserList { sysUserMap[v.AdminId] = v.RealName } } // 图表类型 { tmpChartTypeList, err := data_manage.GetChartTypeListByIdList(currChartTypeList) if err != nil { br.Msg = "获取图表类型失败" br.ErrMsg = "获取图表类型失败,Err:" + err.Error() return } for _, v := range tmpChartTypeList { chartTypeMap[v.ChartTypeId] = v } } for _, v := range chartInfoList { tmpChartInfo, ok := chartInfoMap[v.ChartInfoId] if !ok { continue } v.IsJoinPermission = tmpChartInfo.IsJoinPermission // 图表类型名称 if chartType, ok := chartTypeMap[v.ChartType]; ok { v.ChartTypeName = chartType.ChartTypeName } // 分享人 shareUserName := `` shareUserNameList := make([]string, 0) shareUserNameMap := make(map[int]bool) for _, userId := range v.SharedUserIdList { userName, ok := sysUserMap[userId] if !ok { continue } if _, ok = shareUserNameMap[userId]; ok { continue } shareUserNameMap[userId] = true shareUserNameList = append(shareUserNameList, userName) } if len(shareUserNameList) > 0 { shareUserName = strings.Join(shareUserNameList, `,`) } v.SharedUserName = shareUserName } } resp := data_manage.ChartInfoFilterDataResp{ Paging: page, List: chartInfoList, } br.Ret = 200 br.Success = true br.Msg = "获取成功" br.Data = resp } // BatchSave // @Title 批量图表设置共享 // @Description 批量图表设置共享 // @Param request body request.SetChartSharePermissionReq true "type json string" // @Success 200 {object} data_manage.ChartInfo // @router /chart_info/share/batch_save [post] func (c *ChartInfoShareController) BatchSave() { br := new(models.BaseResponse).Init() defer func() { c.Data["json"] = br c.ServeJSON() }() sysUser := c.SysUser if sysUser == nil { br.Msg = "请登录" br.ErrMsg = "请登录,SysUser Is Empty" br.Ret = 408 return } var req request.SetChartSharePermissionReq err := json.Unmarshal(c.Ctx.Input.RequestBody, &req) if err != nil { br.Msg = "参数解析异常!" br.ErrMsg = "参数解析失败,Err:" + err.Error() return } // 选中的图表id列表 selectChartInfoIdList := make([]int, 0) // 选择所有图表,所以需要通过es获取数据 if req.IsSelectAll { allEsChartInfoIdList, err := getAllChartInfoIdListByShared(req, c.SysUser.AdminId) if err != nil { br.Msg = "设置失败!" br.ErrMsg = "设置失败,Err:" + err.Error() return } if len(req.NoChartIdList) <= 0 { selectChartInfoIdList = allEsChartInfoIdList } else { noChartIdMap := make(map[int]bool) for _, v := range req.NoChartIdList { noChartIdMap[v] = true } for _, v := range allEsChartInfoIdList { if _, ok := noChartIdMap[v]; !ok { // 如果不在未选中的图表id列表中,那么就加入到选中的图表id列表 selectChartInfoIdList = append(selectChartInfoIdList, v) } } } } else { selectChartInfoIdList = req.ChartIdList } num := len(selectChartInfoIdList) if num <= 0 { br.Msg = `请选择图表` br.IsSendEmail = false return } if num > 30 { br.Msg = `图表数量不能超过30个` br.IsSendEmail = false return } chartInfoList, err := data_manage.GetChartInfoListByChartIdList(selectChartInfoIdList) if err != nil { br.Msg = "设置失败!" br.ErrMsg = "设置失败,Err:" + err.Error() return } obj := data_manage.ChartInfoShare{} { for _, chartItem := range chartInfoList { // 如果指标已公开,则不判断是否被其他用户使用 if chartItem.PublicStatus == utils.DataPublicSuccess { continue } if chartItem.PublicStatus != utils.DataPublicSuccess { checkUserIdList := []int{sysUser.AdminId} if len(req.UserIdList) > 0 { checkUserIdList = append(checkUserIdList, req.UserIdList...) } { userIdList, err := obj.GetAllUserIdListByChartInfoIdAndNoShareType(chartItem.ChartInfoId, req.ShareType) if err != nil { br.Msg = "设置失败!" br.ErrMsg = "设置失败,Err:" + err.Error() return } if len(userIdList) > 0 { checkUserIdList = append(checkUserIdList, userIdList...) } } // 校验是否被其他用户关联 noReferenced, otherUserIdList, err, tips := data.CheckChartReferencedByOthers([]int{chartItem.ChartInfoId}, []string{chartItem.UniqueCode}, checkUserIdList) if err != nil { br.Msg = "保存失败" if tips != "" { br.Msg = tips } br.ErrMsg = "设置指标共享失败,查找指标的关联用户失败,Err:" + err.Error() return } if !noReferenced { userNameStr := `` if len(otherUserIdList) > 0 { userNameList := make([]string, 0) userList, err := system.GetAdminListByIdList(otherUserIdList) if err != nil { br.Msg = "保存失败" if tips != "" { br.Msg = tips } br.ErrMsg = "设置指标共享失败,查找用户信息失败,Err:" + err.Error() return } for _, userInfo := range userList { userNameList = append(userNameList, userInfo.RealName) } userNameStr = strings.Join(userNameList, "、") } msg := fmt.Sprintf(`指标《%s》被其他用户使用,无法设置共享`, chartItem.ChartName) if userNameStr != "" { msg = fmt.Sprintf(`指标《%s》被用户%s使用,无法设置共享`, chartItem.ChartName, userNameStr) } if tips != "" { msg = fmt.Sprintf(`%s,用户为:%s,无法设置共享`, tips, userNameStr) } br.Msg = msg br.ErrMsg = "指标被其他用户共享,无法设置共享,ChartInfoId:" + strconv.Itoa(chartItem.ChartInfoId) br.IsSendEmail = false return } } } } // 设置 err = obj.SaveChartInfoShare(selectChartInfoIdList, req.UserIdList, req.ShareType) if err != nil { br.Msg = `保存失败` br.ErrMsg = `保存失败:` + err.Error() return } // 更新es for _, chartInfoId := range selectChartInfoIdList { data.AddOrEditChartInfoToEs(chartInfoId) // 图表收藏操作处理 go cache.AddDataCollectHandler(chartInfoId, utils.DataCollectTypeChart) } br.Ret = 200 br.Success = true br.Msg = "保存成功" } // getAllChartInfoIdListByShared // @Description: 获取所有的图表id列表 // @author: Roc // @datetime 2024-12-10 17:51:35 // @param req request.SetChartSharePermissionReq // @param userId int // @return chartInfoIdList []int // @return err error func getAllChartInfoIdListByShared(req request.SetChartSharePermissionReq, userId int) (chartInfoIdList []int, err error) { keyword := req.Keyword keyword = strings.TrimSpace(keyword) //移除字符串首尾空格 //图表来源 sourceList := []int{utils.CHART_TYPE_CURVE} // 图表分享状态:1-未共享;2-已共享。可多选,多选用英文,隔开;默认是未共享 chartShareList := req.ChartShareList if len(chartShareList) <= 0 { chartShareList = []int{1} } chartShare := 1 // 0:全部,1:未共享,2:已共享 lenChartShareList := len(chartShareList) if len(chartShareList) > 0 { if lenChartShareList > 1 { chartShare = 0 } else { chartShare = chartShareList[0] } } // 图表类型 chartTypeList := req.ChartTypeList // 图表分享状态:1-未共享;2-已共享。可多选,多选用英文,隔开;默认是未共享 chartClassifyIdList := req.ClassifyIdList chartAuth := 1 // 选择范围是:只有我的图表 sortMap := make(map[string]string) // 如果没有搜索关键词,则默认根据图表编码倒序排序 if keyword == `` { sortMap["ChartInfoId"] = `desc` } _, chartInfoList, err := getAllChartInfoDataByShared(keyword, 1, chartShare, sourceList, chartTypeList, chartClassifyIdList, chartAuth, userId, sortMap) if err != nil { return } // 返回图表id列表 for _, v := range chartInfoList { chartInfoIdList = append(chartInfoIdList, v.ChartInfoId) } return } // getAllChartInfoDataByShared // @Description: 获取所有的图表列表(设置共享的时候) // @author: Roc // @datetime 2024-12-10 17:51:18 // @param keyword string // @param currPage int // @param chartShare int // @param sourceList []int // @param classifyIdList []int // @param chartAuth int // @param sysUserId int // @param sortMap map[string]string // @return total int64 // @return list []*data_manage.ChartInfoView // @return err error func getAllChartInfoDataByShared(keyword string, currPage, chartShare int, sourceList, chartTypeList, classifyIdList []int, chartAuth, sysUserId int, sortMap map[string]string) (total int64, list []*data_manage.ChartInfoView, err error) { // 每页获取数据的数量 pageSize := 5000 var startSize int if currPage <= 0 { currPage = 1 } startSize = paging.StartIndex(currPage, pageSize) total, list, err = elastic.SearchChartInfoDataByShared(keyword, startSize, pageSize, chartShare, sourceList, chartTypeList, classifyIdList, chartAuth, sysUserId, sortMap) if err != nil { return } page := paging.GetPaging(currPage, pageSize, int(total)) if !page.IsEnd { _, nextList, tmpErr := getAllChartInfoDataByShared(keyword, page.NextIndex, chartShare, sourceList, chartTypeList, classifyIdList, chartAuth, sysUserId, sortMap) if tmpErr != nil { err = tmpErr return } list = append(list, nextList...) } return }