Files
online-backend/internal/identity/user/dto.go
GuwandykA 323e131216
Some checks failed
CI/CD / Vet, test, build (push) Has been cancelled
CI/CD / Docker image (push) Has been cancelled
CI/CD / Deploy binary to server (push) Has been cancelled
changed role permission
2026-09-26 16:34:28 +05:00

88 lines
2.6 KiB
Go

package user
import "time"
type LocalizedText struct {
En string `json:"en"`
Ru string `json:"ru"`
Tm string `json:"tm"`
}
type StaffBranchDTO struct {
Id int64 `json:"id"`
UniqueCode string `json:"uniqueCode"`
Name 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"`
}