| 12345678910111213141516171819202122232425262728293031323334353637383940414243 |
- package permission
- import (
- "git.sxidc.com/go-framework/baize/convenient/entity_crud"
- "git.sxidc.com/go-framework/baize/framework/binding"
- "git.sxidc.com/go-framework/baize/framework/core/api"
- "git.sxidc.com/go-framework/baize/framework/core/domain"
- "git.sxidc.com/go-framework/baize/framework/core/domain/entity"
- "git.sxidc.com/go-framework/baize/framework/core/infrastructure"
- "git.sxidc.com/go-framework/baize/framework/core/infrastructure/database"
- )
- // Simple Bind参数
- type Simple struct {
- // schema
- Schema string
- // 鉴权中间件
- AuthMiddleware binding.Middleware
- }
- func (simple *Simple) Bind(binder *binding.Binder) {
- entity_crud.BindSimple(binder, &entity_crud.Simple[Info]{
- Entity: &Entity{},
- Schema: simple.Schema,
- CreateJsonBody: &CreatePermissionJsonBody{},
- DeleteQueryParams: &DeletePermissionQueryParams{},
- UpdateJsonBody: &UpdatePermissionJsonBody{},
- QueryQueryParams: &GetPermissionsQueryParams{},
- GetByIDQueryParams: &GetPermissionQueryParams{},
- }, entity_crud.WithGlobalMiddlewares(simple.AuthMiddleware),
- entity_crud.WithCreateCallbacks(&entity_crud.CreateCallbacks{
- Before: func(c *api.Context, e entity.Entity, prepared map[string]any, i *infrastructure.Infrastructure, tx database.Executor) error {
- userInfo := c.GetUserInfo()
- return domain.SetField(e, entity.FieldCreateUserID, userInfo.GetID())
- },
- }), entity_crud.WithUpdateCallbacks(&entity_crud.UpdateCallbacks{
- Before: func(c *api.Context, e entity.Entity, prepared map[string]any, i *infrastructure.Infrastructure, tx database.Executor) error {
- userInfo := c.GetUserInfo()
- return domain.SetField(e, entity.FieldLastUpdateUserID, userInfo.GetID())
- },
- }))
- }
|