ilk
This commit is contained in:
83
svc/permissions/models.go
Normal file
83
svc/permissions/models.go
Normal file
@@ -0,0 +1,83 @@
|
||||
package permissions
|
||||
|
||||
/* =====================================================
|
||||
ROLE PERMISSION MATRIX (READ)
|
||||
- Role bazlı matrix ekranı için: role_id + role_code + module/action/allowed
|
||||
- UI isterse "source" alanı ile satırın nereden geldiğini gösterebilir.
|
||||
===================================================== */
|
||||
|
||||
type PermissionMatrixRow struct {
|
||||
// Role tarafı
|
||||
RoleID int `json:"role_id,omitempty"`
|
||||
RoleCode string `json:"role_code,omitempty"`
|
||||
|
||||
// User override tarafı
|
||||
UserID int64 `json:"user_id,omitempty"`
|
||||
|
||||
// Ortak alanlar
|
||||
Module string `json:"module"`
|
||||
ModuleCode string `json:"module_code"`
|
||||
Action string `json:"action"`
|
||||
Allowed bool `json:"allowed"`
|
||||
|
||||
// role | user
|
||||
Source string `json:"source"`
|
||||
}
|
||||
|
||||
/* =====================================================
|
||||
ROLE PERMISSION UPDATE (WRITE)
|
||||
- /api/permissions/matrix POST gibi update endpoint'lerinde kullanılır
|
||||
===================================================== */
|
||||
|
||||
type PermissionUpdateRequest struct {
|
||||
RoleID int `json:"role_id"`
|
||||
Module string `json:"module"`
|
||||
Action string `json:"action"`
|
||||
Allowed bool `json:"allowed"`
|
||||
}
|
||||
|
||||
/* =====================================================
|
||||
USER OVERRIDE MODELS
|
||||
- mk_sys_user_permissions tablosu için
|
||||
===================================================== */
|
||||
|
||||
// DB’den okurken döndüğümüz satır (GET /api/users/{id}/permissions)
|
||||
type UserOverrideRow struct {
|
||||
Module string `json:"module"`
|
||||
Action string `json:"action"`
|
||||
Allowed bool `json:"allowed"`
|
||||
}
|
||||
|
||||
// Middleware içinde hızlı okuma için de kullanılabilir (GetUserOverrides)
|
||||
type UserPermissionOverride struct {
|
||||
Module string `json:"module"`
|
||||
Action string `json:"action"`
|
||||
Allowed bool `json:"allowed"`
|
||||
}
|
||||
|
||||
// Repo “upsert/insert” gibi operasyonlarda kullanılacak internal model
|
||||
type UserPermission struct {
|
||||
UserID int64 `json:"user_id"`
|
||||
Module string `json:"module"`
|
||||
Action string `json:"action"`
|
||||
Allowed bool `json:"allowed"`
|
||||
}
|
||||
|
||||
// POST payload için tip (SaveUserOverrides input)
|
||||
type UserPermissionRequest struct {
|
||||
Module string `json:"module"`
|
||||
Action string `json:"action"`
|
||||
Allowed bool `json:"allowed"`
|
||||
}
|
||||
|
||||
// Role + Department Permission Row
|
||||
type RoleDepartmentPermission struct {
|
||||
RoleID int `json:"role_id"`
|
||||
DepartmentCode string `json:"department_code"`
|
||||
|
||||
Module string `json:"module"`
|
||||
Action string `json:"action"`
|
||||
Allowed bool `json:"allowed"`
|
||||
|
||||
Source string `json:"source"` // "role_dept"
|
||||
}
|
||||
Reference in New Issue
Block a user