123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177 |
- 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"
- )
- // DeleteEdbPublicCheck
- // @Description: 移除指标公共检测
- // @author: Roc
- // @datetime 2024-12-05 10:23:01
- // @param classifyId int
- // @param edbInfoId int
- // @param sysUser *system.Admin
- // @return deleteStatus int
- // @return tipsMsg string
- // @return tableList []*data_manage.ExcelBaseInfo
- // @return err error
- // @return errMsg string
- func DeleteEdbPublicCheck(edbInfoId int, sysUser *system.Admin) (deleteStatus int, tipsMsg string, tableList []*data_manage.ExcelBaseInfo, err error, errMsg string) {
- // TODO 操作权限校验
- {
- }
- // 移除指标
- if edbInfoId > 0 {
- // TODO 需要判断该指标是否被其他人给收藏了
- //if edbInfo == nil {
- // errMsg = "指标已删除,请刷新页面"
- // return
- //}
- //if chartCount > 0 {
- // deleteStatus = 3
- // tipsMsg = "当前指标已用作画图,不可删除"
- // return
- //}
- return
- }
- return
- }
- // GetSearchPar
- // @Description: 获取查询参数
- // @author: Roc
- // @datetime 2024-12-05 14:13:25
- // @param req request.SearchPublicEdbReq
- // @return keyword string
- // @return searchEdbPublicList []int
- // @return sourceList []int
- // @return classifyIdList []int
- // @return publicClassifyIdList []int
- // @return edbTypeList []int
- // @return edbInfoType int
- // @return edbAuth int
- // @return sortMap map[string]string
- func GetSearchPar(req request.SearchPublicEdbReq) (keyword string, searchEdbPublicList, sourceList, classifyIdList, publicClassifyIdList, edbTypeList []int, edbInfoType, edbAuth int, sortMap map[string]string) {
- keyword = req.Keyword
- keyword = strings.TrimSpace(keyword) //移除字符串首尾空格
- //指标来源
- sourceList = req.SourceList
- // 选择的分类
- classifyIdList = req.ClassifyIdList
- publicClassifyIdList = req.PublicClassifyIdList
- // 指标公开状态:1:未公开,2:已提交;3:已公开。可多选,默认是未公开
- edbPublicList := req.EdbPublicList
- if len(edbPublicList) <= 0 {
- edbPublicList = []int{1}
- }
- edbInfoType = 0 // 普通指标
- edbTypeList = []int{utils.EdbTypeCalculate} // 普通指标中的计算指标
- edbAuth = 1 // 选择范围是:只有我的指标
- searchEdbPublicList = make([]int, 0) // 0:全部,1:未公开,2:已提交;3:已公开
- if len(edbPublicList) > 0 && !utils.InArrayByInt(edbPublicList, 0) {
- // 不含全部
- for _, v := range edbPublicList {
- switch v {
- case 1: // 未公开
- searchEdbPublicList = append(searchEdbPublicList, utils.DataPublicDefault)
- case 2: // 已提交
- searchEdbPublicList = append(searchEdbPublicList, utils.DataPublicCommit, utils.DataPublicReject)
- case 3: // 已公开
- searchEdbPublicList = append(searchEdbPublicList, utils.DataPublicSuccess)
- }
- }
- } else {
- searchEdbPublicList = []int{0, 1, 2, 3}
- }
- sortMap = make(map[string]string)
- // 如果没有搜索关键词,则默认根据指标编码倒序排序
- if keyword == `` {
- sortMap["EdbInfoId"] = `desc`
- }
- return
- }
- // GetAllEdbInfoListBySearchPublicEdbReq
- // @Description: 获取所有的指标列表
- // @author: Roc
- // @datetime 2024-12-04 15:43:14
- // @param req request.SearchPublicEdbReq
- // @param userId int
- // @return edbInfoIdList []*data_manage.EdbInfoList
- // @return err error
- func GetAllEdbInfoListBySearchPublicEdbReq(req request.SearchPublicEdbReq, userId int) (edbInfoList []*data_manage.EdbInfoList, err error) {
- // 获取查询参数
- keyword, searchEdbPublicList, sourceList, edbClassifyIdList, publicClassifyIdList, edbTypeList, edbInfoType, edbAuth, sortMap := GetSearchPar(req)
- _, edbInfoList, err = getAllEdbInfoDataByPublic(keyword, 1, searchEdbPublicList, sourceList, edbClassifyIdList, publicClassifyIdList, edbTypeList, edbInfoType, edbAuth, userId, sortMap)
- if err != nil {
- return
- }
- return
- }
- // getAllEdbInfoDataByShared
- // @Description: 获取所有的指标列表(设置公开的时候)
- // @author: Roc
- // @datetime 2024-12-04 15:27:53
- // @param keyword string
- // @param currPage int
- // @param edbShare int
- // @param sourceList []int
- // @param classifyIdList []int
- // @param edbTypeList []int
- // @param edbInfoType int
- // @param edbAuth int
- // @param sysUserId int
- // @param sortMap map[string]string
- // @return total int64
- // @return list []*data_manage.EdbInfoList
- // @return err error
- func getAllEdbInfoDataByPublic(keyword string, currPage int, searchEdbPublicList, sourceList, classifyIdList, publicClassifyIdList, edbTypeList []int, edbInfoType, edbAuth, sysUserId int, sortMap map[string]string) (total int64, list []*data_manage.EdbInfoList, err error) {
- // 每页获取数据的数量
- pageSize := 5000
- var startSize int
- if currPage <= 0 {
- currPage = 1
- }
- startSize = paging.StartIndex(currPage, pageSize)
- total, list, err = elastic.SearchEdbInfoDataByPublic(keyword, startSize, pageSize, searchEdbPublicList, sourceList, classifyIdList, publicClassifyIdList, edbTypeList, edbInfoType, edbAuth, sysUserId, sortMap)
- if err != nil {
- return
- }
- page := paging.GetPaging(currPage, pageSize, int(total))
- if !page.IsEnd {
- _, nextList, tmpErr := getAllEdbInfoDataByPublic(keyword, page.NextIndex, searchEdbPublicList, sourceList, classifyIdList, publicClassifyIdList, edbTypeList, edbInfoType, edbAuth, sysUserId, sortMap)
- if tmpErr != nil {
- err = tmpErr
- return
- }
- list = append(list, nextList...)
- }
- return
- }
|