调整角色ID为uint格式,增加embed打包,更改日志格式。 (#1144)
* feature: 根据 #377 pr进行修改embed, 打包静态文件夹与配置文件 * 修改角色id为uint * 修改日志格式 Co-authored-by: SliverHorn <503551462@qq.com> Co-authored-by: cg81344 <cg831344@126.com>
This commit is contained in:
@@ -133,7 +133,8 @@ func (authorityService *AuthorityService) DeleteAuthority(auth *system.SysAuthor
|
||||
}
|
||||
err = global.GVA_DB.Delete(&[]system.SysUseAuthority{}, "sys_authority_authority_id = ?", auth.AuthorityId).Error
|
||||
err = global.GVA_DB.Delete(&[]system.SysAuthorityBtn{}, "authority_id = ?", auth.AuthorityId).Error
|
||||
CasbinServiceApp.ClearCasbin(0, auth.AuthorityId)
|
||||
authorityId := strconv.Itoa(int(auth.AuthorityId))
|
||||
CasbinServiceApp.ClearCasbin(0, authorityId)
|
||||
return err
|
||||
}
|
||||
|
||||
|
@@ -9,6 +9,7 @@ import (
|
||||
"github.com/flipped-aurora/gin-vue-admin/server/model/system/request"
|
||||
_ "github.com/go-sql-driver/mysql"
|
||||
"go.uber.org/zap"
|
||||
"strconv"
|
||||
"sync"
|
||||
)
|
||||
|
||||
@@ -22,7 +23,8 @@ type CasbinService struct{}
|
||||
|
||||
var CasbinServiceApp = new(CasbinService)
|
||||
|
||||
func (casbinService *CasbinService) UpdateCasbin(authorityId string, casbinInfos []request.CasbinInfo) error {
|
||||
func (casbinService *CasbinService) UpdateCasbin(AuthorityID uint, casbinInfos []request.CasbinInfo) error {
|
||||
authorityId := strconv.Itoa(int(AuthorityID))
|
||||
casbinService.ClearCasbin(0, authorityId)
|
||||
rules := [][]string{}
|
||||
for _, v := range casbinInfos {
|
||||
@@ -56,8 +58,9 @@ func (casbinService *CasbinService) UpdateCasbinApi(oldPath string, newPath stri
|
||||
//@param: authorityId string
|
||||
//@return: pathMaps []request.CasbinInfo
|
||||
|
||||
func (casbinService *CasbinService) GetPolicyPathByAuthorityId(authorityId string) (pathMaps []request.CasbinInfo) {
|
||||
func (casbinService *CasbinService) GetPolicyPathByAuthorityId(AuthorityID uint) (pathMaps []request.CasbinInfo) {
|
||||
e := casbinService.Casbin()
|
||||
authorityId := strconv.Itoa(int(AuthorityID))
|
||||
list := e.GetFilteredPolicy(0, authorityId)
|
||||
for _, v := range list {
|
||||
pathMaps = append(pathMaps, request.CasbinInfo{
|
||||
|
@@ -20,7 +20,7 @@ type MenuService struct{}
|
||||
|
||||
var MenuServiceApp = new(MenuService)
|
||||
|
||||
func (menuService *MenuService) getMenuTreeMap(authorityId string) (treeMap map[string][]system.SysMenu, err error) {
|
||||
func (menuService *MenuService) getMenuTreeMap(authorityId uint) (treeMap map[string][]system.SysMenu, err error) {
|
||||
var allMenus []system.SysMenu
|
||||
var baseMenu []system.SysBaseMenu
|
||||
var btns []system.SysAuthorityBtn
|
||||
@@ -56,10 +56,10 @@ func (menuService *MenuService) getMenuTreeMap(authorityId string) (treeMap map[
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
var btnMap = make(map[uint]map[string]string)
|
||||
var btnMap = make(map[uint]map[string]uint)
|
||||
for _, v := range btns {
|
||||
if btnMap[v.SysMenuID] == nil {
|
||||
btnMap[v.SysMenuID] = make(map[string]string)
|
||||
btnMap[v.SysMenuID] = make(map[string]uint)
|
||||
}
|
||||
btnMap[v.SysMenuID][v.SysBaseMenuBtn.Name] = authorityId
|
||||
}
|
||||
@@ -76,7 +76,7 @@ func (menuService *MenuService) getMenuTreeMap(authorityId string) (treeMap map[
|
||||
//@param: authorityId string
|
||||
//@return: menus []system.SysMenu, err error
|
||||
|
||||
func (menuService *MenuService) GetMenuTree(authorityId string) (menus []system.SysMenu, err error) {
|
||||
func (menuService *MenuService) GetMenuTree(authorityId uint) (menus []system.SysMenu, err error) {
|
||||
menuTree, err := menuService.getMenuTreeMap(authorityId)
|
||||
menus = menuTree["0"]
|
||||
for i := 0; i < len(menus); i++ {
|
||||
@@ -176,7 +176,7 @@ func (menuService *MenuService) GetBaseMenuTree() (menus []system.SysBaseMenu, e
|
||||
//@param: menus []model.SysBaseMenu, authorityId string
|
||||
//@return: err error
|
||||
|
||||
func (menuService *MenuService) AddMenuAuthority(menus []system.SysBaseMenu, authorityId string) (err error) {
|
||||
func (menuService *MenuService) AddMenuAuthority(menus []system.SysBaseMenu, authorityId uint) (err error) {
|
||||
var auth system.SysAuthority
|
||||
auth.AuthorityId = authorityId
|
||||
auth.SysBaseMenus = menus
|
||||
|
@@ -117,7 +117,7 @@ func (userService *UserService) GetUserInfoList(info request.PageInfo) (list int
|
||||
//@param: uuid uuid.UUID, authorityId string
|
||||
//@return: err error
|
||||
|
||||
func (userService *UserService) SetUserAuthority(id uint, uuid uuid.UUID, authorityId string) (err error) {
|
||||
func (userService *UserService) SetUserAuthority(id uint, uuid uuid.UUID, authorityId uint) (err error) {
|
||||
assignErr := global.GVA_DB.Where("sys_user_id = ? AND sys_authority_authority_id = ?", id, authorityId).First(&system.SysUseAuthority{}).Error
|
||||
if errors.Is(assignErr, gorm.ErrRecordNotFound) {
|
||||
return errors.New("该用户无此角色")
|
||||
@@ -132,7 +132,7 @@ func (userService *UserService) SetUserAuthority(id uint, uuid uuid.UUID, author
|
||||
//@param: id uint, authorityIds []string
|
||||
//@return: err error
|
||||
|
||||
func (userService *UserService) SetUserAuthorities(id uint, authorityIds []string) (err error) {
|
||||
func (userService *UserService) SetUserAuthorities(id uint, authorityIds []uint) (err error) {
|
||||
return global.GVA_DB.Transaction(func(tx *gorm.DB) error {
|
||||
TxErr := tx.Delete(&[]system.SysUseAuthority{}, "sys_user_id = ?", id).Error
|
||||
if TxErr != nil {
|
||||
|
Reference in New Issue
Block a user