diff --git a/app/admin/service/sys_role.go b/app/admin/service/sys_role.go index d5879a3d..c1f1853c 100644 --- a/app/admin/service/sys_role.go +++ b/app/admin/service/sys_role.go @@ -227,7 +227,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) diff --git a/template/v4/dto.go.template b/template/v4/dto.go.template index 69178021..4f84c9f3 100644 --- a/template/v4/dto.go.template +++ b/template/v4/dto.go.template @@ -71,7 +71,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}} @@ -111,7 +112,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 -}} diff --git a/template/v4/no_actions/router_check_role.go.template b/template/v4/no_actions/router_check_role.go.template index 249c61c4..f8a3c3a7 100644 --- a/template/v4/no_actions/router_check_role.go.template +++ b/template/v4/no_actions/router_check_role.go.template @@ -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) } } \ No newline at end of file