english_auth.go 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661
  1. package english_report
  2. import (
  3. "encoding/json"
  4. "eta/eta_api/controllers"
  5. "eta/eta_api/models"
  6. "eta/eta_api/models/company"
  7. "eta/eta_api/models/system"
  8. "eta/eta_api/models/system/request"
  9. "eta/eta_api/models/system/response"
  10. "eta/eta_api/utils"
  11. "fmt"
  12. "github.com/rdlucklib/rdluck_tools/paging"
  13. "strconv"
  14. "strings"
  15. "time"
  16. )
  17. // EnglishAuthController 英文销售权限
  18. type EnglishAuthController struct {
  19. controllers.BaseAuthController
  20. }
  21. // List
  22. // @Title 权限列表
  23. // @Description 权限列表
  24. // @Success 200 {object} response.RoleAdminItemResp
  25. // @router /auth/list [get]
  26. func (this *EnglishAuthController) List() {
  27. br := new(models.BaseResponse).Init()
  28. defer func() {
  29. if br.ErrMsg == "" {
  30. br.IsSendEmail = false
  31. }
  32. this.Data["json"] = br
  33. this.ServeJSON()
  34. }()
  35. sysUser := this.SysUser
  36. if sysUser == nil {
  37. br.Msg = "请登录"
  38. br.ErrMsg = "请登录,SysUser is Empty"
  39. br.Ret = 408
  40. return
  41. }
  42. pageSize, _ := this.GetInt("PageSize")
  43. currentIndex, _ := this.GetInt("CurrentIndex")
  44. var startSize int
  45. if pageSize <= 0 {
  46. pageSize = utils.PageSize20
  47. }
  48. if currentIndex <= 0 {
  49. currentIndex = 1
  50. }
  51. startSize = paging.StartIndex(currentIndex, pageSize)
  52. // 获取英文角色配置
  53. confRoles := make([]company.ConfEnAuthRole, 0)
  54. authKey := company.ConfEnAuthRoleKey
  55. confAuth, e := company.GetConfigDetailByCode(authKey)
  56. if e != nil {
  57. br.Msg = "获取失败"
  58. br.ErrMsg = "获取英文权限角色配置失败, Err: " + e.Error()
  59. return
  60. }
  61. if confAuth.ConfigValue == "" {
  62. br.Msg = "获取失败"
  63. br.ErrMsg = "英文权限角色配置为空"
  64. return
  65. }
  66. if e := json.Unmarshal([]byte(confAuth.ConfigValue), &confRoles); e != nil {
  67. br.Msg = "获取失败"
  68. br.ErrMsg = "英文权限角色配置有误"
  69. return
  70. }
  71. roleCodes := make([]string, 0)
  72. for _, v := range confRoles {
  73. roleCodes = append(roleCodes, v.RoleCode)
  74. }
  75. // 获取权限列表
  76. var cond string
  77. var pars []interface{}
  78. cond += ` AND r.role_type_code IN (` + utils.GetOrmInReplace(len(roleCodes)) + `)`
  79. pars = append(pars, roleCodes)
  80. total, adminList, err := system.GetEnglishAuthRoleAdminList(cond, pars, startSize, pageSize)
  81. if err != nil {
  82. br.Msg = "获取管理账号列表失败!"
  83. br.ErrMsg = "获取管理账号列表失败,Err:" + err.Error()
  84. return
  85. }
  86. // 查询分组信息
  87. departmentGroupNameMap := make(map[int]string)
  88. departmentNameMap := make(map[int]string)
  89. groupList, err := system.GetFullGroup()
  90. if err != nil {
  91. br.Msg = "查询分组信息失败!"
  92. br.ErrMsg = "查询分组信息失败,Err:" + err.Error()
  93. return
  94. }
  95. departmentList, err := system.GetDepartmentList()
  96. if err != nil {
  97. br.Msg = "查询部门信息失败!"
  98. br.ErrMsg = "查询部门信息失败,Err:" + err.Error()
  99. return
  100. }
  101. for _, d := range departmentList {
  102. departmentNameMap[d.DepartmentId] = d.DepartmentName
  103. }
  104. for _, g := range groupList {
  105. if g.ParentGroupName != "" {
  106. departmentGroupNameMap[g.GroupId] = g.DepartmentName + "/" + g.ParentGroupName + "/" + g.GroupName
  107. } else {
  108. departmentGroupNameMap[g.GroupId] = g.DepartmentName + "/" + g.GroupName
  109. }
  110. }
  111. // 查询角色信息
  112. roles, err := system.GetSysRoleAll(false)
  113. if err != nil {
  114. br.Msg = "查询角色信息失败!"
  115. br.ErrMsg = "查询角色信息失败,Err:" + err.Error()
  116. return
  117. }
  118. rolesNameMap := make(map[int]string)
  119. for _, v := range roles {
  120. rolesNameMap[v.RoleId] = v.RoleName
  121. }
  122. var list []*response.RoleAdminItemResp
  123. for _, v := range adminList {
  124. item := new(response.RoleAdminItemResp)
  125. item.SysRoleAdminId = v.SysRoleAdminId
  126. item.AdminId = v.AdminId
  127. item.Mobile = v.Mobile
  128. item.RealName = v.RealName
  129. item.Enabled = v.Enabled
  130. if v.GroupId > 0 {
  131. if departmentGroup, ok := departmentGroupNameMap[v.GroupId]; ok {
  132. item.DepartmentGroup = departmentGroup
  133. }
  134. } else {
  135. if departmentName, ok := departmentNameMap[v.DepartmentId]; ok {
  136. item.DepartmentGroup = departmentName
  137. }
  138. }
  139. // 整理角色名称
  140. item.RoleId = v.RoleId
  141. if rolesName, ok := rolesNameMap[v.RoleId]; ok {
  142. item.RoleName = rolesName
  143. }
  144. // 整理标签
  145. if v.RoleTypeCode == utils.ROLE_TYPE_CODE_ADMIN {
  146. item.LabelVal = 1
  147. } else if v.RoleTypeCode == utils.ROLE_TYPE_CODE_FICC_ADMIN ||
  148. v.RoleTypeCode == utils.ROLE_TYPE_CODE_RAI_ADMIN {
  149. item.LabelVal = 2
  150. } else {
  151. if v.Authority == 1 {
  152. item.LabelVal = 3
  153. } else if v.Authority == 2 && v.RoleTypeCode == utils.ROLE_TYPE_CODE_RAI_GROUP {
  154. item.LabelVal = 4
  155. } else if v.Authority == 2 && v.RoleTypeCode == utils.ROLE_TYPE_CODE_FICC_GROUP {
  156. item.LabelVal = 5
  157. } else if v.Authority == 4 {
  158. item.LabelVal = 4
  159. }
  160. }
  161. list = append(list, item)
  162. }
  163. page := paging.GetPaging(currentIndex, pageSize, total)
  164. resp := response.RoleAdminListResp{
  165. List: list,
  166. Paging: page,
  167. }
  168. br.Ret = 200
  169. br.Success = true
  170. br.Msg = "获取成功"
  171. br.Data = resp
  172. }
  173. // BatchAdd
  174. // @Title 批量新增权限
  175. // @Description 批量新增权限
  176. // @Param request body request.AddEnglishAuthRoleAdminReq true "type json string"
  177. // @Success Ret=200 操作成功
  178. // @router /auth/batch_add [post]
  179. func (this *EnglishAuthController) BatchAdd() {
  180. br := new(models.BaseResponse).Init()
  181. defer func() {
  182. if br.ErrMsg == "" {
  183. br.IsSendEmail = false
  184. }
  185. this.Data["json"] = br
  186. this.ServeJSON()
  187. }()
  188. sysUser := this.SysUser
  189. if sysUser == nil {
  190. br.Msg = "请登录"
  191. br.ErrMsg = "请登录,SysUser Is Empty"
  192. br.Ret = 408
  193. return
  194. }
  195. var req request.AddEnglishAuthRoleAdminReq
  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.AdminIds == "" {
  203. br.Msg = "请选择用户"
  204. return
  205. }
  206. // 校验参数
  207. adminIdArr := strings.Split(req.AdminIds, ",")
  208. if len(adminIdArr) == 0 {
  209. br.Msg = "请选择用户"
  210. return
  211. }
  212. adminIds := make([]int, 0)
  213. for i := range adminIdArr {
  214. v, e := strconv.Atoi(adminIdArr[i])
  215. if e != nil {
  216. br.Msg = "请选择用户"
  217. br.ErrMsg = "参数解析异常, Err:" + e.Error()
  218. return
  219. }
  220. adminIds = append(adminIds, v)
  221. }
  222. if len(adminIds) == 0 {
  223. br.Msg = "请选择有效用户"
  224. return
  225. }
  226. // 获取英文角色配置
  227. confRoles := make([]company.ConfEnAuthRole, 0)
  228. authKey := company.ConfEnAuthRoleKey
  229. confAuth, e := company.GetConfigDetailByCode(authKey)
  230. if e != nil {
  231. br.Msg = "获取失败"
  232. br.ErrMsg = "获取英文权限角色配置失败, Err: " + e.Error()
  233. return
  234. }
  235. if confAuth.ConfigValue == "" {
  236. br.Msg = "获取失败"
  237. br.ErrMsg = "英文权限角色配置为空"
  238. return
  239. }
  240. if e := json.Unmarshal([]byte(confAuth.ConfigValue), &confRoles); e != nil {
  241. br.Msg = "获取失败"
  242. br.ErrMsg = "英文权限角色配置有误"
  243. return
  244. }
  245. roleCodes := make([]string, 0)
  246. for _, v := range confRoles {
  247. roleCodes = append(roleCodes, v.RoleCode)
  248. }
  249. // 获取英文权限角色
  250. roleItems, e := system.GetEnglishAuthRoleItems(roleCodes)
  251. if e != nil {
  252. br.Msg = "新增失败"
  253. br.ErrMsg = "获取英文权限角色IDs失败, Err: " + e.Error()
  254. return
  255. }
  256. if len(roleItems) == 0 || len(roleItems) != len(roleCodes) {
  257. br.Msg = "英文权限角色信息有误"
  258. return
  259. }
  260. // 查询已绑定的管理员账号
  261. var noBindIds []int
  262. bindMap := make(map[int]bool)
  263. hasBindList, e := system.CheckEnglishAuthRoleAdminByAdminIds(adminIds, roleCodes)
  264. if e != nil {
  265. br.Msg = "新增失败"
  266. br.ErrMsg = "查询已绑定英文权限的账号失败, Err:" + e.Error()
  267. return
  268. }
  269. for i := range hasBindList {
  270. bindMap[hasBindList[i].AdminId] = true
  271. }
  272. for i := range adminIds {
  273. if !bindMap[adminIds[i]] {
  274. noBindIds = append(noBindIds, adminIds[i])
  275. }
  276. }
  277. if len(noBindIds) == 0 {
  278. br.Msg = "账号已绑定,无需重复绑定"
  279. br.ErrMsg = "账号已绑定,无需重复绑定"
  280. return
  281. }
  282. // 获取未绑定的用户列表
  283. unboundAdmins := make([]*system.Admin, 0)
  284. {
  285. cond := fmt.Sprintf(` AND admin_id IN (%s)`, utils.GetOrmInReplace(len(noBindIds)))
  286. pars := make([]interface{}, 0)
  287. pars = append(pars, noBindIds)
  288. admins, e := system.GetSysAdminList(cond, pars, []string{}, "")
  289. if e != nil {
  290. br.Msg = "操作失败"
  291. br.ErrMsg = "获取未绑定的用户列表失败, Err: " + e.Error()
  292. return
  293. }
  294. unboundAdmins = admins
  295. }
  296. // 新增绑定关系
  297. var syncRoles []system.SyncAdminEnRole
  298. nowTime := time.Now().Local()
  299. newBounds := make([]*system.SysRoleAdmin, 0)
  300. for _, a := range unboundAdmins {
  301. var d system.SyncAdminEnRole
  302. d.AdminName = a.AdminName
  303. for r := range roleItems {
  304. v := &system.SysRoleAdmin{
  305. AdminId: a.AdminId,
  306. RoleId: roleItems[r].RoleId,
  307. CreateTime: nowTime,
  308. }
  309. newBounds = append(newBounds, v)
  310. d.RoleCodes = append(d.RoleCodes, roleItems[r].RoleTypeCode)
  311. }
  312. syncRoles = append(syncRoles, d)
  313. }
  314. if e = system.AddRoleAdminBatch(newBounds); e != nil {
  315. br.Msg = "新增失败"
  316. br.ErrMsg = "新增英文权限绑定关系失败, Err:" + e.Error()
  317. return
  318. }
  319. // 写入同步缓存
  320. for _, v := range syncRoles {
  321. _ = utils.Rc.LPush(utils.CACHE_SYNC_USER_EN_ROLE, v)
  322. }
  323. br.Ret = 200
  324. br.Success = true
  325. br.Msg = "操作成功"
  326. }
  327. // Detail
  328. // @Title 权限详情
  329. // @Description 权限详情
  330. // @Param AdminId query string int "管理员ID"
  331. // @Success 200 {object} response.EnglishAuthRoleDetailResp
  332. // @router /auth/detail [get]
  333. func (this *EnglishAuthController) Detail() {
  334. br := new(models.BaseResponse).Init()
  335. defer func() {
  336. if br.ErrMsg == "" {
  337. br.IsSendEmail = false
  338. }
  339. this.Data["json"] = br
  340. this.ServeJSON()
  341. }()
  342. sysUser := this.SysUser
  343. if sysUser == nil {
  344. br.Msg = "请登录"
  345. br.ErrMsg = "请登录,SysUser is Empty"
  346. br.Ret = 408
  347. return
  348. }
  349. adminId, _ := this.GetInt("AdminId", 0)
  350. if adminId <= 0 {
  351. br.Msg = "参数有误"
  352. return
  353. }
  354. // 获取英文角色配置
  355. confRoles := make([]company.ConfEnAuthRole, 0)
  356. authKey := company.ConfEnAuthRoleKey
  357. confAuth, e := company.GetConfigDetailByCode(authKey)
  358. if e != nil {
  359. br.Msg = "获取失败"
  360. br.ErrMsg = "获取英文权限角色配置失败, Err: " + e.Error()
  361. return
  362. }
  363. if confAuth.ConfigValue == "" {
  364. br.Msg = "获取失败"
  365. br.ErrMsg = "英文权限角色配置为空"
  366. return
  367. }
  368. if e := json.Unmarshal([]byte(confAuth.ConfigValue), &confRoles); e != nil {
  369. br.Msg = "获取失败"
  370. br.ErrMsg = "英文权限角色配置有误"
  371. return
  372. }
  373. roleCodes := make([]string, 0)
  374. for _, v := range confRoles {
  375. roleCodes = append(roleCodes, v.RoleCode)
  376. }
  377. resp := make([]*response.EnglishAuthRoleDetailResp, 0)
  378. authList, e := system.GetAdminEnglishAuthRoleDetail(adminId, roleCodes)
  379. if e != nil {
  380. br.Msg = "获取失败"
  381. br.ErrMsg = "获取管理员英文权限详情失败, Err:" + e.Error()
  382. return
  383. }
  384. authMap := make(map[string]bool, 0)
  385. for i := range authList {
  386. authMap[authList[i].RoleTypeCode] = true
  387. }
  388. for _, v := range confRoles {
  389. resp = append(resp, &response.EnglishAuthRoleDetailResp{
  390. AdminId: adminId,
  391. AuthName: v.RoleName,
  392. RoleTypeCode: v.RoleCode,
  393. AuthOk: authMap[v.RoleCode],
  394. })
  395. }
  396. br.Ret = 200
  397. br.Success = true
  398. br.Msg = "获取成功"
  399. br.Data = resp
  400. }
  401. // Edit
  402. // @Title 编辑权限
  403. // @Description 编辑权限
  404. // @Param request body request.EditEnglishAuthRoleAdminReq true "type json string"
  405. // @Success Ret=200 操作成功
  406. // @router /auth/edit [post]
  407. func (this *EnglishAuthController) Edit() {
  408. br := new(models.BaseResponse).Init()
  409. defer func() {
  410. if br.ErrMsg == "" {
  411. br.IsSendEmail = false
  412. }
  413. this.Data["json"] = br
  414. this.ServeJSON()
  415. }()
  416. sysUser := this.SysUser
  417. if sysUser == nil {
  418. br.Msg = "请登录"
  419. br.ErrMsg = "请登录,SysUser Is Empty"
  420. br.Ret = 408
  421. return
  422. }
  423. var req request.EditEnglishAuthRoleAdminReq
  424. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  425. if err != nil {
  426. br.Msg = "参数解析异常!"
  427. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  428. return
  429. }
  430. if req.AdminId <= 0 {
  431. br.Msg = "管理员ID有误"
  432. return
  433. }
  434. if req.RoleTypeCodes == "" {
  435. br.Msg = "请选择权限"
  436. return
  437. }
  438. roleArr := strings.Split(req.RoleTypeCodes, ",")
  439. if len(roleArr) == 0 {
  440. br.Msg = "请选择权限"
  441. return
  442. }
  443. // 若用户不存在, 则忽略
  444. admin, e := system.GetSysAdminById(req.AdminId)
  445. if e != nil {
  446. br.Ret = 200
  447. br.Success = true
  448. br.Msg = "操作成功"
  449. return
  450. }
  451. // 获取英文角色配置
  452. confRoles := make([]company.ConfEnAuthRole, 0)
  453. authKey := company.ConfEnAuthRoleKey
  454. confAuth, e := company.GetConfigDetailByCode(authKey)
  455. if e != nil {
  456. br.Msg = "获取失败"
  457. br.ErrMsg = "获取英文权限角色配置失败, Err: " + e.Error()
  458. return
  459. }
  460. if confAuth.ConfigValue == "" {
  461. br.Msg = "获取失败"
  462. br.ErrMsg = "英文权限角色配置为空"
  463. return
  464. }
  465. if e := json.Unmarshal([]byte(confAuth.ConfigValue), &confRoles); e != nil {
  466. br.Msg = "获取失败"
  467. br.ErrMsg = "英文权限角色配置有误"
  468. return
  469. }
  470. roleCodes := make([]string, 0)
  471. for _, v := range confRoles {
  472. roleCodes = append(roleCodes, v.RoleCode)
  473. }
  474. for i := range roleArr {
  475. if !utils.InArrayByStr(roleCodes, roleArr[i]) {
  476. br.Msg = "权限信息有误"
  477. return
  478. }
  479. }
  480. // 获取英文权限角色IDs
  481. roleIds, e := system.GetEnglishAuthRoleIds(roleCodes)
  482. if e != nil {
  483. br.Msg = "新增失败"
  484. br.ErrMsg = "获取英文权限角色IDs失败, Err: " + e.Error()
  485. return
  486. }
  487. if len(roleIds) == 0 {
  488. br.Msg = "英文权限角色信息有误"
  489. return
  490. }
  491. // 获取编辑的权限角色IDs
  492. editRoles, e := system.GetEnglishAuthRoleItems(roleArr)
  493. if e != nil {
  494. br.Msg = "新增失败"
  495. br.ErrMsg = "获取编辑英文权限角色IDs失败, Err: " + e.Error()
  496. return
  497. }
  498. if len(editRoles) != len(roleArr) {
  499. br.Msg = "权限角色信息有误"
  500. return
  501. }
  502. // 同步缓存
  503. var syncData system.SyncAdminEnRole
  504. syncData.AdminName = admin.AdminName
  505. // 编辑权限
  506. nowTime := time.Now().Local()
  507. newBinds := make([]*system.SysRoleAdmin, 0)
  508. for _, r := range editRoles {
  509. v := &system.SysRoleAdmin{
  510. AdminId: req.AdminId,
  511. RoleId: r.RoleId,
  512. CreateTime: nowTime,
  513. }
  514. newBinds = append(newBinds, v)
  515. syncData.RoleCodes = append(syncData.RoleCodes, r.RoleTypeCode)
  516. }
  517. if e = system.EditEnglishAuthRoleAdmin(req.AdminId, roleIds, newBinds); e != nil {
  518. br.Msg = "编辑失败"
  519. br.ErrMsg = "编辑管理员英文权限绑定关系失败, Err:" + e.Error()
  520. return
  521. }
  522. // 写入同步缓存
  523. _ = utils.Rc.LPush(utils.CACHE_SYNC_USER_EN_ROLE, syncData)
  524. br.Ret = 200
  525. br.Success = true
  526. br.Msg = "操作成功"
  527. }
  528. // Del
  529. // @Title 删除权限
  530. // @Description 删除权限
  531. // @Param request body request.DelEnglishAuthRoleAdminReq true "type json string"
  532. // @Success Ret=200 操作成功
  533. // @router /auth/del [post]
  534. func (this *EnglishAuthController) Del() {
  535. br := new(models.BaseResponse).Init()
  536. defer func() {
  537. if br.ErrMsg == "" {
  538. br.IsSendEmail = false
  539. }
  540. this.Data["json"] = br
  541. this.ServeJSON()
  542. }()
  543. sysUser := this.SysUser
  544. if sysUser == nil {
  545. br.Msg = "请登录"
  546. br.ErrMsg = "请登录,SysUser Is Empty"
  547. br.Ret = 408
  548. return
  549. }
  550. var req request.DelEnglishAuthRoleAdminReq
  551. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  552. if err != nil {
  553. br.Msg = "参数解析异常!"
  554. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  555. return
  556. }
  557. if req.AdminId <= 0 {
  558. br.Msg = "参数有误"
  559. return
  560. }
  561. // 若用户不存在, 则忽略
  562. admin, e := system.GetSysAdminById(req.AdminId)
  563. if e != nil {
  564. br.Ret = 200
  565. br.Success = true
  566. br.Msg = "操作成功"
  567. return
  568. }
  569. // 获取英文角色配置
  570. confRoles := make([]company.ConfEnAuthRole, 0)
  571. authKey := company.ConfEnAuthRoleKey
  572. confAuth, e := company.GetConfigDetailByCode(authKey)
  573. if e != nil {
  574. br.Msg = "获取失败"
  575. br.ErrMsg = "获取英文权限角色配置失败, Err: " + e.Error()
  576. return
  577. }
  578. if confAuth.ConfigValue == "" {
  579. br.Msg = "获取失败"
  580. br.ErrMsg = "英文权限角色配置为空"
  581. return
  582. }
  583. if e := json.Unmarshal([]byte(confAuth.ConfigValue), &confRoles); e != nil {
  584. br.Msg = "获取失败"
  585. br.ErrMsg = "英文权限角色配置有误"
  586. return
  587. }
  588. roleCodes := make([]string, 0)
  589. for _, v := range confRoles {
  590. roleCodes = append(roleCodes, v.RoleCode)
  591. }
  592. // 获取英文权限角色IDs
  593. roleIds, e := system.GetEnglishAuthRoleIds(roleCodes)
  594. if e != nil {
  595. br.Msg = "删除失败"
  596. br.ErrMsg = "获取英文权限角色IDs失败, Err: " + e.Error()
  597. return
  598. }
  599. if len(roleIds) == 0 {
  600. br.Msg = "删除失败"
  601. br.ErrMsg = "解除英文权限角色绑定关系失败, 角色信息有误"
  602. return
  603. }
  604. // 解除绑定关系
  605. if e = system.DeleteRoleAdminByAdminIdAndRoleIds(req.AdminId, roleIds); e != nil {
  606. br.Msg = "删除失败"
  607. br.ErrMsg = "解除英文权限角色绑定关系失败, Err:" + e.Error()
  608. return
  609. }
  610. // 写入同步缓存
  611. var syncData system.SyncAdminEnRole
  612. syncData.AdminName = admin.AdminName
  613. _ = utils.Rc.LPush(utils.CACHE_SYNC_USER_EN_ROLE, syncData)
  614. br.Ret = 200
  615. br.Success = true
  616. br.Msg = "操作成功"
  617. }