Files
GuwandykA 72a5ac52b0
Some checks failed
CI/CD / Deploy binary to server (push) Has been cancelled
CI/CD / Vet, test, build (push) Has been cancelled
CI/CD / Docker image (push) Has been cancelled
shared: use one LocalizedText type everywhere
auth, user, userbranch and org/branches each declared their own identical
{en, ru, tm} struct; they now use shared.LocalizedText. No JSON change.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-24 21:48:03 +05:00

86 lines
2.5 KiB
Go

package user
import (
"time"
"online-back/internal/shared"
)
type StaffBranchDTO struct {
Id int64 `json:"id"`
UniqueCode string `json:"uniqueCode"`
Name shared.LocalizedText `json:"name"`
}
type UserPermissionDTO struct {
Code string `json:"code"`
Name string `json:"name"`
}
type UserDTO struct {
Id int64 `json:"id"`
Email string `json:"email"`
Name string `json:"name"`
FirstName string `json:"firstName"`
LastName string `json:"lastName"`
Username string `json:"username"`
Phone string `json:"phone"`
Avatar string `json:"avatar"`
Role string `json:"role"`
RoleId *int64 `json:"roleId,omitempty"`
Active bool `json:"active"`
CreatedAt time.Time `json:"createdAt"`
UpdatedAt time.Time `json:"updatedAt"`
Branches []StaffBranchDTO `json:"branches,omitempty"`
Permissions []UserPermissionDTO `json:"permissions,omitempty"`
}
type CreateUserDTO struct {
Email string `json:"email" binding:"required"`
Password string `json:"password" binding:"required"`
Name string `json:"name" binding:"required"`
FirstName string `json:"firstName"`
LastName string `json:"lastName"`
Username string `json:"username" binding:"required"`
Phone string `json:"phone"`
Avatar string `json:"avatar"`
// Role is a role code; RoleId wins when both are sent. Neither → "user".
Role string `json:"role"`
RoleId *int64 `json:"roleId"`
Active *bool `json:"active"`
}
type UpdateUserDTO struct {
Email string `json:"email" binding:"required"`
Name string `json:"name" binding:"required"`
FirstName string `json:"firstName"`
LastName string `json:"lastName"`
Username string `json:"username" binding:"required"`
Phone string `json:"phone"`
Avatar string `json:"avatar"`
// Role is a role code; RoleId wins when both are sent. Neither keeps
// the user's current role.
Role string `json:"role"`
RoleId *int64 `json:"roleId"`
Active bool `json:"active"`
}
type SetUserRoleDTO struct {
RoleId int64 `json:"roleId" binding:"required"`
}
type ListFilter struct {
Search string
BranchIds []int64
Page int
Limit int
// AllRoles, when true, skips the role=user filter so all-scope callers
// see every user regardless of role.
AllRoles bool
}
type ListUserDTO struct {
Count int64 `json:"count"`
Users []UserDTO `json:"users"`
}