Add Role Assignment Feature for Customers

- Introduced a new role assignment feature for customers, allowing roles to be assigned as either 'admin' or 'analyst'.
- Updated the Customer entity to include a Role field, enhancing the data model to support role management.
- Created new request and response forms for role assignment, ensuring proper validation and structured responses.
- Implemented the AssignRole method in the customer service layer, handling role assignment logic and error management.
- Added a new AssignRole handler to process role assignment requests via the API, complete with Swagger documentation for clarity.
- Updated routes to include the new role assignment endpoint, improving the administrative capabilities of the system.
- Enhanced logging for role assignment operations to ensure traceability and debugging ease.
This commit is contained in:
n.nakhostin
2025-09-17 10:15:14 +03:30
parent 3af09693f8
commit b429bcd24f
5 changed files with 124 additions and 1 deletions
+9
View File
@@ -24,6 +24,14 @@ const (
CustomerTypeGovernment CustomerType = "government"
)
// CustomerRole represents the role of customer
type CustomerRole string
const (
CustomerRoleAdmin CustomerRole = "admin"
CustomerRoleAnalyst CustomerRole = "analyst"
)
// Customer represents a customer in the tender management system
// A customer can have an associated company for login purposes
type Customer struct {
@@ -34,6 +42,7 @@ type Customer struct {
Password string `bson:"password"`
Status CustomerStatus `bson:"status"`
Type CustomerType `bson:"type"`
Role CustomerRole `bson:"role"`
Phone *string `bson:"phone"`
CompanyIDs []string `bson:"company_ids"`
LastLoginAt *int64 `bson:"last_login_at"`