Browse Source
Merge pull request #594 from flipped-aurora/gva_gormv2_dev
Merge pull request #594 from flipped-aurora/gva_gormv2_dev
增加多角色功能和角色切换功能 调整前端获取用户信息方式main
奇淼(piexlmax
3 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
20 changed files with 323 additions and 68 deletions
-
62server/api/v1/system/sys_user.go
-
11server/model/system/request/sys_casbin.go
-
10server/model/system/request/sys_user.go
-
1server/model/system/sys_user.go
-
10server/model/system/sys_user_authority.go
-
2server/router/system/sys_user.go
-
1server/service/system/sys_authority.go
-
4server/service/system/sys_initdb.go
-
50server/service/system/sys_user.go
-
16server/source/api.go
-
4server/source/casbin.go
-
34server/source/user_authority.go.go
-
18server/utils/clamis.go
-
2server/utils/verify.go
-
30web/src/api/user.js
-
1web/src/permission.js
-
9web/src/store/module/user.js
-
21web/src/view/layout/index.vue
-
1web/src/view/superAdmin/authority/authority.vue
-
52web/src/view/superAdmin/user/user.vue
@ -0,0 +1,10 @@ |
|||
package system |
|||
|
|||
type SysUseAuthority struct { |
|||
SysUserId uint `gorm:"column:sys_user_id"` |
|||
SysAuthorityAuthorityId string `gorm:"column:sys_authority_authority_id"` |
|||
} |
|||
|
|||
func (s *SysUseAuthority) TableName() string { |
|||
return "sys_user_authority" |
|||
} |
@ -0,0 +1,34 @@ |
|||
package source |
|||
|
|||
import ( |
|||
"gin-vue-admin/global" |
|||
"gin-vue-admin/model/system" |
|||
"github.com/gookit/color" |
|||
"gorm.io/gorm" |
|||
) |
|||
|
|||
var UserAuthority = new(userAuthority) |
|||
|
|||
type userAuthority struct{} |
|||
|
|||
var userAuthorityModel = []system.SysUseAuthority{ |
|||
{1, "888"}, |
|||
{1, "8881"}, |
|||
{1, "9528"}, |
|||
{2, "888"}, |
|||
} |
|||
|
|||
//@description: user_authority 数据初始化
|
|||
func (a *userAuthority) Init() error { |
|||
return global.GVA_DB.Model(&system.SysUseAuthority{}).Transaction(func(tx *gorm.DB) error { |
|||
if tx.Where("sys_user_id IN (1, 2)").Find(&[]AuthorityMenus{}).RowsAffected == 4 { |
|||
color.Danger.Println("\n[Mysql] --> sys_user_authority 表的初始数据已存在!") |
|||
return nil |
|||
} |
|||
if err := tx.Create(&userAuthorityModel).Error; err != nil { // 遇到错误时回滚事务
|
|||
return err |
|||
} |
|||
color.Info.Println("\n[Mysql] --> sys_user_authority 表初始数据成功!") |
|||
return nil |
|||
}) |
|||
} |
Write
Preview
Loading…
Cancel
Save
Reference in new issue