84 lines
2.4 KiB
Go
84 lines
2.4 KiB
Go
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"
|
||
}
|