mirror of
https://gitee.com/XM-GO/PandaX.git
synced 2026-04-23 02:48:34 +08:00
[优化] 更新kit包
This commit is contained in:
@@ -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)
|
||||
}
|
||||
|
||||
@@ -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))
|
||||
}
|
||||
|
||||
@@ -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("没有权限")))
|
||||
}
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user