12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091 |
- package services
- import (
- "encoding/json"
- "eta/eta_bridge/global"
- "eta/eta_bridge/utils"
- "fmt"
- )
- // ListenSyncRole 同步角色
- func ListenSyncRole() {
- defer func() {
- if err := recover(); err != nil {
- fmt.Println("[ListenSyncRole]", err)
- }
- }()
- for {
- global.Rc.Brpop(utils.CACHE_SYNC_ROLE, func(b []byte) {
- var d SyncRoleData
- _ = json.Unmarshal(b, &d)
- _ = HandleSyncRole(d)
- })
- }
- }
- // ListenSyncAdmin 同步用户
- func ListenSyncAdmin() {
- defer func() {
- if err := recover(); err != nil {
- fmt.Println("[ListenSyncAdmin]", err)
- }
- }()
- for {
- global.Rc.Brpop(utils.CACHE_SYNC_ADMIN, func(b []byte) {
- var d SyncAdminData
- _ = json.Unmarshal(b, &d)
- _ = HandleSyncAdmin(d)
- })
- }
- }
- // ListenSyncDepartment 同步部门
- func ListenSyncDepartment() {
- defer func() {
- if err := recover(); err != nil {
- fmt.Println("[ListenSyncDepartment]", err)
- }
- }()
- for {
- global.Rc.Brpop(utils.CACHE_SYNC_DEPARTMENT, func(b []byte) {
- var d SyncDepartmentData
- _ = json.Unmarshal(b, &d)
- _ = HandleSyncDepartment(d)
- })
- }
- }
- // ListenSyncGroup 同步分组
- func ListenSyncGroup() {
- defer func() {
- if err := recover(); err != nil {
- fmt.Println("[ListenSyncGroup]", err)
- }
- }()
- for {
- global.Rc.Brpop(utils.CACHE_SYNC_GROUP, func(b []byte) {
- var d SyncGroupData
- _ = json.Unmarshal(b, &d)
- _ = HandleSyncGroup(d)
- })
- }
- }
- // ListenSyncUserEnRole 同步用户英文权限角色
- func ListenSyncUserEnRole() {
- defer func() {
- if err := recover(); err != nil {
- fmt.Println("[ListenSyncUserEnRole]", err)
- }
- }()
- for {
- global.Rc.Brpop(utils.CACHE_SYNC_USER_EN_ROLE, func(b []byte) {
- var d SyncAdminEnRole
- _ = json.Unmarshal(b, &d)
- fmt.Println("读到了")
- fmt.Println(d.AdminName)
- fmt.Println(d.RoleCodes)
- _ = HandleSyncUserEnRole(d)
- })
- }
- }
|