Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
B
bwallet
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
JIRA
JIRA
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Go
bwallet
Commits
f76d3676
Commit
f76d3676
authored
Apr 20, 2021
by
shajiaiming
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix
parent
2d784dc8
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
71 additions
and
9 deletions
+71
-9
admin_role.go
routers/api/backend/admin_role.go
+1
-1
role.go
routers/api/backend/role.go
+6
-6
admin_role.go
service/casbin_service/admin_role.go
+1
-1
casbin_rule.go
service/casbin_service/casbin_rule.go
+62
-0
role.go
service/casbin_service/role.go
+1
-1
No files found.
routers/api/backend/admin_role.go
View file @
f76d3676
...
@@ -24,7 +24,7 @@ func AddAdminRole(c *gin.Context) {
...
@@ -24,7 +24,7 @@ func AddAdminRole(c *gin.Context) {
}
}
}
}
roleService
:=
role
_service
.
AdminRole
{
roleService
:=
casbin
_service
.
AdminRole
{
Uid
:
role
.
Uid
,
Uid
:
role
.
Uid
,
RoleId
:
role
.
RoleId
,
RoleId
:
role
.
RoleId
,
}
}
...
...
routers/api/backend/role.go
View file @
f76d3676
...
@@ -28,14 +28,14 @@ func GetRoles(c *gin.Context) {
...
@@ -28,14 +28,14 @@ func GetRoles(c *gin.Context) {
group
:=
user
.
UserInfo
.
Group
group
:=
user
.
UserInfo
.
Group
platform_id
:=
user
.
UserInfo
.
PlatformId
platform_id
:=
user
.
UserInfo
.
PlatformId
roleService
:=
role
_service
.
Role
{}
roleService
:=
casbin
_service
.
Role
{}
if
(
"administrator"
==
group
)
{
if
(
"administrator"
==
group
)
{
if
arg
:=
c
.
Query
(
"platform_id"
);
arg
!=
""
{
if
arg
:=
c
.
Query
(
"platform_id"
);
arg
!=
""
{
platform_id
=
com
.
StrTo
(
c
.
Query
(
"platform_id"
))
.
MustInt
()
platform_id
=
com
.
StrTo
(
c
.
Query
(
"platform_id"
))
.
MustInt
()
}
}
}
}
roleService
=
role
_service
.
Role
{
roleService
=
casbin
_service
.
Role
{
RoleName
:
role_name
,
RoleName
:
role_name
,
Description
:
description
,
Description
:
description
,
PlatformId
:
int64
(
platform_id
),
PlatformId
:
int64
(
platform_id
),
...
@@ -65,7 +65,7 @@ func AddRole(c *gin.Context) {
...
@@ -65,7 +65,7 @@ func AddRole(c *gin.Context) {
user
,
_
:=
util
.
ParseToken
(
token
)
user
,
_
:=
util
.
ParseToken
(
token
)
platform_id
:=
int64
(
user
.
UserInfo
.
PlatformId
)
platform_id
:=
int64
(
user
.
UserInfo
.
PlatformId
)
roleService
:=
role
_service
.
Role
{
roleService
:=
casbin
_service
.
Role
{
RoleName
:
role
.
RoleName
,
RoleName
:
role
.
RoleName
,
Description
:
role
.
Description
,
Description
:
role
.
Description
,
PlatformId
:
platform_id
,
PlatformId
:
platform_id
,
...
@@ -90,7 +90,7 @@ func EditRole(c *gin.Context) {
...
@@ -90,7 +90,7 @@ func EditRole(c *gin.Context) {
}
}
}
}
roleService
:=
role
_service
.
Role
{
Id
:
role_tmp
.
Id
}
roleService
:=
casbin
_service
.
Role
{
Id
:
role_tmp
.
Id
}
role
,
err
:=
roleService
.
GetRole
()
role
,
err
:=
roleService
.
GetRole
()
if
err
!=
nil
{
if
err
!=
nil
{
handler
.
SendResponse
(
c
,
errno
.
ErrRoleNotFound
,
nil
)
handler
.
SendResponse
(
c
,
errno
.
ErrRoleNotFound
,
nil
)
...
@@ -103,7 +103,7 @@ func EditRole(c *gin.Context) {
...
@@ -103,7 +103,7 @@ func EditRole(c *gin.Context) {
handler
.
SendResponse
(
c
,
errno
.
ErrUpdateRole
,
nil
)
handler
.
SendResponse
(
c
,
errno
.
ErrUpdateRole
,
nil
)
return
return
}
}
roleService
=
role
_service
.
Role
{
roleService
=
casbin
_service
.
Role
{
Id
:
role_tmp
.
Id
,
Id
:
role_tmp
.
Id
,
RoleName
:
role_tmp
.
RoleName
,
RoleName
:
role_tmp
.
RoleName
,
Description
:
role_tmp
.
Description
,
Description
:
role_tmp
.
Description
,
...
@@ -124,7 +124,7 @@ func DeleteRole(c *gin.Context) {
...
@@ -124,7 +124,7 @@ func DeleteRole(c *gin.Context) {
return
return
}
}
roleService
:=
role
_service
.
Role
{
Id
:
id
}
roleService
:=
casbin
_service
.
Role
{
Id
:
id
}
role
,
err
:=
roleService
.
GetRole
()
role
,
err
:=
roleService
.
GetRole
()
if
err
!=
nil
{
if
err
!=
nil
{
...
...
service/casbin_service/admin_role.go
View file @
f76d3676
package
role
_service
package
casbin
_service
import
(
import
(
"bwallet/models"
"bwallet/models"
...
...
service/casbin_service/casbin_rule.go
0 → 100644
View file @
f76d3676
package
casbin_service
import
(
"bwallet/models"
)
type
CasbinRole
struct
{
Id
int
Ptype
string
V0
string
V1
string
V2
string
V3
string
V4
string
V5
string
}
func
(
r
*
CasbinRole
)
GetAllRolesRelation
()
([]
*
models
.
Role
,
error
)
{
roles
,
err
:=
models
.
GetRoles
(
r
.
getMaps
())
if
err
!=
nil
{
return
nil
,
err
}
return
roles
,
nil
}
func
(
r
*
CasbinRole
)
AddRoleRelation
()
error
{
role
:=
map
[
string
]
interface
{}{
"ptype"
:
r
.
Ptype
,
"v0"
:
r
.
V0
,
"v1"
:
r
.
V1
,
"v2"
:
r
.
V2
,
}
if
err
:=
models
.
AddRuleRelation
(
role
);
err
!=
nil
{
return
err
}
return
nil
}
func
(
r
*
CasbinRole
)
getMaps
()
(
map
[
string
]
interface
{})
{
maps
:=
make
(
map
[
string
]
interface
{})
if
r
.
Id
!=
0
{
maps
[
"id"
]
=
r
.
Id
}
if
r
.
Ptype
!=
""
{
maps
[
"ptype"
]
=
r
.
Ptype
}
if
r
.
V0
!=
""
{
maps
[
"v0"
]
=
r
.
V0
}
if
r
.
V1
!=
""
{
maps
[
"v1"
]
=
r
.
V1
}
return
maps
}
service/casbin_service/role.go
View file @
f76d3676
package
role
_service
package
casbin
_service
import
(
import
(
"bwallet/models"
"bwallet/models"
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment