修复前端设置数据权限不生效问题
This commit is contained in:
1 parent
492ac31973
commit
abdc80b756
3 files changed
+9
-6
No files matched your search
@@ -214,7 +214,7 @@ func (e *SysRole) UpdateDataScope(c *dto.RoleDataScopeReq) *SysRole {
|
|||||||
var dlist = make([]models.SysDept, 0)
|
var dlist = make([]models.SysDept, 0)
|
||||||
var model = models.SysRole{}
|
var model = models.SysRole{}
|
||||||
tx.Preload("SysDept").First(&model, c.RoleId)
|
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)
|
err = tx.Model(&model).Association("SysDept").Delete(model.SysDept)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
e.Log.Errorf("delete SysDept error:%s", err)
|
e.Log.Errorf("delete SysDept error:%s", err)
|
||||||
|
|||||||
@@ -70,7 +70,8 @@ func (s *{{.ClassName}}InsertReq) Generate(model *models.{{.ClassName}}) {
|
|||||||
{{- else if eq .GoField "CreatedAt" -}}
|
{{- else if eq .GoField "CreatedAt" -}}
|
||||||
{{- else if eq .GoField "UpdatedAt" -}}
|
{{- else if eq .GoField "UpdatedAt" -}}
|
||||||
{{- else if eq .GoField "DeletedAt" -}}
|
{{- 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 if eq .GoField "UpdateBy" -}}
|
||||||
{{- else }}
|
{{- else }}
|
||||||
model.{{.GoField}} = s.{{.GoField}}
|
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 "UpdatedAt" -}}
|
||||||
{{- else if eq .GoField "DeletedAt" -}}
|
{{- else if eq .GoField "DeletedAt" -}}
|
||||||
{{- else if eq .GoField "CreateBy" -}}
|
{{- else if eq .GoField "CreateBy" -}}
|
||||||
{{- else if eq .GoField "UpdateBy" -}}
|
{{- else if eq .GoField "UpdateBy"}}
|
||||||
|
model.{{.GoField}} = s.{{.GoField}} // 添加这而,需要记录是被谁更新的
|
||||||
{{- else }}
|
{{- else }}
|
||||||
model.{{.GoField}} = s.{{.GoField}}
|
model.{{.GoField}} = s.{{.GoField}}
|
||||||
{{- end -}}
|
{{- end -}}
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import (
|
|||||||
|
|
||||||
"go-admin/app/{{.PackageName}}/apis"
|
"go-admin/app/{{.PackageName}}/apis"
|
||||||
"go-admin/common/middleware"
|
"go-admin/common/middleware"
|
||||||
|
"go-admin/common/actions"
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
@@ -17,10 +18,10 @@ func register{{.ClassName}}Router(v1 *gin.RouterGroup, authMiddleware *jwt.GinJW
|
|||||||
api := apis.{{.ClassName}}{}
|
api := apis.{{.ClassName}}{}
|
||||||
r := v1.Group("/{{.ModuleName}}").Use(authMiddleware.MiddlewareFunc()).Use(middleware.AuthCheckRole())
|
r := v1.Group("/{{.ModuleName}}").Use(authMiddleware.MiddlewareFunc()).Use(middleware.AuthCheckRole())
|
||||||
{
|
{
|
||||||
r.GET("", api.GetPage)
|
r.GET("", actions.PermissionAction(), api.GetPage)
|
||||||
r.GET("/:id", api.Get)
|
r.GET("/:id", actions.PermissionAction(), api.Get)
|
||||||
r.POST("", api.Insert)
|
r.POST("", api.Insert)
|
||||||
r.PUT("/:id", api.Update)
|
r.PUT("/:id", actions.PermissionAction(), api.Update)
|
||||||
r.DELETE("", api.Delete)
|
r.DELETE("", api.Delete)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in new issue
Block a user