sys_role.go 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721
  1. package controllers
  2. import (
  3. "encoding/json"
  4. "eta_gn/eta_api/models"
  5. "eta_gn/eta_api/models/system"
  6. "eta_gn/eta_api/services"
  7. "eta_gn/eta_api/utils"
  8. "fmt"
  9. "github.com/rdlucklib/rdluck_tools/paging"
  10. "strconv"
  11. "strings"
  12. "time"
  13. )
  14. type SysRoleController struct {
  15. BaseAuthController
  16. }
  17. // @Title 新增角色
  18. // @Description 新增角色接口
  19. // @Param request body system.SysRoleAddReq true "type json string"
  20. // @Success 200 新增成功
  21. // @router /role/add [post]
  22. func (this *SysRoleController) Add() {
  23. br := new(models.BaseResponse).Init()
  24. defer func() {
  25. this.Data["json"] = br
  26. this.ServeJSON()
  27. }()
  28. var req system.SysRoleAddReq
  29. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  30. if err != nil {
  31. br.Msg = "参数解析异常!"
  32. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  33. return
  34. }
  35. if req.RoleName == "" {
  36. br.Msg = "角色名称不能为空"
  37. return
  38. }
  39. count, err := system.GetSysRoleCount(req.RoleName)
  40. if err != nil && !utils.IsErrNoRow(err) {
  41. br.Msg = "获取数据失败"
  42. br.ErrMsg = "获取数据失败,Err:" + err.Error()
  43. return
  44. }
  45. if count > 0 {
  46. br.Msg = "角色已存在,请重新输入"
  47. return
  48. }
  49. item := new(system.SysRole)
  50. item.RoleName = req.RoleName
  51. item.RoleType = req.RoleType
  52. item.RoleTypeCode = services.GetRoleTypeCode(req.RoleType)
  53. item.CreateTime = time.Now()
  54. item.ModifyTime = time.Now()
  55. _, err = system.AddSysRole(item)
  56. if err != nil {
  57. br.Msg = "新增失败"
  58. br.ErrMsg = "新增失败,Err:" + err.Error()
  59. return
  60. }
  61. br.Ret = 200
  62. br.Success = true
  63. br.Msg = "新增成功"
  64. }
  65. // @Title 修改角色
  66. // @Description 修改角色接口
  67. // @Param request body system.SysRoleEditReq true "type json string"
  68. // @Success 200 修改成功
  69. // @router /role/edit [post]
  70. func (this *SysRoleController) Edit() {
  71. br := new(models.BaseResponse).Init()
  72. defer func() {
  73. this.Data["json"] = br
  74. this.ServeJSON()
  75. }()
  76. var req system.SysRoleEditReq
  77. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  78. if err != nil {
  79. br.Msg = "参数解析异常!"
  80. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  81. return
  82. }
  83. if req.RoleId <= 0 {
  84. br.Msg = "参数错误"
  85. br.ErrMsg = "参数错误,GroupId 小于等于0 "
  86. return
  87. }
  88. if req.RoleName == "" {
  89. br.Msg = "分组名称不能为空"
  90. return
  91. }
  92. item, e := system.GetSysRoleById(req.RoleId)
  93. if e != nil {
  94. if !utils.IsErrNoRow(e) {
  95. br.Msg = "操作失败"
  96. br.ErrMsg = "获取角色失败, Err: " + e.Error()
  97. return
  98. }
  99. br.Msg = "角色不存在, 请刷新页面"
  100. return
  101. }
  102. exists, e := system.GetSysRoleByName(req.RoleName)
  103. if e != nil && !utils.IsErrNoRow(e) {
  104. br.Msg = "操作失败"
  105. br.ErrMsg = "获取重名角色失败, Err: " + e.Error()
  106. return
  107. }
  108. if e == nil && exists.RoleId > 0 && exists.RoleId != item.RoleId {
  109. br.Msg = "名称已存在,请重新输入"
  110. return
  111. }
  112. roleTypeCode := services.GetRoleTypeCode(req.RoleType)
  113. e = system.ModifySysRole(req.RoleName, req.RoleType, roleTypeCode, req.RoleId)
  114. if e != nil {
  115. br.Msg = "操作失败"
  116. br.ErrMsg = "更新角色信息失败, Err: " + e.Error()
  117. return
  118. }
  119. br.Ret = 200
  120. br.Success = true
  121. br.IsAddLog = true
  122. br.Msg = "修改成功"
  123. }
  124. // @Title 删除角色
  125. // @Description 删除角色接口
  126. // @Param request body system.SysRoleDeleteReq true "type json string"
  127. // @Success 200 删除成功
  128. // @router /role/delete [post]
  129. func (this *SysRoleController) Delete() {
  130. br := new(models.BaseResponse).Init()
  131. defer func() {
  132. this.Data["json"] = br
  133. this.ServeJSON()
  134. }()
  135. var req system.SysRoleDeleteReq
  136. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  137. if err != nil {
  138. br.Msg = "参数解析异常!"
  139. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  140. return
  141. }
  142. if req.RoleId <= 0 {
  143. br.Msg = "参数错误"
  144. br.ErrMsg = "参数错误,GroupId 小于等于0 "
  145. return
  146. }
  147. _, e := system.GetSysRoleById(req.RoleId)
  148. if e != nil {
  149. if utils.IsErrNoRow(err) {
  150. br.Msg = "角色不存在, 请刷新页面"
  151. return
  152. }
  153. br.Msg = "删除失败"
  154. br.ErrMsg = "获取角色信息失败, Err: " + e.Error()
  155. return
  156. }
  157. err = system.DeleteSysRole(req.RoleId)
  158. if err != nil {
  159. br.Msg = "删除失败"
  160. br.ErrMsg = "删除失败,Err:" + err.Error()
  161. return
  162. }
  163. br.Ret = 200
  164. br.Success = true
  165. br.IsAddLog = true
  166. br.Msg = "删除成功"
  167. }
  168. // @Title 获取角色列表
  169. // @Description 获取角色列表接口
  170. // @Param PageSize query int true "每页数据条数"
  171. // @Param CurrentIndex query int true "当前页页码,从1开始"
  172. // @Param KeyWord query string true "搜索关键词"
  173. // @Success 200 {object} system.SysRoleListResp
  174. // @router /role/list [get]
  175. func (this *SysRoleController) ListSysRole() {
  176. br := new(models.BaseResponse).Init()
  177. defer func() {
  178. this.Data["json"] = br
  179. this.ServeJSON()
  180. }()
  181. sysUser := this.SysUser
  182. if sysUser == nil {
  183. br.Msg = "请登录"
  184. br.ErrMsg = "请登录,SysUser Is Empty"
  185. return
  186. }
  187. pageSize, _ := this.GetInt("PageSize")
  188. currentIndex, _ := this.GetInt("CurrentIndex")
  189. keyWord := this.GetString("KeyWord")
  190. var startSize int
  191. if pageSize <= 0 {
  192. pageSize = utils.PageSize20
  193. }
  194. if currentIndex <= 0 {
  195. currentIndex = 1
  196. }
  197. startSize = utils.StartIndex(currentIndex, pageSize)
  198. var condition string
  199. var pars []interface{}
  200. if keyWord != "" {
  201. condition += ` AND role_name LIKE '%` + keyWord + `%' `
  202. }
  203. total, err := system.GetSysRoleListCount(condition, pars)
  204. if err != nil {
  205. br.Msg = "获取失败"
  206. br.ErrMsg = "获取失败,Err:" + err.Error()
  207. return
  208. }
  209. list, err := system.GetSysRoleList(condition, pars, startSize, pageSize)
  210. if err != nil {
  211. br.Msg = "获取失败"
  212. br.ErrMsg = "获取失败,Err:" + err.Error()
  213. return
  214. }
  215. page := paging.GetPaging(currentIndex, pageSize, total)
  216. resp := new(system.SysRoleListResp)
  217. resp.List = list
  218. resp.Paging = page
  219. br.Ret = 200
  220. br.Success = true
  221. br.Msg = "获取成功"
  222. br.Data = resp
  223. }
  224. // SysRoleMenusList
  225. // @Title 角色设置权限-菜单列表-CRM14.1弃用
  226. // @Description 角色设置权限-菜单列表
  227. // @Param RoleId query int true "角色Id"
  228. // @Success 200 {object} system.SysRoleListResp
  229. // @router /role/menu/list [get]
  230. func (this *SysRoleController) SysRoleMenusList() {
  231. br := new(models.BaseResponse).Init()
  232. defer func() {
  233. this.Data["json"] = br
  234. this.ServeJSON()
  235. }()
  236. roleId, err := this.GetInt("RoleId")
  237. if err != nil {
  238. br.Msg = "获取角色失败"
  239. br.ErrMsg = "获取角色失败,Err:" + err.Error()
  240. return
  241. }
  242. fmt.Println("roleId", roleId)
  243. list := make([]*system.RoleMenuList, 0)
  244. sysUser := this.SysUser
  245. if sysUser == nil {
  246. br.Msg = "请登录"
  247. br.ErrMsg = "请登录,SysUser Is Empty"
  248. return
  249. }
  250. list, err = system.GetRoleMenuList()
  251. if err != nil {
  252. br.Msg = "获取失败"
  253. br.ErrMsg = "获取失败,Err:" + err.Error()
  254. return
  255. }
  256. lenList := len(list)
  257. for i := 0; i < lenList; i++ {
  258. item := list[i]
  259. child, err := system.GetRoleMenuByParentId(item.MenuId)
  260. if err != nil {
  261. br.Msg = "获取失败"
  262. br.ErrMsg = "获取子菜单数据失败,Err:" + err.Error()
  263. return
  264. }
  265. list[i].Child = child
  266. checkList := make([]int, 0)
  267. if roleId > 0 {
  268. checkItem, err := system.GetCheckListRoleMenu(roleId, item.MenuId)
  269. if err != nil {
  270. br.Msg = "获取失败"
  271. br.ErrMsg = "获取选择数据失败,Err:" + err.Error()
  272. return
  273. }
  274. for _, v := range checkItem {
  275. checkList = append(checkList, v.MenuId)
  276. }
  277. }
  278. list[i].CheckList = checkList
  279. }
  280. resp := new(system.RoleMenuListResp)
  281. resp.List = list
  282. br.Ret = 200
  283. br.Success = true
  284. br.Msg = "获取成功"
  285. br.Data = resp
  286. }
  287. // SysRoleMenusAdd
  288. // @Title 角色设置权限-CRM14.1弃用
  289. // @Description 角色设置权限
  290. // @Param request body system.RoleMenusAddReq true "type json string"
  291. // @Success 200 {object} system.SysRoleListResp
  292. // @router /role/menu/add [post]
  293. func (this *SysRoleController) SysRoleMenusAdd() {
  294. br := new(models.BaseResponse).Init()
  295. defer func() {
  296. this.Data["json"] = br
  297. this.ServeJSON()
  298. }()
  299. var req system.RoleMenusAddReq
  300. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  301. if err != nil {
  302. br.Msg = "参数解析异常!"
  303. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  304. return
  305. }
  306. roleId := req.RoleId
  307. if roleId <= 0 {
  308. br.Msg = "参数错误"
  309. br.ErrMsg = "参数错误,RoleId 小于等于0 "
  310. return
  311. }
  312. if req.MenuIdStr == "" {
  313. br.Msg = "请选择菜单"
  314. br.ErrMsg = "请选择菜单,MenuIdStr IS Empty "
  315. return
  316. }
  317. sysUser := this.SysUser
  318. if sysUser == nil {
  319. br.Msg = "请登录"
  320. br.ErrMsg = "请登录,SysUser Is Empty"
  321. return
  322. }
  323. err = system.DeleteRoleMenuByRoleId(roleId)
  324. if err != nil {
  325. br.Msg = "设置失败"
  326. br.ErrMsg = "清空原有设置失败,Err:" + err.Error()
  327. return
  328. }
  329. menuArr := strings.Split(req.MenuIdStr, ",")
  330. for _, v := range menuArr {
  331. menuId, err := strconv.Atoi(v)
  332. if err != nil {
  333. br.Msg = "设置失败"
  334. br.ErrMsg = "menuId 解析失败,Err:" + err.Error()
  335. return
  336. }
  337. item := new(system.SysRoleMenu)
  338. item.RoleId = roleId
  339. item.MenuId = menuId
  340. _, err = system.AddSysRoleMenu(item)
  341. if err != nil {
  342. br.Msg = "设置失败"
  343. br.ErrMsg = "新增设置失败,Err:" + err.Error()
  344. return
  345. }
  346. }
  347. if req.MenuButtonIdStr != "" {
  348. err = system.DeleteSysRoleButton(roleId)
  349. if err != nil {
  350. br.Msg = "设置失败"
  351. br.ErrMsg = "删除已设置数据失败,Err:" + err.Error()
  352. return
  353. }
  354. buttonMap := make(map[string]string)
  355. buttonArr := strings.Split(req.MenuButtonIdStr, ",")
  356. for _, v := range buttonArr {
  357. if _, ok := buttonMap[v]; !ok {
  358. buttonId, err := strconv.Atoi(v)
  359. count, err := system.GetSysRoleButtonCount(roleId, buttonId)
  360. if err != nil {
  361. br.Msg = "判断设置失败存在失败"
  362. br.ErrMsg = "判断设置失败存在失败,Err:" + err.Error()
  363. return
  364. }
  365. if count <= 0 {
  366. button := new(system.SysRoleButton)
  367. button.RoleId = roleId
  368. button.MenuButtonId = buttonId
  369. button.CreateTime = time.Now()
  370. _, err = system.AddSysRoleButton(button)
  371. if err != nil {
  372. br.Msg = "设置失败"
  373. br.ErrMsg = "按钮权限设置失败,Err:" + err.Error()
  374. return
  375. }
  376. }
  377. }
  378. buttonMap[v] = v
  379. }
  380. } else {
  381. err = system.DeleteSysRoleButton(roleId)
  382. if err != nil {
  383. br.Msg = "设置失败"
  384. br.ErrMsg = "删除已设置数据失败,Err:" + err.Error()
  385. return
  386. }
  387. }
  388. br.Ret = 200
  389. br.Success = true
  390. br.IsAddLog = true
  391. br.Msg = "设置成功"
  392. }
  393. // @Title 获取所有角色
  394. // @Description 获取所有角色
  395. // @Success 200 {object} system.SysRoleListResp
  396. // @router /role/all [get]
  397. func (this *SysRoleController) AllSysRole() {
  398. br := new(models.BaseResponse).Init()
  399. defer func() {
  400. this.Data["json"] = br
  401. this.ServeJSON()
  402. }()
  403. sysUser := this.SysUser
  404. if sysUser == nil {
  405. br.Msg = "请登录"
  406. br.ErrMsg = "请登录,SysUser Is Empty"
  407. return
  408. }
  409. levelFlag := false
  410. roleLevel := this.GetString("RoleLevel")
  411. if roleLevel != "" {
  412. levelFlag = true
  413. }
  414. list, err := system.GetSysRoleAll(levelFlag)
  415. if err != nil {
  416. br.Msg = "获取失败"
  417. br.ErrMsg = "获取失败,Err:" + err.Error()
  418. return
  419. }
  420. resp := new(system.SysRoleAllResp)
  421. resp.List = list
  422. br.Ret = 200
  423. br.Success = true
  424. br.Msg = "获取成功"
  425. br.Data = resp
  426. }
  427. // SysRoleMenuAuthList
  428. // @Title 角色设置权限-菜单列表
  429. // @Description 角色设置权限-菜单列表
  430. // @Param RoleId query int true "角色Id"
  431. // @Success 200 {object} system.SysRoleListResp
  432. // @router /role/menu/auth_list [get]
  433. func (this *SysRoleController) SysRoleMenuAuthList() {
  434. br := new(models.BaseResponse).Init()
  435. defer func() {
  436. if br.ErrMsg == "" {
  437. br.IsSendEmail = false
  438. }
  439. this.Data["json"] = br
  440. this.ServeJSON()
  441. }()
  442. sysUser := this.SysUser
  443. if sysUser == nil {
  444. br.Msg = "请登录"
  445. br.ErrMsg = "请登录,SysUser Is Empty"
  446. return
  447. }
  448. resp := new(system.SysMenuListResp)
  449. resp.ChoiceList = make([]int, 0)
  450. resp.HalfChoiceList = make([]int, 0)
  451. resp.List = make([]*system.SysMenuItem, 0)
  452. // 角色勾选的权限
  453. roleId, _ := this.GetInt("RoleId", 0)
  454. if roleId > 0 {
  455. relates, e := system.GetSysRoleMenuByRoleId(roleId)
  456. if e != nil {
  457. br.Msg = "获取失败"
  458. br.ErrMsg = "获取角色关联菜单失败, Err: " + e.Error()
  459. return
  460. }
  461. for _, r := range relates {
  462. if r.Type == 1 {
  463. resp.HalfChoiceList = append(resp.HalfChoiceList, r.MenuId)
  464. continue
  465. }
  466. resp.ChoiceList = append(resp.ChoiceList, r.MenuId)
  467. }
  468. }
  469. order := `sort ASC, create_time DESC, menu_id DESC`
  470. list, e := system.GetSysMenuItemsByCondition(` AND hidden = 0`, make([]interface{}, 0), []string{}, order)
  471. if e != nil {
  472. br.Msg = "获取失败"
  473. br.ErrMsg = "获取菜单列表失败, Err: " + e.Error()
  474. return
  475. }
  476. items := make([]*system.SysMenuItem, 0)
  477. for _, v := range list {
  478. t := &system.SysMenuItem{
  479. MenuId: v.MenuId,
  480. ParentId: v.ParentId,
  481. Name: v.Name,
  482. Sort: v.Sort,
  483. Path: v.Path,
  484. IconPath: v.IconPath,
  485. Component: v.Component,
  486. Hidden: v.Hidden,
  487. MenuType: v.MenuType,
  488. ButtonCode: v.ButtonCode,
  489. Children: make([]*system.SysMenuItem, 0),
  490. }
  491. items = append(items, t)
  492. }
  493. // 递归返回树形结构
  494. items = services.GetMenuTreeRecursive(items, 0)
  495. resp.List = items
  496. br.Data = resp
  497. br.Ret = 200
  498. br.Success = true
  499. br.Msg = "获取成功"
  500. }
  501. // SysRoleMenuAuthSave
  502. // @Title 角色设置权限-保存
  503. // @Description 角色设置权限-保存
  504. // @Param request body RoleMenusSaveReq true "type json string"
  505. // @Success 200 {object} system.SysRoleListResp
  506. // @router /role/menu/auth_save [post]
  507. func (this *SysRoleController) SysRoleMenuAuthSave() {
  508. br := new(models.BaseResponse).Init()
  509. defer func() {
  510. if br.ErrMsg == "" {
  511. br.IsSendEmail = false
  512. }
  513. this.Data["json"] = br
  514. this.ServeJSON()
  515. }()
  516. sysUser := this.SysUser
  517. if sysUser == nil {
  518. br.Msg = "请登录"
  519. br.ErrMsg = "请登录,SysUser Is Empty"
  520. br.Ret = 408
  521. return
  522. }
  523. type RoleMenusSaveReq struct {
  524. RoleId int `description:"角色ID"`
  525. MenuIds []int `description:"菜单IDs"`
  526. HalfMenuIds []int `description:"半选菜单IDs-仅供前端回显用的"`
  527. }
  528. var req RoleMenusSaveReq
  529. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  530. if err != nil {
  531. br.Msg = "参数解析异常!"
  532. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  533. return
  534. }
  535. if req.RoleId <= 0 {
  536. br.Msg = "参数有误"
  537. return
  538. }
  539. if len(req.MenuIds) == 0 {
  540. br.Msg = "请选择菜单"
  541. return
  542. }
  543. items := make([]*system.SysRoleMenu, 0)
  544. for _, v := range req.MenuIds {
  545. t := new(system.SysRoleMenu)
  546. t.MenuId = v
  547. t.RoleId = req.RoleId
  548. items = append(items, t)
  549. }
  550. for _, v := range req.HalfMenuIds {
  551. t := new(system.SysRoleMenu)
  552. t.MenuId = v
  553. t.Type = 1
  554. t.RoleId = req.RoleId
  555. items = append(items, t)
  556. }
  557. if e := system.CreateMultiSysRoleMenu(req.RoleId, items); e != nil {
  558. br.Msg = "保存失败"
  559. br.ErrMsg = "保存角色菜单权限失败, Err: " + e.Error()
  560. return
  561. }
  562. br.Ret = 200
  563. br.Success = true
  564. br.Msg = "设置成功"
  565. }
  566. // ButtonList
  567. // @Title 角色-按钮权限列表
  568. // @Description 角色-按钮权限列表
  569. // @Param RoleId query int true "角色Id"
  570. // @Success 200 {object} system.SysRoleListResp
  571. // @router /role/menu/buttons [get]
  572. func (this *SysRoleController) ButtonList() {
  573. br := new(models.BaseResponse).Init()
  574. defer func() {
  575. if br.ErrMsg == "" {
  576. br.IsSendEmail = false
  577. }
  578. this.Data["json"] = br
  579. this.ServeJSON()
  580. }()
  581. sysUser := this.SysUser
  582. if sysUser == nil {
  583. br.Msg = "请登录"
  584. br.ErrMsg = "请登录,SysUser Is Empty"
  585. br.Ret = 408
  586. return
  587. }
  588. roleId := sysUser.RoleId
  589. list, e := system.GetMenuButtonsByRoleId(roleId)
  590. if e != nil {
  591. br.Msg = "获取失败"
  592. br.ErrMsg = "获取角色按钮权限失败, Err: " + e.Error()
  593. return
  594. }
  595. buttonList := make([]*system.SysMenuButtonResp, 0)
  596. for _, v := range list {
  597. tmp := new(system.SysMenuButtonResp)
  598. tmp.MenuId = v.MenuId
  599. tmp.ParentId = v.ParentId
  600. tmp.MenuType = v.MenuType
  601. tmp.Name = v.Name
  602. tmp.ButtonCode = v.ButtonCode
  603. buttonList = append(buttonList, tmp)
  604. }
  605. br.Data = buttonList
  606. br.Ret = 200
  607. br.Success = true
  608. br.Msg = "获取成功"
  609. }
  610. // SystemConfig
  611. // @Title 系统配置列表
  612. // @Description 系统配置列表
  613. // @Success 200 {object} []system.BusinessConf
  614. // @router /config [get]
  615. func (this *SysRoleController) SystemConfig() {
  616. br := new(models.BaseResponse).Init()
  617. defer func() {
  618. if br.ErrMsg == "" {
  619. br.IsSendEmail = false
  620. }
  621. this.Data["json"] = br
  622. this.ServeJSON()
  623. }()
  624. sysUser := this.SysUser
  625. if sysUser == nil {
  626. br.Msg = "请登录"
  627. br.ErrMsg = "请登录,SysUser Is Empty"
  628. br.Ret = 408
  629. return
  630. }
  631. list := make([]system.BusinessConf, 0)
  632. // 获取基础配置, 若未配置则直接返回
  633. conf, e := models.GetBusinessConf()
  634. if e != nil {
  635. br.Msg = "获取失败"
  636. br.ErrMsg = "获取基础配置失败, Err: " + e.Error()
  637. return
  638. }
  639. list = append(list, system.BusinessConf{
  640. ConfKey: "ReportViewUrl",
  641. ConfVal: conf["ReportViewUrl"],
  642. }, system.BusinessConf{
  643. ConfKey: "ChartViewUrl",
  644. ConfVal: conf["ChartViewUrl"],
  645. }, system.BusinessConf{
  646. ConfKey: "LoginUrl",
  647. ConfVal: conf["LoginUrl"],
  648. })
  649. osc := system.BusinessConf{
  650. ConfKey: "ObjectStorageClient",
  651. ConfVal: utils.ObjectStorageClient,
  652. }
  653. if osc.ConfVal == "" {
  654. osc.ConfVal = "oss"
  655. }
  656. // ppt上传走后端配置
  657. pptUpload := system.BusinessConf{
  658. ConfKey: "PptUpdateApi",
  659. ConfVal: utils.PptUpdateApi,
  660. }
  661. list = append(list, osc, pptUpload)
  662. // 获取审批流设置
  663. //confKey := "approval_flow"
  664. //confTmp, e := company.GetConfigDetailByCode(confKey)
  665. //if e != nil {
  666. // br.Msg = "获取审批流配置失败"
  667. // br.ErrMsg = "获取审批流配置失败, Err: " + e.Error()
  668. // return
  669. //}
  670. //list = append(list, system.BusinessConf{
  671. // ConfKey: "ApprovalFlow",
  672. // ConfVal: confTmp.ConfigValue,
  673. //})
  674. br.Data = list
  675. br.Ret = 200
  676. br.Success = true
  677. br.Msg = "获取成功"
  678. }