package data import ( "eta_gn/eta_api/models/data_manage" "eta_gn/eta_api/models/data_manage/request" "eta_gn/eta_api/models/system" "eta_gn/eta_api/services/elastic" "eta_gn/eta_api/utils" "github.com/rdlucklib/rdluck_tools/paging" "strings" ) // DeleteChartPublicCheck // @Description: 移除指标公共检测 // @author: Roc // @datetime 2024-12-05 10:23:01 // @param classifyId int // @param chartInfoId int // @param sysUser *system.Admin // @return deleteStatus int // @return tipsMsg string // @return tableList []*data_manage.ExcelBaseInfo // @return err error // @return errMsg string func DeleteChartPublicCheck(chartInfoId int, sysUser *system.Admin) (deleteStatus int, tipsMsg string, tableList []*data_manage.ExcelBaseInfo, err error, errMsg string) { // TODO 操作权限校验 { } // 移除指标 if chartInfoId > 0 { // TODO 需要判断该指标是否被其他人给收藏了 //if chartInfo == nil { // errMsg = "指标已删除,请刷新页面" // return //} //if chartCount > 0 { // deleteStatus = 3 // tipsMsg = "当前指标已用作画图,不可删除" // return //} return } return } // GetChartSearchPar // @Description: 获取查询参数 // @author: Roc // @datetime 2024-12-05 14:13:25 // @param req request.SearchPublicChartReq // @return keyword string // @return searchChartPublicList []int // @return sourceList []int // @return classifyIdList []int // @return publicClassifyIdList []int // @return chartTypeList []int // @return chartInfoType int // @return chartAuth int // @return sortMap map[string]string func GetChartSearchPar(req request.SearchPublicChartReq) (keyword string, searchChartPublicList, sourceList, chartTypeList, classifyIdList, publicClassifyIdList []int, chartAuth int, sortMap map[string]string) { keyword = req.Keyword keyword = strings.TrimSpace(keyword) //移除字符串首尾空格 //指标来源 sourceList = []int{utils.CHART_TYPE_CURVE} chartTypeList = req.ChartTypeList // 选择的分类 classifyIdList = req.ClassifyIdList // 公开分类 publicClassifyIdList = req.PublicClassifyIdList // 指标公开状态:1:未公开,2:已提交;3:已公开。可多选,默认是未公开 chartPublicList := req.ChartPublicList if len(chartPublicList) <= 0 { chartPublicList = []int{1} } chartAuth = 1 // 选择范围是:只有我的指标 searchChartPublicList = make([]int, 0) // 0:全部,1:未公开,2:已提交;3:已公开 if len(chartPublicList) > 0 && !utils.InArrayByInt(chartPublicList, 0) { // 不含全部 for _, v := range chartPublicList { switch v { case 1: // 未公开 searchChartPublicList = append(searchChartPublicList, utils.DataPublicDefault) case 2: // 已提交 searchChartPublicList = append(searchChartPublicList, utils.DataPublicCommit, utils.DataPublicReject) case 3: // 已公开 searchChartPublicList = append(searchChartPublicList, utils.DataPublicSuccess) } } } else { searchChartPublicList = []int{0, 1, 2, 3} } sortMap = make(map[string]string) // 如果没有搜索关键词,则默认根据指标编码倒序排序 if keyword == `` { sortMap["ChartInfoId"] = `desc` } return } // GetAllChartInfoListBySearchPublicChartReq // @Description: 获取所有的指标列表 // @author: Roc // @datetime 2024-12-04 15:43:14 // @param req request.SearchPublicChartReq // @param userId int // @return chartInfoIdList []*data_manage.ChartInfoList // @return err error func GetAllChartInfoListBySearchPublicChartReq(req request.SearchPublicChartReq, userId int) (chartInfoList []*data_manage.ChartInfoView, err error) { // 获取查询参数 keyword, searchChartPublicList, sourceList, chartTypeList, chartClassifyIdList, publicClassifyIdList, chartAuth, sortMap := GetChartSearchPar(req) _, chartInfoList, err = getAllChartInfoDataByPublic(keyword, 1, searchChartPublicList, sourceList, chartTypeList, chartClassifyIdList, publicClassifyIdList, chartAuth, userId, sortMap) if err != nil { return } return } // getAllChartInfoDataByShared // @Description: 获取所有的指标列表(设置公开的时候) // @author: Roc // @datetime 2024-12-04 15:27:53 // @param keyword string // @param currPage int // @param chartShare int // @param sourceList []int // @param classifyIdList []int // @param chartTypeList []int // @param chartInfoType int // @param chartAuth int // @param sysUserId int // @param sortMap map[string]string // @return total int64 // @return list []*data_manage.ChartInfoList // @return err error func getAllChartInfoDataByPublic(keyword string, currPage int, searchChartPublicList, sourceList, chartTypeList, classifyIdList, publicClassifyIdList []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.SearchChartInfoDataByPublic(keyword, startSize, pageSize, searchChartPublicList, sourceList, chartTypeList, classifyIdList, publicClassifyIdList, chartAuth, sysUserId, sortMap) if err != nil { return } page := paging.GetPaging(currPage, pageSize, int(total)) if !page.IsEnd { _, nextList, tmpErr := getAllChartInfoDataByPublic(keyword, page.NextIndex, searchChartPublicList, sourceList, chartTypeList, classifyIdList, publicClassifyIdList, chartAuth, sysUserId, sortMap) if tmpErr != nil { err = tmpErr return } list = append(list, nextList...) } return }