edb_info_share.go 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655
  1. package data_manage
  2. import (
  3. "encoding/json"
  4. "eta_gn/eta_api/controllers"
  5. "eta_gn/eta_api/models"
  6. "eta_gn/eta_api/models/data_manage"
  7. "eta_gn/eta_api/models/data_manage/request"
  8. "eta_gn/eta_api/models/data_manage/response"
  9. "eta_gn/eta_api/services/data"
  10. "eta_gn/eta_api/services/elastic"
  11. "eta_gn/eta_api/utils"
  12. "fmt"
  13. "github.com/rdlucklib/rdluck_tools/paging"
  14. "strings"
  15. )
  16. // EdbInfoShareController 数据管理
  17. type EdbInfoShareController struct {
  18. controllers.BaseAuthController
  19. }
  20. // UserList
  21. // @Title 获取指标设置共享的详情
  22. // @Description 获取指标详情接口
  23. // @Param EdbInfoId query int true "指标id"
  24. // @Success 200 {object} response.EdbInfoShareUserResp
  25. // @router /edb_info/share/user_list [get]
  26. func (c *EdbInfoShareController) UserList() {
  27. br := new(models.BaseResponse).Init()
  28. defer func() {
  29. c.Data["json"] = br
  30. c.ServeJSON()
  31. }()
  32. sysUser := c.SysUser
  33. if sysUser == nil {
  34. br.Msg = "请登录"
  35. br.ErrMsg = "请登录,SysUser Is Empty"
  36. br.Ret = 408
  37. return
  38. }
  39. edbInfoId, _ := c.GetInt("EdbInfoId")
  40. if edbInfoId <= 0 {
  41. br.Msg = "参数错误"
  42. br.ErrMsg = "参数错误"
  43. return
  44. }
  45. _, err := data_manage.GetEdbInfoById(edbInfoId)
  46. if err != nil {
  47. br.Msg = "获取失败"
  48. br.ErrMsg = "获取指标信息失败,Err:" + err.Error()
  49. return
  50. }
  51. //// TODO 权限校验
  52. //{
  53. // classifyMap := make(map[int]*data_manage.EdbClassifyIdItems)
  54. // for _, v := range classifyList {
  55. // classifyMap[v.ClassifyId] = v
  56. // }
  57. // if currClassify, ok := classifyMap[edbInfo.ClassifyId]; ok {
  58. // haveOperaAuth, err := data_manage_permission.CheckEdbPermission(edbInfo.IsJoinPermission, currClassify.IsJoinPermission, c.SysUser.AdminId, edbInfo.EdbInfoId, edbInfo.ClassifyId)
  59. // if err != nil {
  60. // br.Msg = err.Error()
  61. // br.ErrMsg = "校验指标权限失败,err:" + err.Error()
  62. // return
  63. // }
  64. // resp.HaveOperaAuth = haveOperaAuth
  65. // }
  66. //}
  67. resp := response.EdbInfoShareUserResp{}
  68. obj := data_manage.EdbInfoShare{}
  69. list, err := obj.GetListByEdbInfoId(edbInfoId)
  70. if err != nil {
  71. br.Msg = `获取失败`
  72. br.ErrMsg = `获取失败:` + err.Error()
  73. return
  74. }
  75. resp.List = list
  76. if len(list) > 0 {
  77. resp.ShareType = list[0].ShareType
  78. }
  79. br.Ret = 200
  80. br.Success = true
  81. br.Msg = "获取成功"
  82. br.Data = resp
  83. }
  84. // Save
  85. // @Title 单个指标设置共享
  86. // @Description 单个指标设置共享
  87. // @Param request body request.SetEdbInfoShareReq true "type json string"
  88. // @Success 200 {object} data_manage.EdbInfo
  89. // @router /edb_info/share/save [post]
  90. func (c *EdbInfoShareController) Save() {
  91. br := new(models.BaseResponse).Init()
  92. defer func() {
  93. c.Data["json"] = br
  94. c.ServeJSON()
  95. }()
  96. sysUser := c.SysUser
  97. if sysUser == nil {
  98. br.Msg = "请登录"
  99. br.ErrMsg = "请登录,SysUser Is Empty"
  100. br.Ret = 408
  101. return
  102. }
  103. var req request.SetEdbInfoShareReq
  104. err := json.Unmarshal(c.Ctx.Input.RequestBody, &req)
  105. if err != nil {
  106. br.Msg = "参数解析异常!"
  107. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  108. return
  109. }
  110. obj := data_manage.EdbInfoShare{}
  111. err = obj.SaveEdbInfoShare([]int{req.EdbInfoId}, req.UserIdList, req.ShareType)
  112. if err != nil {
  113. br.Msg = `保存失败`
  114. br.ErrMsg = `保存失败:` + err.Error()
  115. return
  116. }
  117. // 更新es
  118. go data.AddOrEditEdbInfoToEs(req.EdbInfoId)
  119. br.Ret = 200
  120. br.Success = true
  121. br.Msg = "保存成功"
  122. }
  123. // Tree
  124. // @Title 获取共享指标的分类/指标树
  125. // @Description 获取共享指标的分类/指标树
  126. // @Success 200 {object} response.EdbShareListResp
  127. // @router /edb_info/share/tree [get]
  128. func (c *EdbInfoShareController) Tree() {
  129. br := new(models.BaseResponse).Init()
  130. defer func() {
  131. c.Data["json"] = br
  132. c.ServeJSON()
  133. }()
  134. sysUser := c.SysUser
  135. if sysUser == nil {
  136. br.Msg = "请登录"
  137. br.ErrMsg = "请登录,SysUser Is Empty"
  138. br.Ret = 408
  139. return
  140. }
  141. resp := response.EdbShareListResp{}
  142. // 我共享的
  143. {
  144. sendList, err := data.GetAllShareEdbListByFromUserId(sysUser.AdminId)
  145. if err != nil {
  146. br.Msg = "获取失败"
  147. br.ErrMsg = "获取我共享的指标列表信息失败,Err:" + err.Error()
  148. return
  149. }
  150. nodeList, err := data.GetEdbClassifyItemListByShareEdbInfoQueryList(sendList)
  151. if err != nil {
  152. br.Msg = "获取失败"
  153. br.ErrMsg = "获取我共享的指标列表分类结构信息失败,Err:" + err.Error()
  154. return
  155. }
  156. resp.Send = nodeList
  157. }
  158. // TODO 不确定加了用户这个顶级,会不会对前端造成一定影响
  159. // 我收到的
  160. {
  161. sendList, err := data.GetAllShareEdbListByReceivedUserId(sysUser.AdminId)
  162. if err != nil {
  163. br.Msg = "获取失败"
  164. br.ErrMsg = "获取我共享的指标列表信息失败,Err:" + err.Error()
  165. return
  166. }
  167. nodeList, err := data.GetEdbClassifyItemListByShareEdbInfoQueryList(sendList)
  168. if err != nil {
  169. br.Msg = "获取失败"
  170. br.ErrMsg = "获取我共享的指标列表分类结构信息失败,Err:" + err.Error()
  171. return
  172. }
  173. receivedMap := make(map[int]int)
  174. var receivedList data_manage.EdbClassifyItemList
  175. for _, v := range nodeList {
  176. index, ok := receivedMap[v.SysUserId]
  177. if !ok {
  178. index = len(receivedMap)
  179. item := &data_manage.EdbClassifyItems{
  180. ClassifyId: v.SysUserId,
  181. EdbInfoId: 0,
  182. ClassifyType: 0,
  183. ClassifyName: v.SysUserRealName,
  184. ClassifyNameEn: "",
  185. ParentId: 0,
  186. RootId: 0,
  187. Level: 0,
  188. Sort: 0,
  189. UniqueCode: "",
  190. Source: 0,
  191. SourceName: "",
  192. SysUserId: v.SysUserId,
  193. SysUserRealName: v.SysUserRealName,
  194. StartDate: "",
  195. EdbCode: "",
  196. EdbType: 0,
  197. Children: []*data_manage.EdbClassifyItems{},
  198. Button: data_manage.EdbClassifyItemsButton{},
  199. IsJoinPermission: 0,
  200. HaveOperaAuth: false,
  201. ClassifyIdPath: "",
  202. }
  203. receivedList = append(receivedList, item)
  204. }
  205. receivedList[index].Children = append(receivedList[index].Children, v)
  206. }
  207. resp.Received = receivedList
  208. }
  209. br.Ret = 200
  210. br.Success = true
  211. br.Msg = "获取成功"
  212. br.Data = resp
  213. }
  214. // List
  215. // @Title 指标列表接口
  216. // @Description 指标列表接口
  217. // @Param PageSize query int true "每页数据条数"
  218. // @Param CurrentIndex query int true "当前页页码,从1开始"
  219. // @Param ClassifyId query int true "分类id"
  220. // @Param FilterSource query int false "共享指标的列表数据来源,0:我共享的;1:别人共享给我的"
  221. // @Success 200 {object} response.EdbInfoChartListResp
  222. // @router /edb_info/share/list [get]
  223. func (c *EdbInfoShareController) List() {
  224. br := new(models.BaseResponse).Init()
  225. defer func() {
  226. if br.ErrMsg == "" {
  227. br.IsSendEmail = false
  228. }
  229. c.Data["json"] = br
  230. c.ServeJSON()
  231. }()
  232. sysUser := c.SysUser
  233. if sysUser == nil {
  234. br.Msg = "请登录"
  235. br.ErrMsg = "请登录,SysUser Is Empty"
  236. br.Ret = 408
  237. return
  238. }
  239. // 分页
  240. pageSize, _ := c.GetInt("PageSize")
  241. currentIndex, _ := c.GetInt("CurrentIndex")
  242. filterSource, _ := c.GetInt("FilterSource")
  243. var total int
  244. page := paging.GetPaging(currentIndex, pageSize, total)
  245. var startSize int
  246. if pageSize <= 0 {
  247. pageSize = utils.PageSize20
  248. }
  249. if currentIndex <= 0 {
  250. currentIndex = 1
  251. }
  252. startSize = paging.StartIndex(currentIndex, pageSize)
  253. // 基础指标
  254. var condition string
  255. var pars []interface{}
  256. condition += ` AND edb_info_type = ? `
  257. pars = append(pars, 0)
  258. // 指标类型
  259. edbType, _ := c.GetInt("EdbType", 0)
  260. if edbType > 0 {
  261. condition += ` AND edb_type = ? `
  262. pars = append(pars, edbType)
  263. }
  264. // 分类筛选
  265. classifyId, _ := c.GetInt("ClassifyId")
  266. if classifyId > 0 {
  267. childClassify, e, _ := data.GetChildClassifyByClassifyId(classifyId)
  268. if e != nil && !utils.IsErrNoRow(e) {
  269. br.Msg = "获取失败"
  270. br.ErrMsg = "获取分类信息失败, GetEdbClassify,Err:" + e.Error()
  271. return
  272. }
  273. var classifyIds []int
  274. for _, v := range childClassify {
  275. classifyIds = append(classifyIds, v.ClassifyId)
  276. }
  277. condition += fmt.Sprintf(` AND b.classify_id IN (%s) `, utils.GetOrmInReplace(len(classifyIds)))
  278. pars = append(pars, classifyIds)
  279. }
  280. switch filterSource {
  281. case 1: // 别人共享给我的
  282. condition += ` AND a.sys_user_id = ? AND b.sys_user_id != ? `
  283. pars = append(pars, sysUser.AdminId, sysUser.AdminId)
  284. default: // 我共享的
  285. condition += ` AND b.sys_user_id = ? `
  286. pars = append(pars, sysUser.AdminId)
  287. }
  288. obj := data_manage.EdbInfoShare{}
  289. dataCount, respList, err := obj.GetShareEdbInfoListPageList(condition, pars, startSize, pageSize)
  290. if err != nil {
  291. br.Msg = "获取失败"
  292. br.ErrMsg = fmt.Sprintf("获取分享指标列表失败, %v", err)
  293. return
  294. }
  295. page = paging.GetPaging(currentIndex, pageSize, int(dataCount))
  296. resp := response.EdbInfoChartListResp{
  297. Paging: page,
  298. List: respList,
  299. }
  300. br.Ret = 200
  301. br.Success = true
  302. br.Msg = "获取成功"
  303. br.Data = resp
  304. }
  305. // ListByEs
  306. // @Title 指标筛选接口
  307. // @Description 指标筛选接口
  308. // @Success 200 {object} data_manage.EdbInfoList
  309. // @Param request body request.SearchEdbInfoShareReq true "type json string"
  310. // @Success 200 {object} data_manage.EdbInfoFilterDataResp
  311. // @router /edb_info/share/list/es [post]
  312. func (c *EdbInfoShareController) ListByEs() {
  313. br := new(models.BaseResponse).Init()
  314. defer func() {
  315. c.Data["json"] = br
  316. c.ServeJSON()
  317. }()
  318. var req request.SearchEdbInfoShareReq
  319. err := json.Unmarshal(c.Ctx.Input.RequestBody, &req)
  320. if err != nil {
  321. br.Msg = "参数解析异常!"
  322. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  323. return
  324. }
  325. pageSize := req.PageSize
  326. currentIndex := req.CurrentIndex
  327. var total int64
  328. var startSize int
  329. if pageSize <= 0 {
  330. pageSize = utils.PageSize20
  331. }
  332. if currentIndex <= 0 {
  333. currentIndex = 1
  334. }
  335. startSize = paging.StartIndex(currentIndex, pageSize)
  336. keyword := req.Keyword
  337. keyword = strings.TrimSpace(keyword) //移除字符串首尾空格
  338. //指标来源
  339. sourceList := req.SourceList
  340. edbInfoType := 0 // 普通指标
  341. edbTypeList := []int{2} // 普通指标中的计算指标
  342. // 指标分享状态:1-未共享;2-已共享。可多选,多选用英文,隔开;默认是未共享
  343. edbShareList := req.EdbShareList
  344. if len(edbShareList) <= 0 {
  345. edbShareList = []int{1}
  346. }
  347. edbShare := 1 // 0:全部,1:未共享,2:已共享
  348. lenEdbShareList := len(edbShareList)
  349. if len(edbShareList) > 0 {
  350. if lenEdbShareList > 1 {
  351. edbShare = 0
  352. } else {
  353. edbShare = edbShareList[0]
  354. }
  355. }
  356. // 指标分享状态:1-未共享;2-已共享。可多选,多选用英文,隔开;默认是未共享
  357. edbClassifyIdList := req.ClassifyIdList
  358. edbAuth := 1 // 选择范围是:只有我的指标
  359. var edbInfoList []*data_manage.EdbInfoList
  360. sortMap := make(map[string]string)
  361. // 如果没有搜索关键词,则默认根据指标编码倒序排序
  362. if keyword == `` {
  363. sortMap["EdbInfoId"] = `desc`
  364. }
  365. total, edbInfoList, err = elastic.SearchEdbInfoDataByShared(keyword, startSize, pageSize, edbShare, sourceList, edbClassifyIdList, edbTypeList, edbInfoType, edbAuth, c.SysUser.AdminId, sortMap)
  366. if err != nil {
  367. edbInfoList = make([]*data_manage.EdbInfoList, 0)
  368. }
  369. page := paging.GetPaging(currentIndex, pageSize, int(total))
  370. edbInfoListLen := len(edbInfoList)
  371. // 因为是ES查找的,所以需要重新查一下指标的信息,主要是为了把是否授权字段找出来
  372. if len(edbInfoList) > 0 {
  373. edbInfoIdList := make([]int, 0)
  374. for _, v := range edbInfoList {
  375. v.ConvertToResp()
  376. v.EdbNameAlias = v.EdbName
  377. v.HaveOperaAuth = true
  378. edbInfoIdList = append(edbInfoIdList, v.EdbInfoId)
  379. }
  380. tmpEdbList, err := data_manage.GetEdbInfoByIdList(edbInfoIdList)
  381. if err != nil {
  382. br.Msg = "获取失败"
  383. br.ErrMsg = "获取所有有权限的指标失败,Err:" + err.Error()
  384. return
  385. }
  386. edbInfoMap := make(map[int]*data_manage.EdbInfo)
  387. for _, v := range tmpEdbList {
  388. edbInfoMap[v.EdbInfoId] = v
  389. }
  390. for _, v := range edbInfoList {
  391. tmpEdbInfo, ok := edbInfoMap[v.EdbInfoId]
  392. if !ok {
  393. continue
  394. }
  395. v.IsJoinPermission = tmpEdbInfo.IsJoinPermission
  396. }
  397. }
  398. for i := 0; i < edbInfoListLen; i++ {
  399. for j := 0; j < edbInfoListLen; j++ {
  400. if (edbInfoList[i].EdbNameAlias == edbInfoList[j].EdbNameAlias) &&
  401. (edbInfoList[i].EdbInfoId != edbInfoList[j].EdbInfoId) &&
  402. !(strings.Contains(edbInfoList[i].EdbName, edbInfoList[i].SourceName)) {
  403. edbInfoList[i].EdbName = edbInfoList[i].EdbName + "(" + edbInfoList[i].SourceName + ")"
  404. }
  405. }
  406. }
  407. resp := data_manage.EdbInfoFilterDataResp{
  408. Paging: page,
  409. List: edbInfoList,
  410. }
  411. br.Ret = 200
  412. br.Success = true
  413. br.Msg = "获取成功"
  414. br.Data = resp
  415. }
  416. // BatchSave
  417. // @Title 批量指标设置共享
  418. // @Description 批量指标设置共享
  419. // @Param request body request.SetEdbSharePermissionReq true "type json string"
  420. // @Success 200 {object} data_manage.EdbInfo
  421. // @router /edb_info/share/batch_save [post]
  422. func (c *EdbInfoShareController) BatchSave() {
  423. br := new(models.BaseResponse).Init()
  424. defer func() {
  425. c.Data["json"] = br
  426. c.ServeJSON()
  427. }()
  428. sysUser := c.SysUser
  429. if sysUser == nil {
  430. br.Msg = "请登录"
  431. br.ErrMsg = "请登录,SysUser Is Empty"
  432. br.Ret = 408
  433. return
  434. }
  435. var req request.SetEdbSharePermissionReq
  436. err := json.Unmarshal(c.Ctx.Input.RequestBody, &req)
  437. if err != nil {
  438. br.Msg = "参数解析异常!"
  439. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  440. return
  441. }
  442. // 选中的指标id列表
  443. selectEdbInfoIdList := make([]int, 0)
  444. // 选择所有指标,所以需要通过es获取数据
  445. if req.IsSelectAll {
  446. allEsEdbInfoIdList, err := getAllEdbInfoIdListByShared(req, c.SysUser.AdminId)
  447. if err != nil {
  448. br.Msg = "设置失败!"
  449. br.ErrMsg = "设置失败,Err:" + err.Error()
  450. return
  451. }
  452. if len(req.NoEdbIdList) <= 0 {
  453. selectEdbInfoIdList = allEsEdbInfoIdList
  454. } else {
  455. noEdbIdMap := make(map[int]bool)
  456. for _, v := range req.NoEdbIdList {
  457. noEdbIdMap[v] = true
  458. }
  459. for _, v := range allEsEdbInfoIdList {
  460. if _, ok := noEdbIdMap[v]; !ok {
  461. // 如果不在未选中的指标id列表中,那么就加入到选中的指标id列表
  462. selectEdbInfoIdList = append(selectEdbInfoIdList, v)
  463. }
  464. }
  465. }
  466. } else {
  467. selectEdbInfoIdList = req.EdbIdList
  468. }
  469. if len(selectEdbInfoIdList) > 30 {
  470. br.Msg = `指标数量不能超过30个`
  471. br.IsSendEmail = false
  472. return
  473. }
  474. // 设置
  475. {
  476. obj := data_manage.EdbInfoShare{}
  477. err = obj.SaveEdbInfoShare(selectEdbInfoIdList, req.UserIdList, req.ShareType)
  478. if err != nil {
  479. br.Msg = `保存失败`
  480. br.ErrMsg = `保存失败:` + err.Error()
  481. return
  482. }
  483. // 更新es
  484. for _, edbInfoId := range selectEdbInfoIdList {
  485. data.AddOrEditEdbInfoToEs(edbInfoId)
  486. }
  487. }
  488. br.Ret = 200
  489. br.Success = true
  490. br.Msg = "保存成功"
  491. }
  492. // getAllEdbInfoIdListByShared
  493. // @Description: 获取所有的指标id列表
  494. // @author: Roc
  495. // @datetime 2024-12-04 15:43:14
  496. // @param req request.SetEdbChartPermissionReq
  497. // @param userId int
  498. // @return edbInfoIdList []int
  499. // @return err error
  500. func getAllEdbInfoIdListByShared(req request.SetEdbSharePermissionReq, userId int) (edbInfoIdList []int, err error) {
  501. keyword := req.Keyword
  502. keyword = strings.TrimSpace(keyword) //移除字符串首尾空格
  503. //指标来源
  504. sourceList := req.SourceList
  505. edbInfoType := 0 // 普通指标
  506. edbTypeList := []int{2} // 普通指标中的计算指标
  507. // 指标分享状态:1-未共享;2-已共享。可多选,多选用英文,隔开;默认是未共享
  508. edbShareList := req.EdbShareList
  509. if len(edbShareList) <= 0 {
  510. edbShareList = []int{1}
  511. }
  512. edbShare := 1 // 0:全部,1:未共享,2:已共享
  513. lenEdbShareList := len(edbShareList)
  514. if len(edbShareList) > 0 {
  515. if lenEdbShareList > 1 {
  516. edbShare = 0
  517. } else {
  518. edbShare = edbShareList[0]
  519. }
  520. }
  521. // 指标分享状态:1-未共享;2-已共享。可多选,多选用英文,隔开;默认是未共享
  522. edbClassifyIdList := req.ClassifyIdList
  523. edbAuth := 1 // 选择范围是:只有我的指标
  524. sortMap := make(map[string]string)
  525. // 如果没有搜索关键词,则默认根据指标编码倒序排序
  526. if keyword == `` {
  527. sortMap["EdbInfoId"] = `desc`
  528. }
  529. _, edbInfoList, err := getAllEdbInfoDataByShared(keyword, 1, edbShare, sourceList, edbClassifyIdList, edbTypeList, edbInfoType, edbAuth, userId, sortMap)
  530. if err != nil {
  531. return
  532. }
  533. // 返回指标id列表
  534. for _, v := range edbInfoList {
  535. edbInfoIdList = append(edbInfoIdList, v.EdbInfoId)
  536. }
  537. return
  538. }
  539. // getAllEdbInfoDataByShared
  540. // @Description: 获取所有的指标列表(设置共享的时候)
  541. // @author: Roc
  542. // @datetime 2024-12-04 15:27:53
  543. // @param keyword string
  544. // @param currPage int
  545. // @param edbShare int
  546. // @param sourceList []int
  547. // @param classifyIdList []int
  548. // @param edbTypeList []int
  549. // @param edbInfoType int
  550. // @param edbAuth int
  551. // @param sysUserId int
  552. // @param sortMap map[string]string
  553. // @return total int64
  554. // @return list []*data_manage.EdbInfoList
  555. // @return err error
  556. func getAllEdbInfoDataByShared(keyword string, currPage, edbShare int, sourceList, classifyIdList, edbTypeList []int, edbInfoType, edbAuth, sysUserId int, sortMap map[string]string) (total int64, list []*data_manage.EdbInfoList, err error) {
  557. // 每页获取数据的数量
  558. pageSize := 5000
  559. var startSize int
  560. if currPage <= 0 {
  561. currPage = 1
  562. }
  563. startSize = paging.StartIndex(currPage, pageSize)
  564. total, list, err = elastic.SearchEdbInfoDataByShared(keyword, startSize, pageSize, edbShare, sourceList, classifyIdList, edbTypeList, edbInfoType, edbAuth, sysUserId, sortMap)
  565. if err != nil {
  566. return
  567. }
  568. page := paging.GetPaging(currPage, pageSize, int(total))
  569. if !page.IsEnd {
  570. _, nextList, tmpErr := getAllEdbInfoDataByShared(keyword, page.NextIndex, edbShare, sourceList, classifyIdList, edbTypeList, edbInfoType, edbAuth, sysUserId, sortMap)
  571. if tmpErr != nil {
  572. err = tmpErr
  573. return
  574. }
  575. list = append(list, nextList...)
  576. }
  577. return
  578. }