[优化] 更新kit包

This commit is contained in:
PandaGoAdmin
2022-08-19 21:54:57 +08:00
parent cf97d854d8
commit 915bc15bae
14 changed files with 162 additions and 22 deletions

View File

@@ -7,6 +7,7 @@ import (
"github.com/XM-GO/PandaKit/utils"
entity "pandax/apps/system/entity"
services "pandax/apps/system/services"
"pandax/pkg/global"
"strconv"
)
@@ -61,5 +62,6 @@ func (s *SystemApiApi) GetAllApis(rc *restfulx.ReqCtx) {
func (s *SystemApiApi) GetPolicyPathByRoleId(rc *restfulx.ReqCtx) {
roleKey := rc.Request.QueryParameter("roleKey")
tenantId := strconv.Itoa(int(rc.LoginAccount.TenantId))
rc.ResData = casbin.GetPolicyPathByRoleId(tenantId, roleKey)
ca := casbin.CasbinS{ModelPath: global.Conf.Casbin.ModelPath}
rc.ResData = ca.GetPolicyPathByRoleId(tenantId, roleKey)
}

View File

@@ -64,7 +64,8 @@ func (r *RoleApi) InsertRole(rc *restfulx.ReqCtx) {
r.RoleMenuApp.Insert(insert.RoleId, role.MenuIds)
//添加权限
tenantId := strconv.Itoa(int(rc.LoginAccount.TenantId))
casbin.UpdateCasbin(tenantId, role.RoleKey, role.ApiIds)
ca := casbin.CasbinS{ModelPath: global.Conf.Casbin.ModelPath}
ca.UpdateCasbin(tenantId, role.RoleKey, role.ApiIds)
}
// UpdateRole 修改用户角色
@@ -80,7 +81,8 @@ func (r *RoleApi) UpdateRole(rc *restfulx.ReqCtx) {
r.RoleMenuApp.Insert(role.RoleId, role.MenuIds)
//修改api权限
tenantId := strconv.Itoa(int(rc.LoginAccount.TenantId))
casbin.UpdateCasbin(tenantId, role.RoleKey, role.ApiIds)
ca := casbin.CasbinS{ModelPath: global.Conf.Casbin.ModelPath}
ca.UpdateCasbin(tenantId, role.RoleKey, role.ApiIds)
}
// UpdateRoleStatus 修改用户角色状态
@@ -122,7 +124,8 @@ func (r *RoleApi) DeleteRole(rc *restfulx.ReqCtx) {
if len(*list) == 0 {
delList = append(delList, rid)
//删除角色绑定api
casbin.ClearCasbin(0, role.RoleKey)
ca := casbin.CasbinS{ModelPath: global.Conf.Casbin.ModelPath}
ca.ClearCasbin(0, role.RoleKey)
} else {
global.Log.Info(fmt.Sprintf("role:%d 存在用户无法删除", rid))
}

View File

@@ -8,6 +8,7 @@ import (
"github.com/emicklei/go-restful/v3"
"github.com/gorilla/websocket"
"github.com/kakuilan/kgo"
"pandax/pkg/middleware"
"runtime"
)
@@ -71,7 +72,7 @@ func (s *System) ConnectWs(request *restful.Request, response *restful.Response)
}
// 权限校验
rc := restfulx.NewReqCtx(request, response)
if err = restfulx.PermissionHandler(rc); err != nil {
if err = middleware.PermissionHandler(rc); err != nil {
panic(any(biz.NewBizErr("没有权限")))
}

View File

@@ -107,7 +107,8 @@ func (m *sysApiModelImpl) Update(api entity.SysApi) *entity.SysApi {
biz.IsTrue(errors.Is(err, gorm.ErrRecordNotFound), "存在相同api路径")
}
// 异常直接抛错误
casbin.UpdateCasbinApi(oldA.Path, api.Path, oldA.Method, api.Method)
ca := casbin.CasbinS{ModelPath: global.Conf.Casbin.ModelPath}
ca.UpdateCasbinApi(oldA.Path, api.Path, oldA.Method, api.Method)
err = global.Db.Table(m.table).Model(&api).Updates(&api).Error
biz.ErrIsNil(err, "修改api信息失败")
return &api