bi_dashboard.go 34 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315
  1. package controllers
  2. import (
  3. "encoding/json"
  4. "errors"
  5. "eta/eta_api/models"
  6. "eta/eta_api/models/bi_dashboard"
  7. "eta/eta_api/models/system"
  8. "eta/eta_api/services"
  9. "eta/eta_api/utils"
  10. "fmt"
  11. "strconv"
  12. "strings"
  13. "time"
  14. )
  15. type BIDaShboardController struct {
  16. BaseAuthController
  17. }
  18. // GroupList
  19. // @Title 获取我的列表
  20. // @Description 获取我的列表接口
  21. // @Success 200 {object} models.RespGroupList
  22. // @router /my_list [get]
  23. func (this *BIDaShboardController) MyList() {
  24. br := new(models.BaseResponse).Init()
  25. defer func() {
  26. this.Data["json"] = br
  27. this.ServeJSON()
  28. }()
  29. // 获取我的看板列表
  30. privateCond := ` AND sys_admin_id = ? `
  31. privatePars := []interface{}{this.SysUser.AdminId}
  32. privateList, err := bi_dashboard.GetBiDashboardList(privateCond, privatePars)
  33. if err != nil {
  34. err = errors.New("我的看板列表查询出错:" + err.Error())
  35. return
  36. }
  37. br.Ret = 200
  38. br.Success = true
  39. br.Msg = "查询成功"
  40. br.Data = privateList
  41. return
  42. }
  43. // AddDashboard
  44. // @Title 新增看板
  45. // @Description 新增看板接口
  46. // @Param request body models.AddDashboardReq true "type json string"
  47. // @Success 200 Ret=200 新增成功
  48. // @router /add [post]
  49. func (this *BIDaShboardController) AddDashboard() {
  50. br := new(models.BaseResponse).Init()
  51. defer func() {
  52. this.Data["json"] = br
  53. this.ServeJSON()
  54. }()
  55. var req bi_dashboard.AddDashboardReq
  56. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  57. if err != nil {
  58. br.Msg = "参数解析异常!"
  59. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  60. return
  61. }
  62. if req.BiDashboardName == "" {
  63. br.Msg = "名称不能为空"
  64. return
  65. }
  66. nameItem, err := bi_dashboard.GetDashboardByName(req.BiDashboardName, this.SysUser.AdminId)
  67. if err != nil && err.Error() != utils.ErrNoRow() {
  68. br.Msg = "查询失败"
  69. br.ErrMsg = "查询失败,Err:" + err.Error()
  70. return
  71. }
  72. if nameItem != nil && nameItem.BiDashboardId > 0 {
  73. br.Msg = "名称重复"
  74. return
  75. }
  76. item := &bi_dashboard.BiDashboard{
  77. //BiDashboardClassifyId: req.ClassifyId,
  78. BiDashboardName: req.BiDashboardName,
  79. SysAdminId: this.SysUser.AdminId,
  80. SysAdminName: this.SysUser.RealName,
  81. //Sort: 0,
  82. CreateTime: time.Now(),
  83. ModifyTime: time.Now(),
  84. State: 1,
  85. }
  86. id, e := bi_dashboard.AddBiDashboard(item)
  87. if e != nil {
  88. err = e
  89. br.Msg = "新增失败"
  90. br.ErrMsg = "新增失败,Err:" + e.Error()
  91. return
  92. }
  93. detailList := make([]*bi_dashboard.BiDashboardDetail, 0)
  94. for i, v := range req.List {
  95. item := &bi_dashboard.BiDashboardDetail{
  96. BiDashboardId: int(id),
  97. Type: v.Type,
  98. UniqueCode: v.UniqueCode,
  99. Sort: i + 1,
  100. CreateTime: time.Now(),
  101. ModifyTime: time.Now(),
  102. }
  103. detailList = append(detailList, item)
  104. }
  105. err = bi_dashboard.AddBiDashboardDetailMulti(detailList)
  106. if err != nil {
  107. br.Msg = "新增详情失败"
  108. br.ErrMsg = "新增详情失败,Err:" + err.Error()
  109. return
  110. }
  111. br.Ret = 200
  112. br.Success = true
  113. br.Msg = "新增成功"
  114. //br.Data =
  115. }
  116. // EditPpt
  117. // @Title 编辑看板
  118. // @Description 编辑看板接口
  119. // @Param request body bi_dashboard.EditDashboardReq true "type json string"
  120. // @Success 200 Ret=200 编辑成功
  121. // @router /edit [post]
  122. func (this *BIDaShboardController) EditDashboard() {
  123. br := new(models.BaseResponse).Init()
  124. defer func() {
  125. this.Data["json"] = br
  126. this.ServeJSON()
  127. }()
  128. var req bi_dashboard.EditDashboardReq
  129. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  130. if err != nil {
  131. br.Msg = "参数解析异常!"
  132. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  133. return
  134. }
  135. if req.BiDashboardName == "" {
  136. br.Msg = "标题不能为空"
  137. return
  138. }
  139. item, err := bi_dashboard.GetDashboardById(req.BiDashboardId)
  140. if err != nil {
  141. br.Msg = "获取数据异常!"
  142. br.ErrMsg = "获取数据异常,Err:" + err.Error()
  143. return
  144. }
  145. // 修改
  146. item.BiDashboardName = req.BiDashboardName
  147. item.ModifyTime = time.Now()
  148. err = bi_dashboard.EditDashboard(item)
  149. if err != nil {
  150. br.Msg = "编辑失败"
  151. br.ErrMsg = "编辑失败,Err:" + err.Error()
  152. return
  153. }
  154. err = bi_dashboard.DeleteBiDashboardDetail(req.BiDashboardId)
  155. if err != nil {
  156. br.Msg = "删除详情失败"
  157. br.ErrMsg = "删除详情失败,Err:" + err.Error()
  158. return
  159. }
  160. detailList := make([]*bi_dashboard.BiDashboardDetail, 0)
  161. for _, v := range req.List {
  162. item := &bi_dashboard.BiDashboardDetail{
  163. BiDashboardId: req.BiDashboardId,
  164. Type: v.Type,
  165. UniqueCode: v.UniqueCode,
  166. Sort: v.Sort,
  167. CreateTime: time.Now(),
  168. ModifyTime: time.Now(),
  169. }
  170. detailList = append(detailList, item)
  171. }
  172. err = bi_dashboard.AddBiDashboardDetailMulti(detailList)
  173. if err != nil {
  174. br.Msg = "新增详情失败"
  175. br.ErrMsg = "新增详情失败,Err:" + err.Error()
  176. return
  177. }
  178. br.Ret = 200
  179. br.Success = true
  180. br.Msg = "编辑成功"
  181. br.IsAddLog = true
  182. }
  183. // DeleteDashboard
  184. // @Title 删除看板
  185. // @Description 删除看板接口
  186. // @Param request body bi_dashboard.DelDashboardReq true "type json string"
  187. // @Success 200 Ret=200 删除成功
  188. // @router /delete [post]
  189. func (this *BIDaShboardController) DeleteDashboard() {
  190. br := new(models.BaseResponse).Init()
  191. defer func() {
  192. this.Data["json"] = br
  193. this.ServeJSON()
  194. }()
  195. var req bi_dashboard.DelDashboardReq
  196. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  197. if err != nil {
  198. br.Msg = "参数解析异常!"
  199. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  200. return
  201. }
  202. if req.BiDashboardId <= 0 {
  203. br.Msg = "参数错误"
  204. return
  205. }
  206. item, err := bi_dashboard.GetDashboardById(req.BiDashboardId)
  207. if err != nil {
  208. br.Msg = "获取数据异常!"
  209. br.ErrMsg = "获取数据异常,Err:" + err.Error()
  210. return
  211. }
  212. if item.SysAdminId != this.SysUser.AdminId {
  213. br.Msg = "无权删除"
  214. return
  215. }
  216. err = bi_dashboard.DelDashboard(req.BiDashboardId)
  217. if err != nil {
  218. br.Msg = "删除失败"
  219. br.ErrMsg = "删除失败,Err:" + err.Error()
  220. return
  221. }
  222. //如果该看板存在共享记录,则删除共享
  223. err = bi_dashboard.DeleteDashboardGrant(req.BiDashboardId)
  224. if err != nil {
  225. br.Msg = "删除失败"
  226. br.ErrMsg = "删除失败,Err:" + err.Error()
  227. return
  228. }
  229. br.Ret = 200
  230. br.Success = true
  231. br.IsAddLog = true
  232. br.Msg = "删除成功"
  233. }
  234. // DeleteDashboard
  235. // @Title 删除看板详情
  236. // @Description 删除看板详情接口
  237. // @Param request body bi_dashboard.DelDashboardDetailReq true "type json string"
  238. // @Success 200 Ret=200 删除成功
  239. // @router /detail/delete [post]
  240. func (this *BIDaShboardController) DeleteDashboardDetail() {
  241. br := new(models.BaseResponse).Init()
  242. defer func() {
  243. this.Data["json"] = br
  244. this.ServeJSON()
  245. }()
  246. var req bi_dashboard.DelDashboardDetailReq
  247. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  248. if err != nil {
  249. br.Msg = "参数解析异常!"
  250. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  251. return
  252. }
  253. if req.BiDashboardDetailId <= 0 {
  254. br.Msg = "参数错误"
  255. return
  256. }
  257. err = bi_dashboard.DeleteBiDashboardDetailByDetailId(req.BiDashboardDetailId)
  258. if err != nil {
  259. br.Msg = "删除失败"
  260. br.ErrMsg = "删除失败,Err:" + err.Error()
  261. return
  262. }
  263. br.Ret = 200
  264. br.Success = true
  265. br.IsAddLog = true
  266. br.Msg = "删除成功"
  267. }
  268. // DetailDashboard
  269. // @Title 获取看板详情
  270. // @Description 获取看板详情接口
  271. // @Param PptId query int true "PptId"
  272. // @Success 200 {object} models.PptV2
  273. // @router /detail [get]
  274. func (this *BIDaShboardController) DetailDashboard() {
  275. br := new(models.BaseResponse).Init()
  276. defer func() {
  277. if br.ErrMsg == "" {
  278. br.IsSendEmail = false
  279. }
  280. this.Data["json"] = br
  281. this.ServeJSON()
  282. }()
  283. sysUser := this.SysUser
  284. if sysUser == nil {
  285. br.Msg = "请登录"
  286. br.ErrMsg = "请登录,SysUser Is Empty"
  287. br.Ret = 408
  288. return
  289. }
  290. dashboardId, _ := this.GetInt("DashboardId")
  291. resp := new(bi_dashboard.DashboardDetailResp)
  292. dashboardItem, err := bi_dashboard.GetDashboardById(dashboardId)
  293. if err != nil {
  294. err = errors.New("我的看板列表查询出错:" + err.Error())
  295. br.Msg = "我的看板列表查询出错"
  296. br.ErrMsg = err.Error()
  297. return
  298. }
  299. grantInfoList, err := bi_dashboard.GetDashboardGrantInfo(dashboardId)
  300. if err != nil {
  301. br.Msg = "信息获取失败"
  302. br.ErrMsg = "共享信息获取失败,Err:" + err.Error()
  303. return
  304. }
  305. if len(grantInfoList) > 0 {
  306. resp.IsGrant = 1
  307. }
  308. detailList, err := bi_dashboard.GetBiDashboardDetailById(dashboardId)
  309. if err != nil {
  310. br.Msg = "详情获取失败"
  311. br.ErrMsg = "详情获取失败,Err:" + err.Error()
  312. return
  313. }
  314. editor, e := services.UpdateBiDashboardEditing(dashboardId, 0, sysUser.AdminId, sysUser.RealName)
  315. if e != nil {
  316. br.Msg = "编辑状态更新失败"
  317. br.ErrMsg = "编辑状态更新失败,Err:" + e.Error()
  318. return
  319. }
  320. resp.Editor = editor
  321. resp.BiDashboard = dashboardItem
  322. resp.List = detailList
  323. br.Ret = 200
  324. br.Success = true
  325. br.Msg = "获取成功"
  326. br.Data = resp
  327. }
  328. // MoveDashboard
  329. // @Title 移动看板详情
  330. // @Description 移动看板详情接口
  331. // @Param request body bi_dashboard.MoveDashboardDetailReq true "type json string"
  332. // @Success 200 Ret=200 移动成功
  333. // @router /detail/move [post]
  334. func (this *BIDaShboardController) MoveDashboard() {
  335. br := new(models.BaseResponse).Init()
  336. defer func() {
  337. this.Data["json"] = br
  338. this.ServeJSON()
  339. }()
  340. var req bi_dashboard.MoveDashboardDetailReq
  341. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  342. if err != nil {
  343. br.Msg = "参数解析异常!"
  344. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  345. return
  346. }
  347. if req.BiDashboardId <= 0 {
  348. br.Msg = "参数错误"
  349. return
  350. }
  351. if req.BiDashboardDetailId == req.OtherDetailId || req.BiDashboardDetailId <= 0 || req.OtherDetailId <= 0 {
  352. br.Msg = "看板Id有误"
  353. return
  354. }
  355. if req.Sort < 0 || req.OtherSort < 0 || req.Sort == req.OtherSort {
  356. br.Msg = "排序有误"
  357. return
  358. }
  359. item, err := bi_dashboard.GetDashboardById(req.BiDashboardId)
  360. if err != nil {
  361. br.Msg = "获取数据异常!"
  362. br.ErrMsg = "获取数据异常,Err:" + err.Error()
  363. return
  364. }
  365. // 判断权限
  366. if item.SysAdminId != this.SysUser.AdminId {
  367. br.Msg = `无权移动`
  368. return
  369. }
  370. // 修改
  371. detailItem := &bi_dashboard.BiDashboardDetail{
  372. BiDashboardDetailId: req.BiDashboardDetailId,
  373. Sort: req.OtherSort,
  374. ModifyTime: time.Now(),
  375. }
  376. err = bi_dashboard.EditBiDashboardDetail(detailItem)
  377. if err != nil {
  378. br.Msg = "编辑详情失败"
  379. br.ErrMsg = "编辑详情失败,Err:" + err.Error()
  380. return
  381. }
  382. otherItem := &bi_dashboard.BiDashboardDetail{
  383. BiDashboardDetailId: req.OtherDetailId,
  384. Sort: req.Sort,
  385. ModifyTime: time.Now(),
  386. }
  387. err = bi_dashboard.EditBiDashboardDetail(otherItem)
  388. if err != nil {
  389. br.Msg = "编辑详情失败"
  390. br.ErrMsg = "编辑详情失败,Err:" + err.Error()
  391. return
  392. }
  393. br.Ret = 200
  394. br.Success = true
  395. br.Msg = "编辑成功"
  396. br.IsAddLog = true
  397. }
  398. // ShareList
  399. // @Title 获取共享列表
  400. // @Description 获取共享列表接口
  401. // @Success 200 {object} models.RespGroupList
  402. // @router /share_list [get]
  403. func (this *BIDaShboardController) ShareList() {
  404. br := new(models.BaseResponse).Init()
  405. defer func() {
  406. this.Data["json"] = br
  407. this.ServeJSON()
  408. }()
  409. //myPptList := make([]*bi_dashboard.BiDashboard, 0)
  410. //otherPptList := make([]*bi_dashboard.BiDashboard, 0)
  411. grantList := bi_dashboard.RespGroupList{}
  412. // 获取我的看板列表
  413. ShareList, err := bi_dashboard.GetAllMyShareList(this.SysUser.AdminId)
  414. if err != nil {
  415. err = errors.New("我的看板列表查询出错:" + err.Error())
  416. br.ErrMsg = err.Error()
  417. br.Msg = "查询失败"
  418. return
  419. }
  420. grantList.MyList = ShareList
  421. //dashboardMap := make(map[int]*bi_dashboard.BiDashboard)
  422. adminIdList := make([]int, 0) //需要查询的创建人admin_id列表集合
  423. adminIdMap := make(map[int]int) //需要查询的创建人admin_id集合,用来去重的,避免重复id
  424. grantDashboardList, err := bi_dashboard.GetAllGrantList(this.SysUser.AdminId)
  425. if err != nil {
  426. err = errors.New("我的看板列表查询出错:" + err.Error())
  427. br.ErrMsg = err.Error()
  428. br.Msg = "查询失败"
  429. return
  430. }
  431. publicAdminIdList := make([]int, 0)
  432. publicDashboardListMap := make(map[int][]*bi_dashboard.BiDashboard)
  433. for _, v := range grantDashboardList {
  434. publicDashboardList, ok := publicDashboardListMap[v.SysAdminId]
  435. if !ok {
  436. publicDashboardList = make([]*bi_dashboard.BiDashboard, 0)
  437. publicAdminIdList = append(publicAdminIdList, v.SysAdminId)
  438. if _, ok := adminIdMap[v.SysAdminId]; !ok {
  439. adminIdList = append(adminIdList, v.SysAdminId) //需要查询的创建人admin_id列表集合
  440. adminIdMap[v.SysAdminId] = v.SysAdminId //需要查询的创建人admin_id集合,用来去重的,避免重复id
  441. }
  442. }
  443. tmp := &bi_dashboard.BiDashboard{
  444. BiDashboardId: v.BiDashboardId,
  445. BiDashboardName: v.BiDashboardName,
  446. CreateTime: v.CreateTime,
  447. ModifyTime: v.ModifyTime,
  448. Sort: v.Sort,
  449. State: v.State,
  450. SysAdminId: v.SysAdminId,
  451. SysAdminName: v.SysAdminName,
  452. }
  453. publicDashboardList = append(publicDashboardList, tmp)
  454. publicDashboardListMap[v.SysAdminId] = publicDashboardList
  455. }
  456. // 创建人信息
  457. systemAdminMap := make(map[int]*system.Admin)
  458. systemAdminList, err := system.GetAdminListByIdList(adminIdList)
  459. if err != nil {
  460. return
  461. }
  462. for _, v := range systemAdminList {
  463. systemAdminMap[v.AdminId] = v
  464. }
  465. for _, v := range publicAdminIdList {
  466. systemAdmin, ok := systemAdminMap[v]
  467. if !ok {
  468. continue
  469. }
  470. // 看板 列表信息
  471. respGroupNameListItemList, ok := publicDashboardListMap[v]
  472. if !ok {
  473. respGroupNameListItemList = make([]*bi_dashboard.BiDashboard, 0)
  474. }
  475. // ppt 分组信息
  476. tmpRespGroupListItem := &bi_dashboard.RespOtherGroupListItem{
  477. GroupId: int64(systemAdmin.AdminId),
  478. GroupName: systemAdmin.RealName,
  479. AdminId: systemAdmin.AdminId,
  480. DashboardList: respGroupNameListItemList,
  481. }
  482. grantList.OtherList = append(grantList.OtherList, tmpRespGroupListItem)
  483. }
  484. //if len(dashboradIds) > 0 {
  485. // // 通过dashboradIds列表字段获取所有的看板信息
  486. // dashboradList, tmpErr := bi_dashboard.GetDashboradByIds(dashboradIds)
  487. // if tmpErr != nil {
  488. // err = errors.New("查询dashborad详情出错:" + err.Error())
  489. // br.Msg = "查询dashborad详情出错"
  490. // br.ErrMsg = err.Error()
  491. // return
  492. // }
  493. // for _, v := range dashboradList {
  494. // dashboardMap[v.BiDashboardId] = v
  495. // }
  496. //}
  497. br.Ret = 200
  498. br.Success = true
  499. br.Msg = "查询成功"
  500. br.Data = grantList
  501. return
  502. }
  503. // PublicList
  504. // @Title 获取公共列表
  505. // @Description 获取公共列表接口
  506. // @Success 200 {object} models.RespGroupList
  507. // @router /public_list [get]
  508. func (this *BIDaShboardController) PublicList() {
  509. br := new(models.BaseResponse).Init()
  510. defer func() {
  511. this.Data["json"] = br
  512. this.ServeJSON()
  513. }()
  514. resp := make([]*bi_dashboard.RespPublicGroupListItem, 0)
  515. // 获取公共看板列表
  516. publicCond := ` AND state = 6 `
  517. publicPars := make([]interface{}, 0)
  518. publicList, err := bi_dashboard.GetBiDashboardList(publicCond, publicPars)
  519. if err != nil {
  520. err = errors.New("我的看板列表查询出错:" + err.Error())
  521. return
  522. }
  523. //dashboardMap := make(map[int]*bi_dashboard.BiDashboard)
  524. adminIdList := make([]int, 0) //需要查询的创建人admin_id列表集合
  525. adminIdMap := make(map[int]int) //需要查询的创建人admin_id集合,用来去重的,避免重复id
  526. publicAdminIdList := make([]int, 0)
  527. publicDashboardListMap := make(map[int][]*bi_dashboard.BiDashboard)
  528. publicDashboardClassifyIdMap := make(map[int]int)
  529. for _, v := range publicList {
  530. publicDashboardList, ok := publicDashboardListMap[v.SysAdminId]
  531. if !ok {
  532. publicDashboardList = make([]*bi_dashboard.BiDashboard, 0)
  533. publicAdminIdList = append(publicAdminIdList, v.SysAdminId)
  534. if _, ok := adminIdMap[v.SysAdminId]; !ok {
  535. adminIdList = append(adminIdList, v.SysAdminId) //需要查询的创建人admin_id列表集合
  536. adminIdMap[v.SysAdminId] = v.SysAdminId //需要查询的创建人admin_id集合,用来去重的,避免重复id
  537. }
  538. }
  539. tmp := &bi_dashboard.BiDashboard{
  540. BiDashboardId: v.BiDashboardId,
  541. BiDashboardClassifyId: v.BiDashboardClassifyId,
  542. BiDashboardName: v.BiDashboardName,
  543. CreateTime: v.CreateTime,
  544. ModifyTime: v.ModifyTime,
  545. Sort: v.Sort,
  546. State: v.State,
  547. SysAdminId: v.SysAdminId,
  548. SysAdminName: v.SysAdminName,
  549. }
  550. publicDashboardList = append(publicDashboardList, tmp)
  551. publicDashboardListMap[v.SysAdminId] = publicDashboardList
  552. publicDashboardClassifyIdMap[v.BiDashboardClassifyId] = v.BiDashboardClassifyId
  553. }
  554. // 创建人信息
  555. systemAdminMap := make(map[int]*system.Admin)
  556. systemAdminList, err := system.GetAdminListByIdList(adminIdList)
  557. if err != nil {
  558. return
  559. }
  560. for _, v := range systemAdminList {
  561. systemAdminMap[v.AdminId] = v
  562. }
  563. for _, v := range adminIdList {
  564. systemAdmin, ok := systemAdminMap[v]
  565. if !ok {
  566. continue
  567. }
  568. // 看板 列表信息
  569. respGroupNameListItemList, ok := publicDashboardListMap[v]
  570. if !ok {
  571. respGroupNameListItemList = make([]*bi_dashboard.BiDashboard, 0)
  572. }
  573. // ppt 分组信息
  574. tmpRespGroupListItem := &bi_dashboard.RespPublicGroupListItem{
  575. GroupId: int64(systemAdmin.AdminId),
  576. GroupName: systemAdmin.RealName,
  577. AdminId: systemAdmin.AdminId,
  578. DashboardList: make([]*bi_dashboard.BiDashboard, 0),
  579. }
  580. for _, vv := range respGroupNameListItemList {
  581. tmpRespGroupListItem.DashboardList = append(tmpRespGroupListItem.DashboardList, vv)
  582. }
  583. resp = append(resp, tmpRespGroupListItem)
  584. }
  585. br.Ret = 200
  586. br.Success = true
  587. br.Msg = "查询成功"
  588. br.Data = resp
  589. return
  590. }
  591. // AddDashboardClassify
  592. // @Title 新增看板分类
  593. // @Description 新增看板分类接口
  594. // @Param request body bi_dashboard.AddDashboardClassifyReq true "type json string"
  595. // @Success 200 Ret=200 新增成功
  596. // @router /classify/add [post]
  597. func (this *BIDaShboardController) AddDashboardClassify() {
  598. br := new(models.BaseResponse).Init()
  599. defer func() {
  600. this.Data["json"] = br
  601. this.ServeJSON()
  602. }()
  603. var req bi_dashboard.AddDashboardClassifyReq
  604. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  605. if err != nil {
  606. br.Msg = "参数解析异常!"
  607. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  608. return
  609. }
  610. if req.ClassifyName == "" {
  611. br.Msg = "名称不能为空"
  612. return
  613. }
  614. maxSort, err := bi_dashboard.GetBiDashboardClassifyMaxSort()
  615. if err != nil {
  616. br.Msg = "获取最大排序值失败"
  617. br.ErrMsg = "获取最大排序值失败,Err:" + err.Error()
  618. return
  619. }
  620. count, err := bi_dashboard.GetBiDashboardClassifyByName(req.ClassifyName)
  621. if err != nil {
  622. br.Msg = "获取分类名称失败"
  623. br.ErrMsg = "获取分类名称失败,Err:" + err.Error()
  624. return
  625. }
  626. if count > 0 {
  627. br.Msg = "分类名称已存在"
  628. return
  629. }
  630. item := &bi_dashboard.BiDashboardClassify{
  631. BiDashboardClassifyName: req.ClassifyName,
  632. Sort: maxSort + 1,
  633. CreateTime: time.Now(),
  634. ModifyTime: time.Now(),
  635. }
  636. _, e := bi_dashboard.AddBiDashboardClassify(item)
  637. if e != nil {
  638. err = e
  639. br.Msg = "新增失败"
  640. br.ErrMsg = "新增失败,Err:" + e.Error()
  641. return
  642. }
  643. br.Ret = 200
  644. br.Success = true
  645. br.Msg = "新增成功"
  646. //br.Data =
  647. }
  648. // EditDashboardClassify
  649. // @Title 编辑看板分类
  650. // @Description 编辑看板分类接口
  651. // @Param request body bi_dashboard.EditDashboardReq true "type json string"
  652. // @Success 200 Ret=200 编辑成功
  653. // @router /classify/edit [post]
  654. func (this *BIDaShboardController) EditDashboardClassify() {
  655. br := new(models.BaseResponse).Init()
  656. defer func() {
  657. this.Data["json"] = br
  658. this.ServeJSON()
  659. }()
  660. var req bi_dashboard.EditDashboardClassifyReq
  661. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  662. if err != nil {
  663. br.Msg = "参数解析异常!"
  664. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  665. return
  666. }
  667. if req.ClassifyName == "" {
  668. br.Msg = "标题不能为空"
  669. return
  670. }
  671. if req.BiDashboardClassifyId <= 0 {
  672. br.Msg = "参数有误"
  673. br.ErrMsg = fmt.Sprintf("参数有误, BiDashboardClassifyId: %d", req.BiDashboardClassifyId)
  674. return
  675. }
  676. item, err := bi_dashboard.GetBiDashboardClassifyById(req.BiDashboardClassifyId)
  677. if err != nil && err.Error() != utils.ErrNoRow() {
  678. br.Msg = "获取数据异常!"
  679. br.ErrMsg = "获取数据异常,Err:" + err.Error()
  680. return
  681. }
  682. // 修改
  683. item.BiDashboardClassifyName = req.ClassifyName
  684. item.ModifyTime = time.Now()
  685. err = bi_dashboard.EditDashboardClassify(item)
  686. if err != nil {
  687. br.Msg = "编辑失败"
  688. br.ErrMsg = "编辑失败,Err:" + err.Error()
  689. return
  690. }
  691. br.Ret = 200
  692. br.Success = true
  693. br.Msg = "编辑成功"
  694. br.IsAddLog = true
  695. }
  696. // Grant
  697. // @Title 分配看板权限
  698. // @Description 分配看板权限接口
  699. // @Param request body models.GrantPptReq true "type json string"
  700. // @Success 200 Ret=200 分配成功
  701. // @router /grant [post]
  702. func (this *BIDaShboardController) Grant() {
  703. br := new(models.BaseResponse).Init()
  704. defer func() {
  705. this.Data["json"] = br
  706. this.ServeJSON()
  707. }()
  708. var req bi_dashboard.GrantDashboardReq
  709. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  710. if err != nil {
  711. br.Msg = "参数解析异常!"
  712. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  713. return
  714. }
  715. if req.AdminIdStr == "" {
  716. br.Msg = "参数错误"
  717. return
  718. }
  719. if req.BiDashboardId <= 0 {
  720. br.Msg = "参数错误"
  721. return
  722. }
  723. dashboardItem, err := bi_dashboard.GetDashboardById(req.BiDashboardId)
  724. if err != nil {
  725. err = errors.New("我的看板列表查询出错:" + err.Error())
  726. br.Msg = "我的看板列表查询出错"
  727. br.ErrMsg = err.Error()
  728. return
  729. }
  730. if dashboardItem.SysAdminId != this.SysUser.AdminId {
  731. br.Msg = "无权配置"
  732. return
  733. }
  734. list := make([]*bi_dashboard.BiDashboardGrant, 0)
  735. grantAdminIdStrList := strings.Split(req.AdminIdStr, ",")
  736. lenGrantAdminIdStrList := len(grantAdminIdStrList) //指定用户的人数
  737. for _, v := range grantAdminIdStrList {
  738. grantAdminId, tmpErr := strconv.Atoi(v)
  739. if tmpErr != nil {
  740. br.Msg = "参数有误"
  741. br.ErrMsg = fmt.Sprintf("参数有误,Err:%s", tmpErr.Error())
  742. return
  743. }
  744. //如果只选择了自己作为指定的人,那么就提示他报错。如果多人,那么就过滤自己
  745. if grantAdminId == this.SysUser.AdminId {
  746. if lenGrantAdminIdStrList == 1 {
  747. br.Msg = "不能指定自己为权限用户"
  748. br.ErrMsg = fmt.Sprintf("参数有误,Err:%s", tmpErr.Error())
  749. return
  750. }
  751. continue
  752. }
  753. tmpV := &bi_dashboard.BiDashboardGrant{
  754. BiDashboardId: req.BiDashboardId,
  755. GrantAdminId: grantAdminId,
  756. CreateTime: time.Now(),
  757. }
  758. list = append(list, tmpV)
  759. }
  760. if len(list) <= 0 {
  761. br.Msg = "参数有误"
  762. br.ErrMsg = fmt.Sprintf("参数有误,Err:%s", "指定用户为空")
  763. return
  764. }
  765. err = bi_dashboard.MultiAddDashboardGrant(req.BiDashboardId, list)
  766. if err != nil {
  767. br.Msg = "分配失败"
  768. br.ErrMsg = fmt.Sprintf("分配失败,Err:%s", err.Error())
  769. return
  770. }
  771. br.Ret = 200
  772. br.Success = true
  773. br.IsAddLog = true
  774. br.Msg = "分配成功"
  775. }
  776. // Public
  777. // @Title
  778. // @Description 设置公共看板
  779. // @Param request body models.GrantPptReq true "type json string"
  780. // @Success 200 Ret=200 分配成功
  781. // @router /public [post]
  782. func (this *BIDaShboardController) Public() {
  783. br := new(models.BaseResponse).Init()
  784. defer func() {
  785. this.Data["json"] = br
  786. this.ServeJSON()
  787. }()
  788. var req bi_dashboard.PublicDashboardReq
  789. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  790. if err != nil {
  791. br.Msg = "参数解析异常!"
  792. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  793. return
  794. }
  795. item, err := bi_dashboard.GetDashboardById(req.BiDashboardId)
  796. if err != nil {
  797. br.Msg = "获取数据异常!"
  798. br.ErrMsg = "获取数据异常,Err:" + err.Error()
  799. return
  800. }
  801. item.State = 6
  802. err = bi_dashboard.EditDashboard(item)
  803. if err != nil {
  804. br.Msg = "编辑失败"
  805. br.ErrMsg = "编辑失败,Err:" + err.Error()
  806. return
  807. }
  808. br.Ret = 200
  809. br.Success = true
  810. br.IsAddLog = true
  811. br.Msg = "分配成功"
  812. }
  813. // GroupList
  814. // @Title 获取分类列表
  815. // @Description 获取分类列表接口
  816. // @Success 200 {object} models.RespGroupList
  817. // @router /classify/list [get]
  818. func (this *BIDaShboardController) ClassifyList() {
  819. br := new(models.BaseResponse).Init()
  820. defer func() {
  821. this.Data["json"] = br
  822. this.ServeJSON()
  823. }()
  824. classifyList, err := bi_dashboard.GetBiDashboardClassifyAllList()
  825. if err != nil {
  826. br.Msg = "查询失败"
  827. br.ErrMsg = "查询失败,Err:" + err.Error()
  828. return
  829. }
  830. br.Ret = 200
  831. br.Success = true
  832. br.Msg = "查询成功"
  833. br.Data = classifyList
  834. return
  835. }
  836. // CancelGrant
  837. // @Title 取消分配看板权限
  838. // @Description 取消分配看板权限
  839. // @Param request body bi_dashboard.DelDashboardReq true "type json string"
  840. // @Success 200 Ret=200 分配成功
  841. // @router /grant/cancel [post]
  842. func (this *BIDaShboardController) CancelGrant() {
  843. br := new(models.BaseResponse).Init()
  844. defer func() {
  845. this.Data["json"] = br
  846. this.ServeJSON()
  847. }()
  848. var req bi_dashboard.DelDashboardReq
  849. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  850. if err != nil {
  851. br.Msg = "参数解析异常!"
  852. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  853. return
  854. }
  855. if req.BiDashboardId <= 0 {
  856. br.Msg = "参数错误"
  857. return
  858. }
  859. item, err := bi_dashboard.GetDashboardById(req.BiDashboardId)
  860. if err != nil {
  861. br.Msg = "数据不存在"
  862. br.ErrMsg = "数据不存在,Err:" + err.Error()
  863. return
  864. }
  865. if item.SysAdminId != this.SysUser.AdminId {
  866. br.Msg = "无权配置"
  867. return
  868. }
  869. // 分配
  870. err = bi_dashboard.DeleteDashboardGrant(req.BiDashboardId)
  871. if err != nil {
  872. br.Msg = "取消失败"
  873. br.ErrMsg = "取消失败,Err:" + err.Error()
  874. return
  875. }
  876. br.Ret = 200
  877. br.Success = true
  878. br.IsAddLog = true
  879. br.Msg = "取消成功"
  880. }
  881. // GrantInfo
  882. // @Title 获取分配ppt权限详情
  883. // @Description 获取分配ppt权限详情接口
  884. // @Param BiDashboardId query int true "看板的id"
  885. // @Success 200 {object} models.GrantInfoResp
  886. // @router /grant/info [get]
  887. func (this *BIDaShboardController) GrantInfo() {
  888. br := new(models.BaseResponse).Init()
  889. defer func() {
  890. this.Data["json"] = br
  891. this.ServeJSON()
  892. }()
  893. biDashboardId, _ := this.GetInt("BiDashboardId")
  894. if biDashboardId <= 0 {
  895. br.Msg = "参数错误"
  896. return
  897. }
  898. item, err := bi_dashboard.GetDashboardById(biDashboardId)
  899. if err != nil {
  900. br.Msg = "数据不存在"
  901. br.ErrMsg = "数据不存在,Err:" + err.Error()
  902. return
  903. }
  904. if item.SysAdminId != this.SysUser.AdminId {
  905. br.Msg = "无权配置"
  906. return
  907. }
  908. grantInfoList, err := bi_dashboard.GetDashboardGrantInfo(biDashboardId)
  909. if err != nil {
  910. br.Msg = "信息获取失败"
  911. br.ErrMsg = "信息获取失败,Err:" + err.Error()
  912. return
  913. }
  914. if len(grantInfoList) <= 0 {
  915. br.Msg = "未配置"
  916. br.IsSendEmail = false
  917. br.Success = true
  918. br.Ret = 200
  919. return
  920. }
  921. var adminIdStr string
  922. adminIdsList := make([]string, 0)
  923. for _, v := range grantInfoList {
  924. adminIdsList = append(adminIdsList, strconv.Itoa(int(v.GrantAdminId)))
  925. }
  926. adminIdStr = strings.Join(adminIdsList, ",")
  927. br.Ret = 200
  928. br.Success = true
  929. br.Data = adminIdStr
  930. br.Msg = "查询成功"
  931. }
  932. // Public
  933. // @Title
  934. // @Description 撤销公共看板
  935. // @Param request body models.GrantPptReq true "type json string"
  936. // @Success 200 Ret=200 分配成功
  937. // @router /public/cancel [post]
  938. func (this *BIDaShboardController) PublicCancel() {
  939. br := new(models.BaseResponse).Init()
  940. defer func() {
  941. this.Data["json"] = br
  942. this.ServeJSON()
  943. }()
  944. var req bi_dashboard.DelDashboardReq
  945. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  946. if err != nil {
  947. br.Msg = "参数解析异常!"
  948. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  949. return
  950. }
  951. item, err := bi_dashboard.GetDashboardById(req.BiDashboardId)
  952. if err != nil && err.Error() != utils.ErrNoRow() {
  953. br.Msg = "获取数据异常!"
  954. br.ErrMsg = "获取数据异常,Err:" + err.Error()
  955. return
  956. }
  957. item.State = 1
  958. err = bi_dashboard.EditDashboard(item)
  959. if err != nil {
  960. br.Msg = "编辑失败"
  961. br.ErrMsg = "编辑失败,Err:" + err.Error()
  962. return
  963. }
  964. br.Ret = 200
  965. br.Success = true
  966. br.IsAddLog = true
  967. br.Msg = "撤销成功"
  968. }
  969. // GroupList
  970. // @Title 获取我的首页看板
  971. // @Description 获取我的首页看板接口
  972. // @Success 200 {object} models.RespGroupList
  973. // @router /home_page [get]
  974. func (this *BIDaShboardController) HomePage() {
  975. br := new(models.BaseResponse).Init()
  976. defer func() {
  977. this.Data["json"] = br
  978. this.ServeJSON()
  979. }()
  980. item, err := bi_dashboard.GetBiDashboardHomePageById(this.SysUser.AdminId)
  981. if err != nil && err.Error() != utils.ErrNoRow() {
  982. br.Msg = "数据不存在"
  983. br.ErrMsg = "数据不存在,Err:" + err.Error()
  984. return
  985. }
  986. publicCond := ` AND state = 6 AND bi_dashboard_classify_id > 0 `
  987. publicPars := []interface{}{this.SysUser.AdminId}
  988. publicList, err := bi_dashboard.GetBiDashboardList(publicCond, publicPars)
  989. if err != nil {
  990. err = errors.New("我的看板列表查询出错:" + err.Error())
  991. return
  992. }
  993. if item.BiDashboardHomePageId == 0 && len(publicList) > 0 {
  994. item = &bi_dashboard.BiDashboardHomePage{
  995. AdminId: publicList[0].SysAdminId,
  996. BiDashboardId: publicList[0].BiDashboardId,
  997. FromType: 3,
  998. }
  999. }
  1000. if item.BiDashboardId == 0 {
  1001. item = nil
  1002. }
  1003. br.Ret = 200
  1004. br.Success = true
  1005. br.Msg = "查询成功"
  1006. br.Data = item
  1007. return
  1008. }
  1009. // GroupList
  1010. // @Title 保存我的看板首页
  1011. // @Description保存我的看板首页接口
  1012. // @Success 200 {object} models.RespGroupList
  1013. // @router /home_page/save [post]
  1014. func (this *BIDaShboardController) HomePageSave() {
  1015. br := new(models.BaseResponse).Init()
  1016. defer func() {
  1017. this.Data["json"] = br
  1018. this.ServeJSON()
  1019. }()
  1020. var req bi_dashboard.SaveHomePageReq
  1021. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  1022. if err != nil {
  1023. br.Msg = "参数解析异常!"
  1024. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  1025. return
  1026. }
  1027. if req.BiDashboardId <= 0 {
  1028. br.Msg = "参数错误"
  1029. return
  1030. }
  1031. item, err := bi_dashboard.GetBiDashboardHomePageById(this.SysUser.AdminId)
  1032. if err != nil && err.Error() != utils.ErrNoRow() {
  1033. br.Msg = "首页看板查询失败"
  1034. br.ErrMsg = "首页看板查询失败,Err:" + err.Error()
  1035. return
  1036. }
  1037. homePageItem := &bi_dashboard.BiDashboardHomePage{
  1038. BiDashboardId: req.BiDashboardId,
  1039. AdminId: this.SysUser.AdminId,
  1040. CreateTime: time.Now(),
  1041. ModifyTime: time.Now(),
  1042. FromType: req.FromType,
  1043. }
  1044. if item.BiDashboardHomePageId > 0 {
  1045. homePageItem.BiDashboardHomePageId = item.BiDashboardHomePageId
  1046. }
  1047. err = bi_dashboard.SaveBiDashboardHomePage(homePageItem)
  1048. if err != nil {
  1049. br.Msg = "保存失败"
  1050. br.ErrMsg = "保存失败,Err:" + err.Error()
  1051. return
  1052. }
  1053. br.Ret = 200
  1054. br.Success = true
  1055. br.Msg = "保存成功"
  1056. return
  1057. }
  1058. // Editing
  1059. // @Title 标记/查询编辑状态
  1060. // @Description 标记/查询编辑状态
  1061. // @Param request body models.PPTEditingReq true "type json string"
  1062. // @Success 200 Ret=200 操作成功
  1063. // @router /editing [post]
  1064. func (this *BIDaShboardController) Editing() {
  1065. br := new(models.BaseResponse).Init()
  1066. defer func() {
  1067. if br.ErrMsg == "" {
  1068. br.IsSendEmail = false
  1069. }
  1070. this.Data["json"] = br
  1071. this.ServeJSON()
  1072. }()
  1073. sysUser := this.SysUser
  1074. if sysUser == nil {
  1075. br.Msg = "请登录"
  1076. br.ErrMsg = "请登录,SysUser Is Empty"
  1077. br.Ret = 408
  1078. return
  1079. }
  1080. var req bi_dashboard.BiDashboardEditingReq
  1081. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  1082. if err != nil {
  1083. br.Msg = "参数解析异常!"
  1084. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  1085. return
  1086. }
  1087. if req.BiDashboardId <= 0 {
  1088. br.Msg = "参数有误"
  1089. return
  1090. }
  1091. if req.Status < 0 {
  1092. br.Msg = "标记状态异常"
  1093. return
  1094. }
  1095. editor, e := services.UpdateBiDashboardEditing(req.BiDashboardId, req.Status, sysUser.AdminId, sysUser.RealName)
  1096. if e != nil {
  1097. br.Msg = "操作失败"
  1098. br.ErrMsg = "更新编辑状态失败, err: " + e.Error()
  1099. return
  1100. }
  1101. br.Data = editor
  1102. br.Ret = 200
  1103. br.Success = true
  1104. br.Msg = "操作成功"
  1105. }
  1106. // GroupList
  1107. // @Title 获取我拥有的图库表格菜单权限
  1108. // @Description 获取我拥有的图库表格菜单权限接口
  1109. // @Success 200 {object} models.RespGroupList
  1110. // @router /chart_excel_permission [get]
  1111. func (this *BIDaShboardController) ChartExcelPermission() {
  1112. br := new(models.BaseResponse).Init()
  1113. defer func() {
  1114. this.Data["json"] = br
  1115. this.ServeJSON()
  1116. }()
  1117. sysUser := this.SysUser
  1118. if sysUser == nil {
  1119. br.Msg = "请登录"
  1120. br.ErrMsg = "请登录,SysUser Is Empty"
  1121. br.Ret = 408
  1122. return
  1123. }
  1124. roleId := sysUser.RoleId
  1125. //roleId=1
  1126. if roleId <= 0 {
  1127. br.Msg = "参数错误"
  1128. return
  1129. }
  1130. roleIds := strconv.Itoa(roleId)
  1131. //查询账号绑定的其他角色
  1132. otherRoles, err := system.GetRoleIdsByAdminId(sysUser.AdminId)
  1133. if err != nil {
  1134. br.Msg = "获取其他角色失败"
  1135. br.ErrMsg = "获取其他角色失败,Err:" + err.Error()
  1136. return
  1137. }
  1138. if len(otherRoles) > 0 {
  1139. for _, v := range otherRoles {
  1140. roleIds += "," + strconv.Itoa(v.RoleId)
  1141. }
  1142. }
  1143. groupId := 0
  1144. if utils.RunMode == "release" {
  1145. groupId = 37
  1146. } else {
  1147. groupId = 61
  1148. }
  1149. //共享客户组下的用户
  1150. shareSellerMap := make(map[int]bool, 0)
  1151. subAdmins, err := system.GetAdminByGroupId(groupId)
  1152. if err != nil && err.Error() != utils.ErrNoRow() {
  1153. br.Msg = "获取销售失败"
  1154. br.ErrMsg = "获取销售失败,Err:" + err.Error()
  1155. return
  1156. }
  1157. for _, admin := range subAdmins {
  1158. shareSellerMap[admin.AdminId] = true
  1159. }
  1160. list, err := system.GetMenuByRoleIds(roleIds)
  1161. if err != nil {
  1162. br.Msg = "获取失败"
  1163. br.ErrMsg = "获取失败,Err:" + err.Error()
  1164. return
  1165. }
  1166. lenList := len(list)
  1167. menuList := make([]*system.SysMenuSimple, 0)
  1168. chartExcelTypes, e := models.GetBusinessConfByKey("ChartExcelType")
  1169. if e != nil {
  1170. br.Msg = "获取失败"
  1171. br.ErrMsg = "获取商家配置失败, Err: " + e.Error()
  1172. return
  1173. }
  1174. types := strings.Split(chartExcelTypes.ConfVal, ",")
  1175. typeMap := map[string]bool{}
  1176. for _, v := range types {
  1177. typeMap[v] = true
  1178. }
  1179. for i := 0; i < lenList; i++ {
  1180. item := list[i]
  1181. if !typeMap[item.LevelPath] && !typeMap[item.Path] {
  1182. continue
  1183. }
  1184. newItem := &system.SysMenuSimple{
  1185. MenuId: item.MenuId,
  1186. ParentId: item.ParentId,
  1187. Name: item.Name,
  1188. Sort: item.Sort,
  1189. Path: item.Path,
  1190. NameEn: item.NameEn,
  1191. }
  1192. if item.IsLevel == 1 {
  1193. newItem.Path = item.LevelPath
  1194. }
  1195. menuList = append(menuList, newItem)
  1196. }
  1197. br.Ret = 200
  1198. br.Success = true
  1199. br.Msg = "查询成功"
  1200. br.Data = menuList
  1201. return
  1202. }