This commit is contained in:
2026-02-11 17:46:22 +03:00
commit eacfacb13b
266 changed files with 51337 additions and 0 deletions

83
svc/permissions/models.go Normal file
View 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
===================================================== */
// DBden 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"
}