修复前端设置数据权限不生效问题
This commit is contained in:
1 parent
492ac31973
commit
abdc80b756
3 files changed
+11
-8
No files matched your search
@@ -142,7 +142,7 @@ func (e *SysRole) Update(c *dto.SysRoleUpdateReq, cb *casbin.SyncedEnforcer) err
|
||||
e.Log.Errorf("delete policy error:%s", err)
|
||||
return err
|
||||
}
|
||||
mp:=make(map [string] interface{} ,0)
|
||||
mp := make(map[string]interface{}, 0)
|
||||
polices := make([][]string, 0)
|
||||
for _, menu := range mlist {
|
||||
for _, api := range menu.SysApi {
|
||||
@@ -214,7 +214,7 @@ func (e *SysRole) UpdateDataScope(c *dto.RoleDataScopeReq) *SysRole {
|
||||
var dlist = make([]models.SysDept, 0)
|
||||
var model = models.SysRole{}
|
||||
tx.Preload("SysDept").First(&model, c.RoleId)
|
||||
tx.Where("id in ?", c.DeptIds).Find(&dlist)
|
||||
tx.Where("dept_id in ?", c.DeptIds).Find(&dlist)
|
||||
err = tx.Model(&model).Association("SysDept").Delete(model.SysDept)
|
||||
if err != nil {
|
||||
e.Log.Errorf("delete SysDept error:%s", err)
|
||||
@@ -299,4 +299,4 @@ func (e *SysRole) GetById(roleId int) ([]string, error) {
|
||||
permissions = append(permissions, l[i].Permission)
|
||||
}
|
||||
return permissions, nil
|
||||
}
|
||||
}
|
||||
@@ -70,7 +70,8 @@ func (s *{{.ClassName}}InsertReq) Generate(model *models.{{.ClassName}}) {
|
||||
{{- else if eq .GoField "CreatedAt" -}}
|
||||
{{- else if eq .GoField "UpdatedAt" -}}
|
||||
{{- else if eq .GoField "DeletedAt" -}}
|
||||
{{- else if eq .GoField "CreateBy" -}}
|
||||
{{- else if eq .GoField "CreateBy"}}
|
||||
model.{{.GoField}} = s.{{.GoField}} // 添加这而,需要记录是被谁创建的
|
||||
{{- else if eq .GoField "UpdateBy" -}}
|
||||
{{- else }}
|
||||
model.{{.GoField}} = s.{{.GoField}}
|
||||
@@ -110,7 +111,8 @@ func (s *{{.ClassName}}UpdateReq) Generate(model *models.{{.ClassName}}) {
|
||||
{{- else if eq .GoField "UpdatedAt" -}}
|
||||
{{- else if eq .GoField "DeletedAt" -}}
|
||||
{{- else if eq .GoField "CreateBy" -}}
|
||||
{{- else if eq .GoField "UpdateBy" -}}
|
||||
{{- else if eq .GoField "UpdateBy"}}
|
||||
model.{{.GoField}} = s.{{.GoField}} // 添加这而,需要记录是被谁更新的
|
||||
{{- else }}
|
||||
model.{{.GoField}} = s.{{.GoField}}
|
||||
{{- end -}}
|
||||
|
||||
@@ -6,6 +6,7 @@ import (
|
||||
|
||||
"go-admin/app/{{.PackageName}}/apis"
|
||||
"go-admin/common/middleware"
|
||||
"go-admin/common/actions"
|
||||
)
|
||||
|
||||
func init() {
|
||||
@@ -17,10 +18,10 @@ func register{{.ClassName}}Router(v1 *gin.RouterGroup, authMiddleware *jwt.GinJW
|
||||
api := apis.{{.ClassName}}{}
|
||||
r := v1.Group("/{{.ModuleName}}").Use(authMiddleware.MiddlewareFunc()).Use(middleware.AuthCheckRole())
|
||||
{
|
||||
r.GET("", api.GetPage)
|
||||
r.GET("/:id", api.Get)
|
||||
r.GET("", actions.PermissionAction(), api.GetPage)
|
||||
r.GET("/:id", actions.PermissionAction(), api.Get)
|
||||
r.POST("", api.Insert)
|
||||
r.PUT("/:id", api.Update)
|
||||
r.PUT("/:id", actions.PermissionAction(), api.Update)
|
||||
r.DELETE("", api.Delete)
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user