diff --git a/README.md b/README.md index f5442e4..3b3c8d1 100644 --- a/README.md +++ b/README.md @@ -64,10 +64,9 @@ The Tender Management API features comprehensive, auto-generated Swagger documen - **Health**: System monitoring and health check endpoints - **Authorization**: User authentication, token management, and session handling - **Users**: Administrative user management with RBAC (Role-Based Access Control) -- **Customers-Admin**: Web panel customer management with advanced filtering +- **Admin-Customers**: Web panel customer management with advanced filtering - **Customers-Authorization**: Mobile app customer authentication and profile access -- **Companies-Admin**: Comprehensive company management with search, filtering, and analytics -- **Companies-Mobile**: Mobile-optimized company lookup and information retrieval +- **Admin-Companies**: Comprehensive company management with search, filtering, and analytics #### 🔧 **Documentation Access** - **Local Development**: `http://localhost:8081/swagger/` diff --git a/cmd/web/docs/docs.go b/cmd/web/docs/docs.go index 234b39e..ea9e811 100644 --- a/cmd/web/docs/docs.go +++ b/cmd/web/docs/docs.go @@ -39,7 +39,7 @@ const docTemplate = `{ "application/json" ], "tags": [ - "Companies-Admin" + "Admin-Companies" ], "summary": "List companies with filters and pagination", "parameters": [ @@ -251,7 +251,7 @@ const docTemplate = `{ "application/json" ], "tags": [ - "Companies-Admin" + "Admin-Companies" ], "summary": "Create a new company", "parameters": [ @@ -326,7 +326,7 @@ const docTemplate = `{ "application/json" ], "tags": [ - "Companies-Admin" + "Admin-Companies" ], "summary": "Get companies by industry", "parameters": [ @@ -410,7 +410,7 @@ const docTemplate = `{ "application/json" ], "tags": [ - "Companies-Admin" + "Admin-Companies" ], "summary": "Advanced search for companies", "parameters": [ @@ -562,7 +562,7 @@ const docTemplate = `{ "application/json" ], "tags": [ - "Companies-Admin" + "Admin-Companies" ], "summary": "Get company statistics", "responses": { @@ -608,7 +608,7 @@ const docTemplate = `{ "application/json" ], "tags": [ - "Companies-Admin" + "Admin-Companies" ], "summary": "Get companies by status", "parameters": [ @@ -698,7 +698,7 @@ const docTemplate = `{ "application/json" ], "tags": [ - "Companies-Admin" + "Admin-Companies" ], "summary": "Get companies by type", "parameters": [ @@ -789,7 +789,7 @@ const docTemplate = `{ "application/json" ], "tags": [ - "Companies-Admin" + "Admin-Companies" ], "summary": "Get company by ID", "parameters": [ @@ -854,7 +854,7 @@ const docTemplate = `{ "application/json" ], "tags": [ - "Companies-Admin" + "Admin-Companies" ], "summary": "Update company information", "parameters": [ @@ -940,7 +940,7 @@ const docTemplate = `{ "application/json" ], "tags": [ - "Companies-Admin" + "Admin-Companies" ], "summary": "Delete company", "parameters": [ @@ -995,7 +995,7 @@ const docTemplate = `{ "application/json" ], "tags": [ - "Companies-Admin" + "Admin-Companies" ], "summary": "Activate company", "parameters": [ @@ -1050,7 +1050,7 @@ const docTemplate = `{ "application/json" ], "tags": [ - "Companies-Admin" + "Admin-Companies" ], "summary": "Update company status", "parameters": [ @@ -1120,7 +1120,7 @@ const docTemplate = `{ "application/json" ], "tags": [ - "Companies-Admin" + "Admin-Companies" ], "summary": "Suspend company", "parameters": [ @@ -1190,7 +1190,7 @@ const docTemplate = `{ "application/json" ], "tags": [ - "Companies-Admin" + "Admin-Companies" ], "summary": "Update company tags", "parameters": [ @@ -1260,7 +1260,7 @@ const docTemplate = `{ "application/json" ], "tags": [ - "Companies-Admin" + "Admin-Companies" ], "summary": "Add tags to company", "parameters": [ @@ -1330,7 +1330,7 @@ const docTemplate = `{ "application/json" ], "tags": [ - "Companies-Admin" + "Admin-Companies" ], "summary": "Remove tags from company", "parameters": [ @@ -1400,7 +1400,7 @@ const docTemplate = `{ "application/json" ], "tags": [ - "Companies-Admin" + "Admin-Companies" ], "summary": "Update company verification status", "parameters": [ @@ -1470,7 +1470,7 @@ const docTemplate = `{ "application/json" ], "tags": [ - "Companies-Admin" + "Admin-Companies" ], "summary": "Verify company", "parameters": [ @@ -1525,7 +1525,7 @@ const docTemplate = `{ "application/json" ], "tags": [ - "Customers-Admin" + "Admin-Customers" ], "summary": "List customers with filters and pagination", "parameters": [ @@ -1691,7 +1691,7 @@ const docTemplate = `{ "application/json" ], "tags": [ - "Customers-Admin" + "Admin-Customers" ], "summary": "Create a new customer", "parameters": [ @@ -1766,7 +1766,7 @@ const docTemplate = `{ "application/json" ], "tags": [ - "Customers-Admin" + "Admin-Customers" ], "summary": "Get customers by company ID", "parameters": [ @@ -1842,7 +1842,7 @@ const docTemplate = `{ "application/json" ], "tags": [ - "Customers-Admin" + "Admin-Customers" ], "summary": "Get customers by status", "parameters": [ @@ -1932,7 +1932,7 @@ const docTemplate = `{ "application/json" ], "tags": [ - "Customers-Admin" + "Admin-Customers" ], "summary": "Get customers by type", "parameters": [ @@ -2021,7 +2021,7 @@ const docTemplate = `{ "application/json" ], "tags": [ - "Customers-Admin" + "Admin-Customers" ], "summary": "List customers with companies and filters", "parameters": [ @@ -2189,7 +2189,7 @@ const docTemplate = `{ "application/json" ], "tags": [ - "Customers-Admin" + "Admin-Customers" ], "summary": "Get customer by ID", "parameters": [ @@ -2254,7 +2254,7 @@ const docTemplate = `{ "application/json" ], "tags": [ - "Customers-Admin" + "Admin-Customers" ], "summary": "Update customer information", "parameters": [ @@ -2340,7 +2340,7 @@ const docTemplate = `{ "application/json" ], "tags": [ - "Customers-Admin" + "Admin-Customers" ], "summary": "Delete customer", "parameters": [ @@ -2395,7 +2395,7 @@ const docTemplate = `{ "application/json" ], "tags": [ - "Customers-Admin" + "Admin-Customers" ], "summary": "Activate customer", "parameters": [ @@ -2450,7 +2450,7 @@ const docTemplate = `{ "application/json" ], "tags": [ - "Customers-Admin" + "Admin-Customers" ], "summary": "Assign companies to a customer", "parameters": [ @@ -2520,7 +2520,7 @@ const docTemplate = `{ "application/json" ], "tags": [ - "Customers-Admin" + "Admin-Customers" ], "summary": "Remove companies from a customer", "parameters": [ @@ -2590,7 +2590,7 @@ const docTemplate = `{ "application/json" ], "tags": [ - "Customers-Admin" + "Admin-Customers" ], "summary": "Update customer status", "parameters": [ @@ -2660,7 +2660,7 @@ const docTemplate = `{ "application/json" ], "tags": [ - "Customers-Admin" + "Admin-Customers" ], "summary": "Suspend customer", "parameters": [ @@ -2730,7 +2730,7 @@ const docTemplate = `{ "application/json" ], "tags": [ - "Customers-Admin" + "Admin-Customers" ], "summary": "Update customer verification status", "parameters": [ @@ -2800,7 +2800,7 @@ const docTemplate = `{ "application/json" ], "tags": [ - "Customers-Admin" + "Admin-Customers" ], "summary": "Verify customer", "parameters": [ @@ -2855,7 +2855,7 @@ const docTemplate = `{ "application/json" ], "tags": [ - "Customers-Admin" + "Admin-Customers" ], "summary": "Get customer by ID with companies", "parameters": [ @@ -2917,7 +2917,7 @@ const docTemplate = `{ "application/json" ], "tags": [ - "Health" + "Admin-Health" ], "summary": "Health check endpoint", "responses": { @@ -2951,7 +2951,7 @@ const docTemplate = `{ "application/json" ], "tags": [ - "Users" + "Admin-Users" ], "summary": "Get authenticated user profile", "responses": { @@ -3007,7 +3007,7 @@ const docTemplate = `{ "application/json" ], "tags": [ - "Users" + "Admin-Users" ], "summary": "Update authenticated user profile", "parameters": [ @@ -3088,7 +3088,7 @@ const docTemplate = `{ "application/json" ], "tags": [ - "Users" + "Admin-Users" ], "summary": "Change user password", "parameters": [ @@ -3146,7 +3146,7 @@ const docTemplate = `{ "application/json" ], "tags": [ - "Authorization" + "Admin-Authorization" ], "summary": "Authenticate user login", "parameters": [ @@ -3227,7 +3227,7 @@ const docTemplate = `{ "application/json" ], "tags": [ - "Authorization" + "Admin-Authorization" ], "summary": "Logout authenticated user", "responses": { @@ -3262,7 +3262,7 @@ const docTemplate = `{ "application/json" ], "tags": [ - "Authorization" + "Admin-Authorization" ], "summary": "Refresh access token", "parameters": [ @@ -3332,7 +3332,7 @@ const docTemplate = `{ "application/json" ], "tags": [ - "Authorization" + "Admin-Authorization" ], "summary": "Initiate password reset process", "parameters": [ @@ -3401,7 +3401,7 @@ const docTemplate = `{ "application/json" ], "tags": [ - "Users" + "Admin-Users" ], "summary": "List users", "parameters": [ @@ -3513,7 +3513,7 @@ const docTemplate = `{ "application/json" ], "tags": [ - "Users" + "Admin-Users" ], "summary": "Create new user account", "parameters": [ @@ -3600,7 +3600,7 @@ const docTemplate = `{ "application/json" ], "tags": [ - "Users" + "Admin-Users" ], "summary": "Get users by company ID", "parameters": [ @@ -3686,7 +3686,7 @@ const docTemplate = `{ "application/json" ], "tags": [ - "Users" + "Admin-Users" ], "summary": "Get users by role", "parameters": [ @@ -3772,7 +3772,7 @@ const docTemplate = `{ "application/json" ], "tags": [ - "Users" + "Admin-Users" ], "summary": "Get user by ID", "parameters": [ @@ -3849,7 +3849,7 @@ const docTemplate = `{ "application/json" ], "tags": [ - "Users" + "Admin-Users" ], "summary": "Update user", "parameters": [ @@ -3935,7 +3935,7 @@ const docTemplate = `{ "application/json" ], "tags": [ - "Users" + "Admin-Users" ], "summary": "Delete user", "parameters": [ @@ -4002,7 +4002,7 @@ const docTemplate = `{ "application/json" ], "tags": [ - "Users" + "Admin-Users" ], "summary": "Update user role", "parameters": [ @@ -4078,7 +4078,7 @@ const docTemplate = `{ "application/json" ], "tags": [ - "Users" + "Admin-Users" ], "summary": "Update user status", "parameters": [ @@ -4139,7 +4139,7 @@ const docTemplate = `{ } } }, - "/api/v1/": { + "/api/v1/profile": { "get": { "security": [ { @@ -4154,7 +4154,7 @@ const docTemplate = `{ "application/json" ], "tags": [ - "Customers-Authorization" + "Authorization" ], "summary": "Get customer profile", "responses": { @@ -4197,46 +4197,6 @@ const docTemplate = `{ } } }, - "/api/v1/logout": { - "delete": { - "security": [ - { - "BearerAuth": [] - } - ], - "description": "Logout customer and invalidate access token", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "Customers-Authorization" - ], - "summary": "Customer logout", - "responses": { - "200": { - "description": "Logout successful", - "schema": { - "$ref": "#/definitions/response.APIResponse" - } - }, - "401": { - "description": "Unauthorized - Invalid or missing token", - "schema": { - "$ref": "#/definitions/response.APIResponse" - } - }, - "500": { - "description": "Internal server error", - "schema": { - "$ref": "#/definitions/response.APIResponse" - } - } - } - } - }, "/api/v1/profile/login": { "post": { "description": "Authenticate customer with username (email) and password. Returns access token, refresh token, and customer information upon successful authentication.", @@ -4247,7 +4207,7 @@ const docTemplate = `{ "application/json" ], "tags": [ - "Customers-Authorization" + "Authorization" ], "summary": "Customer login", "parameters": [ @@ -4307,6 +4267,46 @@ const docTemplate = `{ } } }, + "/api/v1/profile/logout": { + "delete": { + "security": [ + { + "BearerAuth": [] + } + ], + "description": "Logout customer and invalidate access token", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "Authorization" + ], + "summary": "Customer logout", + "responses": { + "200": { + "description": "Logout successful", + "schema": { + "$ref": "#/definitions/response.APIResponse" + } + }, + "401": { + "description": "Unauthorized - Invalid or missing token", + "schema": { + "$ref": "#/definitions/response.APIResponse" + } + }, + "500": { + "description": "Internal server error", + "schema": { + "$ref": "#/definitions/response.APIResponse" + } + } + } + } + }, "/api/v1/profile/refresh-token": { "post": { "description": "Refresh access token using a valid refresh token. This allows customers to maintain their session without re-authentication.", @@ -4317,7 +4317,7 @@ const docTemplate = `{ "application/json" ], "tags": [ - "Customers-Authorization" + "Authorization" ], "summary": "Refresh customer access token", "parameters": [ @@ -4377,7 +4377,7 @@ const docTemplate = `{ } } }, - "/api/v1/with-companies": { + "/api/v1/profile/with-companies": { "get": { "security": [ { @@ -4392,7 +4392,7 @@ const docTemplate = `{ "application/json" ], "tags": [ - "Customers-Authorization" + "Authorization" ], "summary": "Get customer profile with companies", "responses": { @@ -5223,10 +5223,6 @@ const docTemplate = `{ "type": "string" } }, - "company_name": { - "description": "Company customer fields", - "type": "string" - }, "contact_person": { "description": "Contact person (for company customers)", "allOf": [ @@ -5274,6 +5270,7 @@ const docTemplate = `{ "type": "string" }, "registration_number": { + "description": "Company customer fields", "type": "string" }, "tax_id": { @@ -5928,31 +5925,27 @@ const docTemplate = `{ "tags": [ { "description": "System health check operations for monitoring application status and dependencies", - "name": "Health" + "name": "Admin-Health" }, { "description": "User authentication and authorization operations including login, logout, token refresh, and password management for web panel administration", - "name": "Authorization" + "name": "Admin-Authorization" }, { "description": "Administrative user management operations including CRUD operations, role management, status updates, and profile management for web panel administrators", - "name": "Users" + "name": "Admin-Users" }, { "description": "Administrative customer management operations for web panel including CRUD operations, company assignment, verification, status management, and comprehensive filtering with pagination", - "name": "Customers-Admin" - }, - { - "description": "Customer authentication and authorization operations for mobile application including login, logout, token refresh, and profile access", - "name": "Customers-Authorization" + "name": "Admin-Customers" }, { "description": "Administrative company management operations for web panel including CRUD operations, tag management, verification, status updates, comprehensive search and filtering, and statistical reporting", - "name": "Companies-Admin" + "name": "Admin-Companies" }, { - "description": "Company-related operations for mobile application including company lookup, search, and basic information retrieval", - "name": "Companies-Mobile" + "description": "Customer authentication and authorization operations for mobile application including login, logout, token refresh, and profile access", + "name": "Authorization" } ] }` diff --git a/cmd/web/docs/swagger.json b/cmd/web/docs/swagger.json index 3706d0b..1ecbc8f 100644 --- a/cmd/web/docs/swagger.json +++ b/cmd/web/docs/swagger.json @@ -33,7 +33,7 @@ "application/json" ], "tags": [ - "Companies-Admin" + "Admin-Companies" ], "summary": "List companies with filters and pagination", "parameters": [ @@ -245,7 +245,7 @@ "application/json" ], "tags": [ - "Companies-Admin" + "Admin-Companies" ], "summary": "Create a new company", "parameters": [ @@ -320,7 +320,7 @@ "application/json" ], "tags": [ - "Companies-Admin" + "Admin-Companies" ], "summary": "Get companies by industry", "parameters": [ @@ -404,7 +404,7 @@ "application/json" ], "tags": [ - "Companies-Admin" + "Admin-Companies" ], "summary": "Advanced search for companies", "parameters": [ @@ -556,7 +556,7 @@ "application/json" ], "tags": [ - "Companies-Admin" + "Admin-Companies" ], "summary": "Get company statistics", "responses": { @@ -602,7 +602,7 @@ "application/json" ], "tags": [ - "Companies-Admin" + "Admin-Companies" ], "summary": "Get companies by status", "parameters": [ @@ -692,7 +692,7 @@ "application/json" ], "tags": [ - "Companies-Admin" + "Admin-Companies" ], "summary": "Get companies by type", "parameters": [ @@ -783,7 +783,7 @@ "application/json" ], "tags": [ - "Companies-Admin" + "Admin-Companies" ], "summary": "Get company by ID", "parameters": [ @@ -848,7 +848,7 @@ "application/json" ], "tags": [ - "Companies-Admin" + "Admin-Companies" ], "summary": "Update company information", "parameters": [ @@ -934,7 +934,7 @@ "application/json" ], "tags": [ - "Companies-Admin" + "Admin-Companies" ], "summary": "Delete company", "parameters": [ @@ -989,7 +989,7 @@ "application/json" ], "tags": [ - "Companies-Admin" + "Admin-Companies" ], "summary": "Activate company", "parameters": [ @@ -1044,7 +1044,7 @@ "application/json" ], "tags": [ - "Companies-Admin" + "Admin-Companies" ], "summary": "Update company status", "parameters": [ @@ -1114,7 +1114,7 @@ "application/json" ], "tags": [ - "Companies-Admin" + "Admin-Companies" ], "summary": "Suspend company", "parameters": [ @@ -1184,7 +1184,7 @@ "application/json" ], "tags": [ - "Companies-Admin" + "Admin-Companies" ], "summary": "Update company tags", "parameters": [ @@ -1254,7 +1254,7 @@ "application/json" ], "tags": [ - "Companies-Admin" + "Admin-Companies" ], "summary": "Add tags to company", "parameters": [ @@ -1324,7 +1324,7 @@ "application/json" ], "tags": [ - "Companies-Admin" + "Admin-Companies" ], "summary": "Remove tags from company", "parameters": [ @@ -1394,7 +1394,7 @@ "application/json" ], "tags": [ - "Companies-Admin" + "Admin-Companies" ], "summary": "Update company verification status", "parameters": [ @@ -1464,7 +1464,7 @@ "application/json" ], "tags": [ - "Companies-Admin" + "Admin-Companies" ], "summary": "Verify company", "parameters": [ @@ -1519,7 +1519,7 @@ "application/json" ], "tags": [ - "Customers-Admin" + "Admin-Customers" ], "summary": "List customers with filters and pagination", "parameters": [ @@ -1685,7 +1685,7 @@ "application/json" ], "tags": [ - "Customers-Admin" + "Admin-Customers" ], "summary": "Create a new customer", "parameters": [ @@ -1760,7 +1760,7 @@ "application/json" ], "tags": [ - "Customers-Admin" + "Admin-Customers" ], "summary": "Get customers by company ID", "parameters": [ @@ -1836,7 +1836,7 @@ "application/json" ], "tags": [ - "Customers-Admin" + "Admin-Customers" ], "summary": "Get customers by status", "parameters": [ @@ -1926,7 +1926,7 @@ "application/json" ], "tags": [ - "Customers-Admin" + "Admin-Customers" ], "summary": "Get customers by type", "parameters": [ @@ -2015,7 +2015,7 @@ "application/json" ], "tags": [ - "Customers-Admin" + "Admin-Customers" ], "summary": "List customers with companies and filters", "parameters": [ @@ -2183,7 +2183,7 @@ "application/json" ], "tags": [ - "Customers-Admin" + "Admin-Customers" ], "summary": "Get customer by ID", "parameters": [ @@ -2248,7 +2248,7 @@ "application/json" ], "tags": [ - "Customers-Admin" + "Admin-Customers" ], "summary": "Update customer information", "parameters": [ @@ -2334,7 +2334,7 @@ "application/json" ], "tags": [ - "Customers-Admin" + "Admin-Customers" ], "summary": "Delete customer", "parameters": [ @@ -2389,7 +2389,7 @@ "application/json" ], "tags": [ - "Customers-Admin" + "Admin-Customers" ], "summary": "Activate customer", "parameters": [ @@ -2444,7 +2444,7 @@ "application/json" ], "tags": [ - "Customers-Admin" + "Admin-Customers" ], "summary": "Assign companies to a customer", "parameters": [ @@ -2514,7 +2514,7 @@ "application/json" ], "tags": [ - "Customers-Admin" + "Admin-Customers" ], "summary": "Remove companies from a customer", "parameters": [ @@ -2584,7 +2584,7 @@ "application/json" ], "tags": [ - "Customers-Admin" + "Admin-Customers" ], "summary": "Update customer status", "parameters": [ @@ -2654,7 +2654,7 @@ "application/json" ], "tags": [ - "Customers-Admin" + "Admin-Customers" ], "summary": "Suspend customer", "parameters": [ @@ -2724,7 +2724,7 @@ "application/json" ], "tags": [ - "Customers-Admin" + "Admin-Customers" ], "summary": "Update customer verification status", "parameters": [ @@ -2794,7 +2794,7 @@ "application/json" ], "tags": [ - "Customers-Admin" + "Admin-Customers" ], "summary": "Verify customer", "parameters": [ @@ -2849,7 +2849,7 @@ "application/json" ], "tags": [ - "Customers-Admin" + "Admin-Customers" ], "summary": "Get customer by ID with companies", "parameters": [ @@ -2911,7 +2911,7 @@ "application/json" ], "tags": [ - "Health" + "Admin-Health" ], "summary": "Health check endpoint", "responses": { @@ -2945,7 +2945,7 @@ "application/json" ], "tags": [ - "Users" + "Admin-Users" ], "summary": "Get authenticated user profile", "responses": { @@ -3001,7 +3001,7 @@ "application/json" ], "tags": [ - "Users" + "Admin-Users" ], "summary": "Update authenticated user profile", "parameters": [ @@ -3082,7 +3082,7 @@ "application/json" ], "tags": [ - "Users" + "Admin-Users" ], "summary": "Change user password", "parameters": [ @@ -3140,7 +3140,7 @@ "application/json" ], "tags": [ - "Authorization" + "Admin-Authorization" ], "summary": "Authenticate user login", "parameters": [ @@ -3221,7 +3221,7 @@ "application/json" ], "tags": [ - "Authorization" + "Admin-Authorization" ], "summary": "Logout authenticated user", "responses": { @@ -3256,7 +3256,7 @@ "application/json" ], "tags": [ - "Authorization" + "Admin-Authorization" ], "summary": "Refresh access token", "parameters": [ @@ -3326,7 +3326,7 @@ "application/json" ], "tags": [ - "Authorization" + "Admin-Authorization" ], "summary": "Initiate password reset process", "parameters": [ @@ -3395,7 +3395,7 @@ "application/json" ], "tags": [ - "Users" + "Admin-Users" ], "summary": "List users", "parameters": [ @@ -3507,7 +3507,7 @@ "application/json" ], "tags": [ - "Users" + "Admin-Users" ], "summary": "Create new user account", "parameters": [ @@ -3594,7 +3594,7 @@ "application/json" ], "tags": [ - "Users" + "Admin-Users" ], "summary": "Get users by company ID", "parameters": [ @@ -3680,7 +3680,7 @@ "application/json" ], "tags": [ - "Users" + "Admin-Users" ], "summary": "Get users by role", "parameters": [ @@ -3766,7 +3766,7 @@ "application/json" ], "tags": [ - "Users" + "Admin-Users" ], "summary": "Get user by ID", "parameters": [ @@ -3843,7 +3843,7 @@ "application/json" ], "tags": [ - "Users" + "Admin-Users" ], "summary": "Update user", "parameters": [ @@ -3929,7 +3929,7 @@ "application/json" ], "tags": [ - "Users" + "Admin-Users" ], "summary": "Delete user", "parameters": [ @@ -3996,7 +3996,7 @@ "application/json" ], "tags": [ - "Users" + "Admin-Users" ], "summary": "Update user role", "parameters": [ @@ -4072,7 +4072,7 @@ "application/json" ], "tags": [ - "Users" + "Admin-Users" ], "summary": "Update user status", "parameters": [ @@ -4133,7 +4133,7 @@ } } }, - "/api/v1/": { + "/api/v1/profile": { "get": { "security": [ { @@ -4148,7 +4148,7 @@ "application/json" ], "tags": [ - "Customers-Authorization" + "Authorization" ], "summary": "Get customer profile", "responses": { @@ -4191,46 +4191,6 @@ } } }, - "/api/v1/logout": { - "delete": { - "security": [ - { - "BearerAuth": [] - } - ], - "description": "Logout customer and invalidate access token", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "Customers-Authorization" - ], - "summary": "Customer logout", - "responses": { - "200": { - "description": "Logout successful", - "schema": { - "$ref": "#/definitions/response.APIResponse" - } - }, - "401": { - "description": "Unauthorized - Invalid or missing token", - "schema": { - "$ref": "#/definitions/response.APIResponse" - } - }, - "500": { - "description": "Internal server error", - "schema": { - "$ref": "#/definitions/response.APIResponse" - } - } - } - } - }, "/api/v1/profile/login": { "post": { "description": "Authenticate customer with username (email) and password. Returns access token, refresh token, and customer information upon successful authentication.", @@ -4241,7 +4201,7 @@ "application/json" ], "tags": [ - "Customers-Authorization" + "Authorization" ], "summary": "Customer login", "parameters": [ @@ -4301,6 +4261,46 @@ } } }, + "/api/v1/profile/logout": { + "delete": { + "security": [ + { + "BearerAuth": [] + } + ], + "description": "Logout customer and invalidate access token", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "Authorization" + ], + "summary": "Customer logout", + "responses": { + "200": { + "description": "Logout successful", + "schema": { + "$ref": "#/definitions/response.APIResponse" + } + }, + "401": { + "description": "Unauthorized - Invalid or missing token", + "schema": { + "$ref": "#/definitions/response.APIResponse" + } + }, + "500": { + "description": "Internal server error", + "schema": { + "$ref": "#/definitions/response.APIResponse" + } + } + } + } + }, "/api/v1/profile/refresh-token": { "post": { "description": "Refresh access token using a valid refresh token. This allows customers to maintain their session without re-authentication.", @@ -4311,7 +4311,7 @@ "application/json" ], "tags": [ - "Customers-Authorization" + "Authorization" ], "summary": "Refresh customer access token", "parameters": [ @@ -4371,7 +4371,7 @@ } } }, - "/api/v1/with-companies": { + "/api/v1/profile/with-companies": { "get": { "security": [ { @@ -4386,7 +4386,7 @@ "application/json" ], "tags": [ - "Customers-Authorization" + "Authorization" ], "summary": "Get customer profile with companies", "responses": { @@ -5217,10 +5217,6 @@ "type": "string" } }, - "company_name": { - "description": "Company customer fields", - "type": "string" - }, "contact_person": { "description": "Contact person (for company customers)", "allOf": [ @@ -5268,6 +5264,7 @@ "type": "string" }, "registration_number": { + "description": "Company customer fields", "type": "string" }, "tax_id": { @@ -5922,31 +5919,27 @@ "tags": [ { "description": "System health check operations for monitoring application status and dependencies", - "name": "Health" + "name": "Admin-Health" }, { "description": "User authentication and authorization operations including login, logout, token refresh, and password management for web panel administration", - "name": "Authorization" + "name": "Admin-Authorization" }, { "description": "Administrative user management operations including CRUD operations, role management, status updates, and profile management for web panel administrators", - "name": "Users" + "name": "Admin-Users" }, { "description": "Administrative customer management operations for web panel including CRUD operations, company assignment, verification, status management, and comprehensive filtering with pagination", - "name": "Customers-Admin" - }, - { - "description": "Customer authentication and authorization operations for mobile application including login, logout, token refresh, and profile access", - "name": "Customers-Authorization" + "name": "Admin-Customers" }, { "description": "Administrative company management operations for web panel including CRUD operations, tag management, verification, status updates, comprehensive search and filtering, and statistical reporting", - "name": "Companies-Admin" + "name": "Admin-Companies" }, { - "description": "Company-related operations for mobile application including company lookup, search, and basic information retrieval", - "name": "Companies-Mobile" + "description": "Customer authentication and authorization operations for mobile application including login, logout, token refresh, and profile access", + "name": "Authorization" } ] } \ No newline at end of file diff --git a/cmd/web/docs/swagger.yaml b/cmd/web/docs/swagger.yaml index bd78d7e..91d967a 100644 --- a/cmd/web/docs/swagger.yaml +++ b/cmd/web/docs/swagger.yaml @@ -511,9 +511,6 @@ definitions: items: type: string type: array - company_name: - description: Company customer fields - type: string contact_person: allOf: - $ref: '#/definitions/customer.ContactPersonForm' @@ -545,6 +542,7 @@ definitions: phone: type: string registration_number: + description: Company customer fields type: string tax_id: type: string @@ -1148,7 +1146,7 @@ paths: - BearerAuth: [] summary: List companies with filters and pagination tags: - - Companies-Admin + - Admin-Companies post: consumes: - application/json @@ -1196,7 +1194,7 @@ paths: - BearerAuth: [] summary: Create a new company tags: - - Companies-Admin + - Admin-Companies /admin/v1/companies/{id}: delete: consumes: @@ -1231,7 +1229,7 @@ paths: - BearerAuth: [] summary: Delete company tags: - - Companies-Admin + - Admin-Companies get: consumes: - application/json @@ -1270,7 +1268,7 @@ paths: - BearerAuth: [] summary: Get company by ID tags: - - Companies-Admin + - Admin-Companies put: consumes: - application/json @@ -1325,7 +1323,7 @@ paths: - BearerAuth: [] summary: Update company information tags: - - Companies-Admin + - Admin-Companies /admin/v1/companies/{id}/activate: post: consumes: @@ -1360,7 +1358,7 @@ paths: - BearerAuth: [] summary: Activate company tags: - - Companies-Admin + - Admin-Companies /admin/v1/companies/{id}/status: patch: consumes: @@ -1405,7 +1403,7 @@ paths: - BearerAuth: [] summary: Update company status tags: - - Companies-Admin + - Admin-Companies /admin/v1/companies/{id}/suspend: post: consumes: @@ -1450,7 +1448,7 @@ paths: - BearerAuth: [] summary: Suspend company tags: - - Companies-Admin + - Admin-Companies /admin/v1/companies/{id}/tags: put: consumes: @@ -1496,7 +1494,7 @@ paths: - BearerAuth: [] summary: Update company tags tags: - - Companies-Admin + - Admin-Companies /admin/v1/companies/{id}/tags/add: post: consumes: @@ -1541,7 +1539,7 @@ paths: - BearerAuth: [] summary: Add tags to company tags: - - Companies-Admin + - Admin-Companies /admin/v1/companies/{id}/tags/remove: post: consumes: @@ -1586,7 +1584,7 @@ paths: - BearerAuth: [] summary: Remove tags from company tags: - - Companies-Admin + - Admin-Companies /admin/v1/companies/{id}/verification: patch: consumes: @@ -1631,7 +1629,7 @@ paths: - BearerAuth: [] summary: Update company verification status tags: - - Companies-Admin + - Admin-Companies /admin/v1/companies/{id}/verify: post: consumes: @@ -1666,7 +1664,7 @@ paths: - BearerAuth: [] summary: Verify company tags: - - Companies-Admin + - Admin-Companies /admin/v1/companies/industry/{industry}: get: consumes: @@ -1719,7 +1717,7 @@ paths: - BearerAuth: [] summary: Get companies by industry tags: - - Companies-Admin + - Admin-Companies /admin/v1/companies/search: get: consumes: @@ -1817,7 +1815,7 @@ paths: - BearerAuth: [] summary: Advanced search for companies tags: - - Companies-Admin + - Admin-Companies /admin/v1/companies/stats: get: consumes: @@ -1843,7 +1841,7 @@ paths: - BearerAuth: [] summary: Get company statistics tags: - - Companies-Admin + - Admin-Companies /admin/v1/companies/status/{status}: get: consumes: @@ -1902,7 +1900,7 @@ paths: - BearerAuth: [] summary: Get companies by status tags: - - Companies-Admin + - Admin-Companies /admin/v1/companies/type/{type}: get: consumes: @@ -1962,7 +1960,7 @@ paths: - BearerAuth: [] summary: Get companies by type tags: - - Companies-Admin + - Admin-Companies /admin/v1/customers: get: consumes: @@ -2077,7 +2075,7 @@ paths: - BearerAuth: [] summary: List customers with filters and pagination tags: - - Customers-Admin + - Admin-Customers post: consumes: - application/json @@ -2124,7 +2122,7 @@ paths: - BearerAuth: [] summary: Create a new customer tags: - - Customers-Admin + - Admin-Customers /admin/v1/customers/{id}: delete: consumes: @@ -2159,7 +2157,7 @@ paths: - BearerAuth: [] summary: Delete customer tags: - - Customers-Admin + - Admin-Customers get: consumes: - application/json @@ -2198,7 +2196,7 @@ paths: - BearerAuth: [] summary: Get customer by ID tags: - - Customers-Admin + - Admin-Customers put: consumes: - application/json @@ -2252,7 +2250,7 @@ paths: - BearerAuth: [] summary: Update customer information tags: - - Customers-Admin + - Admin-Customers /admin/v1/customers/{id}/activate: post: consumes: @@ -2287,7 +2285,7 @@ paths: - BearerAuth: [] summary: Activate customer tags: - - Customers-Admin + - Admin-Customers /admin/v1/customers/{id}/companies/assign: post: consumes: @@ -2332,7 +2330,7 @@ paths: - BearerAuth: [] summary: Assign companies to a customer tags: - - Customers-Admin + - Admin-Customers /admin/v1/customers/{id}/companies/remove: post: consumes: @@ -2377,7 +2375,7 @@ paths: - BearerAuth: [] summary: Remove companies from a customer tags: - - Customers-Admin + - Admin-Customers /admin/v1/customers/{id}/status: patch: consumes: @@ -2422,7 +2420,7 @@ paths: - BearerAuth: [] summary: Update customer status tags: - - Customers-Admin + - Admin-Customers /admin/v1/customers/{id}/suspend: post: consumes: @@ -2467,7 +2465,7 @@ paths: - BearerAuth: [] summary: Suspend customer tags: - - Customers-Admin + - Admin-Customers /admin/v1/customers/{id}/verification: patch: consumes: @@ -2512,7 +2510,7 @@ paths: - BearerAuth: [] summary: Update customer verification status tags: - - Customers-Admin + - Admin-Customers /admin/v1/customers/{id}/verify: post: consumes: @@ -2547,7 +2545,7 @@ paths: - BearerAuth: [] summary: Verify customer tags: - - Customers-Admin + - Admin-Customers /admin/v1/customers/{id}/with-companies: get: consumes: @@ -2588,7 +2586,7 @@ paths: - BearerAuth: [] summary: Get customer by ID with companies tags: - - Customers-Admin + - Admin-Customers /admin/v1/customers/company/{companyId}: get: consumes: @@ -2634,7 +2632,7 @@ paths: - BearerAuth: [] summary: Get customers by company ID tags: - - Customers-Admin + - Admin-Customers /admin/v1/customers/status/{status}: get: consumes: @@ -2693,7 +2691,7 @@ paths: - BearerAuth: [] summary: Get customers by status tags: - - Customers-Admin + - Admin-Customers /admin/v1/customers/type/{type}: get: consumes: @@ -2751,7 +2749,7 @@ paths: - BearerAuth: [] summary: Get customers by type tags: - - Customers-Admin + - Admin-Customers /admin/v1/customers/with-companies: get: consumes: @@ -2866,7 +2864,7 @@ paths: - BearerAuth: [] summary: List customers with companies and filters tags: - - Customers-Admin + - Admin-Customers /admin/v1/health: get: consumes: @@ -2887,7 +2885,7 @@ paths: $ref: '#/definitions/main.HealthResponse' summary: Health check endpoint tags: - - Health + - Admin-Health /admin/v1/profile: get: consumes: @@ -2923,7 +2921,7 @@ paths: - BearerAuth: [] summary: Get authenticated user profile tags: - - Users + - Admin-Users put: consumes: - application/json @@ -2974,7 +2972,7 @@ paths: - BearerAuth: [] summary: Update authenticated user profile tags: - - Users + - Admin-Users /admin/v1/profile/change-password: put: consumes: @@ -3018,7 +3016,7 @@ paths: - BearerAuth: [] summary: Change user password tags: - - Users + - Admin-Users /admin/v1/profile/login: post: consumes: @@ -3067,7 +3065,7 @@ paths: $ref: '#/definitions/response.APIResponse' summary: Authenticate user login tags: - - Authorization + - Admin-Authorization /admin/v1/profile/logout: delete: consumes: @@ -3094,7 +3092,7 @@ paths: - BearerAuth: [] summary: Logout authenticated user tags: - - Authorization + - Admin-Authorization /admin/v1/profile/refresh-token: post: consumes: @@ -3139,7 +3137,7 @@ paths: $ref: '#/definitions/response.APIResponse' summary: Refresh access token tags: - - Authorization + - Admin-Authorization /admin/v1/profile/reset-password: post: consumes: @@ -3183,7 +3181,7 @@ paths: $ref: '#/definitions/response.APIResponse' summary: Initiate password reset process tags: - - Authorization + - Admin-Authorization /admin/v1/users: get: consumes: @@ -3254,7 +3252,7 @@ paths: - BearerAuth: [] summary: List users tags: - - Users + - Admin-Users post: consumes: - application/json @@ -3310,7 +3308,7 @@ paths: - BearerAuth: [] summary: Create new user account tags: - - Users + - Admin-Users /admin/v1/users/{id}: delete: consumes: @@ -3353,7 +3351,7 @@ paths: - BearerAuth: [] summary: Delete user tags: - - Users + - Admin-Users get: consumes: - application/json @@ -3400,7 +3398,7 @@ paths: - BearerAuth: [] summary: Get user by ID tags: - - Users + - Admin-Users put: consumes: - application/json @@ -3453,7 +3451,7 @@ paths: - BearerAuth: [] summary: Update user tags: - - Users + - Admin-Users /admin/v1/users/{id}/role: put: consumes: @@ -3502,7 +3500,7 @@ paths: - BearerAuth: [] summary: Update user role tags: - - Users + - Admin-Users /admin/v1/users/{id}/status: put: consumes: @@ -3551,7 +3549,7 @@ paths: - BearerAuth: [] summary: Update user status tags: - - Users + - Admin-Users /admin/v1/users/company/{company_id}: get: consumes: @@ -3604,7 +3602,7 @@ paths: - BearerAuth: [] summary: Get users by company ID tags: - - Users + - Admin-Users /admin/v1/users/role/{role}: get: consumes: @@ -3657,8 +3655,8 @@ paths: - BearerAuth: [] summary: Get users by role tags: - - Users - /api/v1/: + - Admin-Users + /api/v1/profile: get: consumes: - application/json @@ -3691,32 +3689,7 @@ paths: - BearerAuth: [] summary: Get customer profile tags: - - Customers-Authorization - /api/v1/logout: - delete: - consumes: - - application/json - description: Logout customer and invalidate access token - produces: - - application/json - responses: - "200": - description: Logout successful - schema: - $ref: '#/definitions/response.APIResponse' - "401": - description: Unauthorized - Invalid or missing token - schema: - $ref: '#/definitions/response.APIResponse' - "500": - description: Internal server error - schema: - $ref: '#/definitions/response.APIResponse' - security: - - BearerAuth: [] - summary: Customer logout - tags: - - Customers-Authorization + - Authorization /api/v1/profile/login: post: consumes: @@ -3760,7 +3733,32 @@ paths: $ref: '#/definitions/response.APIResponse' summary: Customer login tags: - - Customers-Authorization + - Authorization + /api/v1/profile/logout: + delete: + consumes: + - application/json + description: Logout customer and invalidate access token + produces: + - application/json + responses: + "200": + description: Logout successful + schema: + $ref: '#/definitions/response.APIResponse' + "401": + description: Unauthorized - Invalid or missing token + schema: + $ref: '#/definitions/response.APIResponse' + "500": + description: Internal server error + schema: + $ref: '#/definitions/response.APIResponse' + security: + - BearerAuth: [] + summary: Customer logout + tags: + - Authorization /api/v1/profile/refresh-token: post: consumes: @@ -3804,8 +3802,8 @@ paths: $ref: '#/definitions/response.APIResponse' summary: Refresh customer access token tags: - - Customers-Authorization - /api/v1/with-companies: + - Authorization + /api/v1/profile/with-companies: get: consumes: - application/json @@ -3839,7 +3837,7 @@ paths: - BearerAuth: [] summary: Get customer profile with companies tags: - - Customers-Authorization + - Authorization securityDefinitions: BearerAuth: description: 'Type "Bearer" followed by a space and JWT token. Example: "Bearer @@ -3851,24 +3849,21 @@ swagger: "2.0" tags: - description: System health check operations for monitoring application status and dependencies - name: Health + name: Admin-Health - description: User authentication and authorization operations including login, logout, token refresh, and password management for web panel administration - name: Authorization + name: Admin-Authorization - description: Administrative user management operations including CRUD operations, role management, status updates, and profile management for web panel administrators - name: Users + name: Admin-Users - description: Administrative customer management operations for web panel including CRUD operations, company assignment, verification, status management, and comprehensive filtering with pagination - name: Customers-Admin -- description: Customer authentication and authorization operations for mobile application - including login, logout, token refresh, and profile access - name: Customers-Authorization + name: Admin-Customers - description: Administrative company management operations for web panel including CRUD operations, tag management, verification, status updates, comprehensive search and filtering, and statistical reporting - name: Companies-Admin -- description: Company-related operations for mobile application including company - lookup, search, and basic information retrieval - name: Companies-Mobile + name: Admin-Companies +- description: Customer authentication and authorization operations for mobile application + including login, logout, token refresh, and profile access + name: Authorization diff --git a/cmd/web/health.go b/cmd/web/health.go index 31fecd3..a31dee7 100644 --- a/cmd/web/health.go +++ b/cmd/web/health.go @@ -9,7 +9,7 @@ import ( // @Summary Health check endpoint // @Description Get comprehensive server health status including system information, dependencies status, and performance metrics. This endpoint is used for monitoring and load balancer health checks. -// @Tags Health +// @Tags Admin-Health // @Accept json // @Produce json // @Success 200 {object} HealthResponse "System is healthy and operational" diff --git a/cmd/web/main.go b/cmd/web/main.go index 253b75f..cf3a2b6 100644 --- a/cmd/web/main.go +++ b/cmd/web/main.go @@ -20,26 +20,23 @@ package main // @name Authorization // @description Type "Bearer" followed by a space and JWT token. Example: "Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..." -// @tag.name Health +// @tag.name Admin-Health // @tag.description System health check operations for monitoring application status and dependencies -// @tag.name Authorization +// @tag.name Admin-Authorization // @tag.description User authentication and authorization operations including login, logout, token refresh, and password management for web panel administration -// @tag.name Users +// @tag.name Admin-Users // @tag.description Administrative user management operations including CRUD operations, role management, status updates, and profile management for web panel administrators -// @tag.name Customers-Admin +// @tag.name Admin-Customers // @tag.description Administrative customer management operations for web panel including CRUD operations, company assignment, verification, status management, and comprehensive filtering with pagination -// @tag.name Customers-Authorization -// @tag.description Customer authentication and authorization operations for mobile application including login, logout, token refresh, and profile access - -// @tag.name Companies-Admin +// @tag.name Admin-Companies // @tag.description Administrative company management operations for web panel including CRUD operations, tag management, verification, status updates, comprehensive search and filtering, and statistical reporting -// @tag.name Companies-Mobile -// @tag.description Company-related operations for mobile application including company lookup, search, and basic information retrieval +// @tag.name Authorization +// @tag.description Customer authentication and authorization operations for mobile application including login, logout, token refresh, and profile access import ( "context" diff --git a/cmd/web/router/routes.go b/cmd/web/router/routes.go index 6aeb0b3..6b74093 100644 --- a/cmd/web/router/routes.go +++ b/cmd/web/router/routes.go @@ -99,7 +99,7 @@ func RegisterPublicRoutes(e *echo.Echo, customerHandler *customer.Handler) { customerGP.POST("/login", customerHandler.Login) customerGP.POST("/refresh-token", customerHandler.RefreshToken) - profileGP := v1.Group("") + profileGP := customerGP.Group("") profileGP.Use(customerHandler.AuthMiddleware()) profileGP.GET("", customerHandler.GetProfile) profileGP.GET("/with-companies", customerHandler.GetProfileWithCompanies) diff --git a/internal/company/handler.go b/internal/company/handler.go index 0ce3eb8..984d468 100644 --- a/internal/company/handler.go +++ b/internal/company/handler.go @@ -28,7 +28,7 @@ func NewHandler(service Service, userHandler *user.Handler, logger logger.Logger // CreateCompany creates a new company (Web Panel) // @Summary Create a new company // @Description Create a new company with comprehensive information including business details, address, tags, and customer assignment. This endpoint is used by the web panel for full company registration. -// @Tags Companies-Admin +// @Tags Admin-Companies // @Accept json // @Produce json // @Param company body CreateCompanyForm true "Company information including type, business details, address, tags, and optional customer assignment" @@ -67,7 +67,7 @@ func (h *Handler) CreateCompany(c echo.Context) error { // GetCompany retrieves a company by ID (Web Panel) // @Summary Get company by ID // @Description Retrieve detailed company information by company ID -// @Tags Companies-Admin +// @Tags Admin-Companies // @Accept json // @Produce json // @Param id path string true "Company ID" @@ -94,7 +94,7 @@ func (h *Handler) GetCompany(c echo.Context) error { // UpdateCompany updates a company (Web Panel) // @Summary Update company information // @Description Update company information including business details, address, tags, and customer assignment -// @Tags Companies-Admin +// @Tags Admin-Companies // @Accept json // @Produce json // @Param id path string true "Company ID" @@ -139,7 +139,7 @@ func (h *Handler) UpdateCompany(c echo.Context) error { // DeleteCompany deletes a company (Web Panel) // @Summary Delete company // @Description Soft delete a company by setting status to inactive -// @Tags Companies-Admin +// @Tags Admin-Companies // @Accept json // @Produce json // @Param id path string true "Company ID" @@ -174,7 +174,7 @@ func (h *Handler) DeleteCompany(c echo.Context) error { // ListCompanies lists companies with filters and pagination (Web Panel) // @Summary List companies with filters and pagination // @Description Retrieve a paginated list of companies with advanced filtering options including search, type, status, industry, verification status, tags, and business criteria. Supports sorting and pagination. -// @Tags Companies-Admin +// @Tags Admin-Companies // @Accept json // @Produce json // @Param search query string false "Search term to filter companies by name, description, or industry" @@ -220,7 +220,7 @@ func (h *Handler) ListCompanies(c echo.Context) error { // SearchCompanies searches companies with advanced filters (Web Panel) // @Summary Advanced search for companies // @Description Search companies with advanced filtering capabilities including tags, business criteria, and location -// @Tags Companies-Admin +// @Tags Admin-Companies // @Accept json // @Produce json // @Param q query string false "Search query" @@ -261,7 +261,7 @@ func (h *Handler) SearchCompanies(c echo.Context) error { // UpdateCompanyStatus updates company status (Web Panel) // @Summary Update company status // @Description Update company account status (active, inactive, suspended, pending) -// @Tags Companies-Admin +// @Tags Admin-Companies // @Accept json // @Produce json // @Param id path string true "Company ID" @@ -302,7 +302,7 @@ func (h *Handler) UpdateCompanyStatus(c echo.Context) error { // UpdateCompanyVerification updates company verification status (Web Panel) // @Summary Update company verification status // @Description Update company verification and compliance status -// @Tags Companies-Admin +// @Tags Admin-Companies // @Accept json // @Produce json // @Param id path string true "Company ID" @@ -343,7 +343,7 @@ func (h *Handler) UpdateCompanyVerification(c echo.Context) error { // UpdateCompanyTags updates company tags (Web Panel) // @Summary Update company tags // @Description Update company tags (CPV, categories, keywords, specializations, certifications) -// @Tags Companies-Admin +// @Tags Admin-Companies // @Accept json // @Produce json // @Param id path string true "Company ID" @@ -384,7 +384,7 @@ func (h *Handler) UpdateCompanyTags(c echo.Context) error { // AddTags adds tags to a company (Web Panel) // @Summary Add tags to company // @Description Add specific tags to a company -// @Tags Companies-Admin +// @Tags Admin-Companies // @Accept json // @Produce json // @Param id path string true "Company ID" @@ -425,7 +425,7 @@ func (h *Handler) AddTags(c echo.Context) error { // RemoveTags removes tags from a company (Web Panel) // @Summary Remove tags from company // @Description Remove specific tags from a company -// @Tags Companies-Admin +// @Tags Admin-Companies // @Accept json // @Produce json // @Param id path string true "Company ID" @@ -466,7 +466,7 @@ func (h *Handler) RemoveTags(c echo.Context) error { // VerifyCompany verifies a company (Web Panel) // @Summary Verify company // @Description Mark a company as verified -// @Tags Companies-Admin +// @Tags Admin-Companies // @Accept json // @Produce json // @Param id path string true "Company ID" @@ -501,7 +501,7 @@ func (h *Handler) VerifyCompany(c echo.Context) error { // SuspendCompany suspends a company (Web Panel) // @Summary Suspend company // @Description Suspend a company account with reason -// @Tags Companies-Admin +// @Tags Admin-Companies // @Accept json // @Produce json // @Param id path string true "Company ID" @@ -542,7 +542,7 @@ func (h *Handler) SuspendCompany(c echo.Context) error { // ActivateCompany activates a company (Web Panel) // @Summary Activate company // @Description Activate a suspended company account -// @Tags Companies-Admin +// @Tags Admin-Companies // @Accept json // @Produce json // @Param id path string true "Company ID" @@ -577,7 +577,7 @@ func (h *Handler) ActivateCompany(c echo.Context) error { // GetCompanyStats returns company statistics (Web Panel) // @Summary Get company statistics // @Description Get comprehensive company statistics for dashboard -// @Tags Companies-Admin +// @Tags Admin-Companies // @Accept json // @Produce json // @Success 200 {object} response.APIResponse{data=CompanyStatsResponse} "Company statistics retrieved successfully" @@ -596,7 +596,7 @@ func (h *Handler) GetCompanyStats(c echo.Context) error { // GetCompaniesByType retrieves companies by type (Web Panel) // @Summary Get companies by type // @Description Retrieve companies filtered by their type (private, public, government, ngo, startup) -// @Tags Companies-Admin +// @Tags Admin-Companies // @Accept json // @Produce json // @Param type path string true "Company type" Enums(private, public, government, ngo, startup) @@ -654,7 +654,7 @@ func (h *Handler) GetCompaniesByType(c echo.Context) error { // GetCompaniesByStatus retrieves companies by status (Web Panel) // @Summary Get companies by status // @Description Retrieve companies filtered by their status (active, inactive, suspended, pending) -// @Tags Companies-Admin +// @Tags Admin-Companies // @Accept json // @Produce json // @Param status path string true "Company status" Enums(active, inactive, suspended, pending) @@ -711,7 +711,7 @@ func (h *Handler) GetCompaniesByStatus(c echo.Context) error { // GetCompaniesByIndustry retrieves companies by industry (Web Panel) // @Summary Get companies by industry // @Description Retrieve companies filtered by their industry -// @Tags Companies-Admin +// @Tags Admin-Companies // @Accept json // @Produce json // @Param industry path string true "Industry" diff --git a/internal/customer/form.go b/internal/customer/form.go index c5bb5a6..09b29f8 100644 --- a/internal/customer/form.go +++ b/internal/customer/form.go @@ -18,7 +18,6 @@ type CreateCustomerForm struct { Mobile *string `json:"mobile,omitempty" valid:"optional,length(10|20)"` // Company customer fields - CompanyName *string `json:"company_name,omitempty" valid:"optional,length(2|200)"` RegistrationNumber *string `json:"registration_number,omitempty" valid:"optional,length(5|50)"` TaxID *string `json:"tax_id,omitempty" valid:"optional,length(5|50)"` Industry *string `json:"industry,omitempty" valid:"optional,length(2|100)"` diff --git a/internal/customer/handler.go b/internal/customer/handler.go index ce312f8..e9bf648 100644 --- a/internal/customer/handler.go +++ b/internal/customer/handler.go @@ -31,7 +31,7 @@ func NewHandler(service Service, userHandler *user.Handler, authService authoriz // CreateCustomer creates a new customer (Web Panel) // @Summary Create a new customer // @Description Create a new customer with comprehensive information including personal details, company information, address, and business details. This endpoint is used by the web panel for full customer registration. -// @Tags Customers-Admin +// @Tags Admin-Customers // @Accept json // @Produce json // @Param customer body CreateCustomerForm true "Customer information including type (individual|company|government), personal details, company info, address, and business details" @@ -71,7 +71,7 @@ func (h *Handler) CreateCustomer(c echo.Context) error { // GetCustomerByID retrieves a customer by ID (Web Panel) // @Summary Get customer by ID // @Description Retrieve detailed customer information by customer ID -// @Tags Customers-Admin +// @Tags Admin-Customers // @Accept json // @Produce json // @Param id path string true "Customer ID" @@ -98,7 +98,7 @@ func (h *Handler) GetCustomerByID(c echo.Context) error { // GetCustomerByIDWithCompanies retrieves a customer by ID with companies (Web Panel) // @Summary Get customer by ID with companies // @Description Retrieve detailed customer information by customer ID including assigned companies -// @Tags Customers-Admin +// @Tags Admin-Customers // @Accept json // @Produce json // @Param id path string true "Customer ID" @@ -125,7 +125,7 @@ func (h *Handler) GetCustomerByIDWithCompanies(c echo.Context) error { // UpdateCustomer updates a customer (Web Panel) // @Summary Update customer information // @Description Update customer information including personal details, company information, address, and business details -// @Tags Customers-Admin +// @Tags Admin-Customers // @Accept json // @Produce json // @Param id path string true "Customer ID" @@ -171,7 +171,7 @@ func (h *Handler) UpdateCustomer(c echo.Context) error { // DeleteCustomer deletes a customer (Web Panel) // @Summary Delete customer // @Description Soft delete a customer by setting status to inactive -// @Tags Customers-Admin +// @Tags Admin-Customers // @Accept json // @Produce json // @Param id path string true "Customer ID" @@ -206,7 +206,7 @@ func (h *Handler) DeleteCustomer(c echo.Context) error { // ListCustomers lists customers with filters and pagination // @Summary List customers with filters and pagination // @Description Retrieve a paginated list of customers with advanced filtering options including search, type, status, company, industry, verification status, and compliance status. Supports sorting and pagination. -// @Tags Customers-Admin +// @Tags Admin-Customers // @Accept json // @Produce json // @Param search query string false "Search term to filter customers by name, email, or company name" @@ -245,7 +245,7 @@ func (h *Handler) ListCustomers(c echo.Context) error { // ListCustomersWithCompanies lists customers with companies and filters // @Summary List customers with companies and filters // @Description Retrieve a paginated list of customers with their assigned companies and advanced filtering options including search, type, status, company, industry, verification status, and compliance status. Supports sorting and pagination. -// @Tags Customers-Admin +// @Tags Admin-Customers // @Accept json // @Produce json // @Param search query string false "Search term to filter customers by name, email, or company name" @@ -284,7 +284,7 @@ func (h *Handler) ListCustomersWithCompanies(c echo.Context) error { // UpdateCustomerStatus updates customer status (Web Panel) // @Summary Update customer status // @Description Update customer account status (active, inactive, suspended, pending) -// @Tags Customers-Admin +// @Tags Admin-Customers // @Accept json // @Produce json // @Param id path string true "Customer ID" @@ -325,7 +325,7 @@ func (h *Handler) UpdateCustomerStatus(c echo.Context) error { // UpdateCustomerVerification updates customer verification status (Web Panel) // @Summary Update customer verification status // @Description Update customer verification and compliance status -// @Tags Customers-Admin +// @Tags Admin-Customers // @Accept json // @Produce json // @Param id path string true "Customer ID" @@ -366,7 +366,7 @@ func (h *Handler) UpdateCustomerVerification(c echo.Context) error { // VerifyCustomer verifies a customer (Web Panel) // @Summary Verify customer // @Description Mark a customer as verified -// @Tags Customers-Admin +// @Tags Admin-Customers // @Accept json // @Produce json // @Param id path string true "Customer ID" @@ -401,7 +401,7 @@ func (h *Handler) VerifyCustomer(c echo.Context) error { // SuspendCustomer suspends a customer (Web Panel) // @Summary Suspend customer // @Description Suspend a customer account with optional reason -// @Tags Customers-Admin +// @Tags Admin-Customers // @Accept json // @Produce json // @Param id path string true "Customer ID" @@ -442,7 +442,7 @@ func (h *Handler) SuspendCustomer(c echo.Context) error { // ActivateCustomer activates a customer (Web Panel) // @Summary Activate customer // @Description Activate a suspended customer account -// @Tags Customers-Admin +// @Tags Admin-Customers // @Accept json // @Produce json // @Param id path string true "Customer ID" @@ -477,7 +477,7 @@ func (h *Handler) ActivateCustomer(c echo.Context) error { // GetCustomersByCompanyID retrieves customers by company ID (Web Panel) // @Summary Get customers by company ID // @Description Retrieve all customers associated with a specific company -// @Tags Customers-Admin +// @Tags Admin-Customers // @Accept json // @Produce json // @Param companyId path string true "Company ID" @@ -529,7 +529,7 @@ func (h *Handler) GetCustomersByCompanyID(c echo.Context) error { // GetCustomersByType retrieves customers by type // @Summary Get customers by type // @Description Retrieve customers filtered by their type (individual, company, or government). Useful for administrative reporting and management. -// @Tags Customers-Admin +// @Tags Admin-Customers // @Accept json // @Produce json // @Param type path string true "Customer type" Enums(individual, company, government) @@ -585,7 +585,7 @@ func (h *Handler) GetCustomersByType(c echo.Context) error { // GetCustomersByStatus retrieves customers by status // @Summary Get customers by status // @Description Retrieve customers filtered by their account status (active, inactive, suspended, or pending). Useful for administrative monitoring and management. -// @Tags Customers-Admin +// @Tags Admin-Customers // @Accept json // @Produce json // @Param status path string true "Customer status" Enums(active, inactive, suspended, pending) @@ -641,7 +641,7 @@ func (h *Handler) GetCustomersByStatus(c echo.Context) error { // AssignCompaniesToCustomer assigns companies to a customer (Web Panel) // @Summary Assign companies to a customer // @Description Assign one or more companies to a specific customer. -// @Tags Customers-Admin +// @Tags Admin-Customers // @Accept json // @Produce json // @Param id path string true "Customer ID" @@ -682,7 +682,7 @@ func (h *Handler) AssignCompaniesToCustomer(c echo.Context) error { // RemoveCompaniesFromCustomer removes companies from a customer (Web Panel) // @Summary Remove companies from a customer // @Description Remove one or more companies from a specific customer. -// @Tags Customers-Admin +// @Tags Admin-Customers // @Accept json // @Produce json // @Param id path string true "Customer ID" @@ -723,7 +723,7 @@ func (h *Handler) RemoveCompaniesFromCustomer(c echo.Context) error { // Login handles customer authentication // @Summary Customer login // @Description Authenticate customer with username (email) and password. Returns access token, refresh token, and customer information upon successful authentication. -// @Tags Customers-Authorization +// @Tags Authorization // @Accept json // @Produce json // @Param login body LoginForm true "Login credentials (username/email and password)" @@ -757,7 +757,7 @@ func (h *Handler) Login(c echo.Context) error { // RefreshToken handles customer token refresh // @Summary Refresh customer access token // @Description Refresh access token using a valid refresh token. This allows customers to maintain their session without re-authentication. -// @Tags Customers-Authorization +// @Tags Authorization // @Accept json // @Produce json // @Param refresh body RefreshTokenForm true "Refresh token for generating new access token" @@ -788,7 +788,7 @@ func (h *Handler) RefreshToken(c echo.Context) error { // GetProfile retrieves customer profile information (Mobile) // @Summary Get customer profile // @Description Retrieve current customer profile information -// @Tags Customers-Authorization +// @Tags Authorization // @Accept json // @Produce json // @Security BearerAuth @@ -796,7 +796,7 @@ func (h *Handler) RefreshToken(c echo.Context) error { // @Failure 401 {object} response.APIResponse "Unauthorized - Invalid or missing token" // @Failure 404 {object} response.APIResponse "Not found - Customer not found" // @Failure 500 {object} response.APIResponse "Internal server error" -// @Router /api/v1/ [get] +// @Router /api/v1/profile [get] func (h *Handler) GetProfile(c echo.Context) error { // Extract customer ID from JWT token context customerID, err := GetCustomerIDFromContext(c) @@ -818,7 +818,7 @@ func (h *Handler) GetProfile(c echo.Context) error { // GetProfileWithCompanies retrieves customer profile with companies (Mobile) // @Summary Get customer profile with companies // @Description Retrieve current customer profile information along with their assigned companies. -// @Tags Customers-Authorization +// @Tags Authorization // @Accept json // @Produce json // @Security BearerAuth @@ -826,7 +826,7 @@ func (h *Handler) GetProfile(c echo.Context) error { // @Failure 401 {object} response.APIResponse "Unauthorized - Invalid or missing token" // @Failure 404 {object} response.APIResponse "Not found - Customer not found" // @Failure 500 {object} response.APIResponse "Internal server error" -// @Router /api/v1/with-companies [get] +// @Router /api/v1/profile/with-companies [get] func (h *Handler) GetProfileWithCompanies(c echo.Context) error { // Extract customer ID from JWT token context customerID, err := GetCustomerIDFromContext(c) @@ -848,14 +848,14 @@ func (h *Handler) GetProfileWithCompanies(c echo.Context) error { // Logout handles customer logout (Mobile) // @Summary Customer logout // @Description Logout customer and invalidate access token -// @Tags Customers-Authorization +// @Tags Authorization // @Accept json // @Produce json // @Security BearerAuth // @Success 200 {object} response.APIResponse "Logout successful" // @Failure 401 {object} response.APIResponse "Unauthorized - Invalid or missing token" // @Failure 500 {object} response.APIResponse "Internal server error" -// @Router /api/v1/logout [delete] +// @Router /api/v1/profile/logout [delete] func (h *Handler) Logout(c echo.Context) error { // Extract customer ID from JWT token context customerID, err := GetCustomerIDFromContext(c) diff --git a/internal/customer/service.go b/internal/customer/service.go index ec96291..381814b 100644 --- a/internal/customer/service.go +++ b/internal/customer/service.go @@ -81,14 +81,6 @@ func (s *customerService) CreateCustomer(ctx context.Context, form *CreateCustom return nil, errors.New("customer with this email already exists") } - // Check if company name already exists (for company customers) - if form.Type == string(CustomerTypeCompany) && form.CompanyName != nil { - existingCustomer, _ = s.repository.GetByCompanyName(ctx, *form.CompanyName) - if existingCustomer != nil { - return nil, errors.New("company with this name already exists") - } - } - // Check if registration number already exists (for company customers) if form.Type == string(CustomerTypeCompany) && form.RegistrationNumber != nil { existingCustomer, _ = s.repository.GetByRegistrationNumber(ctx, *form.RegistrationNumber) diff --git a/internal/user/handler.go b/internal/user/handler.go index f6310f1..04d3bbe 100644 --- a/internal/user/handler.go +++ b/internal/user/handler.go @@ -31,7 +31,7 @@ func NewUserHandler(service Service, logger logger.Logger, validator ValidationS // Login handles user login // @Summary Authenticate user login // @Description Authenticate user with username/email and password to obtain access and refresh tokens for web panel administration. This endpoint validates credentials and returns JWT tokens for subsequent API calls. -// @Tags Authorization +// @Tags Admin-Authorization // @Accept json // @Produce json // @Param login body LoginForm true "User login credentials including username/email and password" @@ -60,7 +60,7 @@ func (h *Handler) Login(c echo.Context) error { // RefreshToken handles token refresh // @Summary Refresh access token // @Description Generate a new access token using a valid refresh token. This endpoint allows clients to obtain fresh access tokens without re-authentication, maintaining session continuity. -// @Tags Authorization +// @Tags Admin-Authorization // @Accept json // @Produce json // @Param refresh body RefreshTokenForm true "Refresh token for generating new access token" @@ -87,7 +87,7 @@ func (h *Handler) RefreshToken(c echo.Context) error { // ResetPassword handles password reset request // @Summary Initiate password reset process // @Description Send password reset email to user with reset token. This endpoint validates the email address and sends a secure reset link to the user's registered email address. -// @Tags Authorization +// @Tags Admin-Authorization // @Accept json // @Produce json // @Param reset body ResetPasswordForm true "Email address for password reset request" @@ -117,7 +117,7 @@ func (h *Handler) ResetPassword(c echo.Context) error { // GetProfile gets current user profile // @Summary Get authenticated user profile // @Description Retrieve complete profile information for the currently authenticated user including personal details, role information, permissions, and account status. This endpoint requires valid authentication token. -// @Tags Users +// @Tags Admin-Users // @Accept json // @Produce json // @Security BearerAuth @@ -144,7 +144,7 @@ func (h *Handler) GetProfile(c echo.Context) error { // UpdateProfile updates current user profile // @Summary Update authenticated user profile // @Description Update profile information for the currently authenticated user including personal details, contact information, and preferences. Only the authenticated user can update their own profile. -// @Tags Users +// @Tags Admin-Users // @Accept json // @Produce json // @Security BearerAuth @@ -179,7 +179,7 @@ func (h *Handler) UpdateProfile(c echo.Context) error { // ChangePassword changes current user password // @Summary Change user password // @Description Change password for the currently authenticated user. Requires current password verification and enforces password policy. This operation invalidates all existing sessions and requires re-authentication. -// @Tags Users +// @Tags Admin-Users // @Accept json // @Produce json // @Security BearerAuth @@ -214,7 +214,7 @@ func (h *Handler) ChangePassword(c echo.Context) error { // Logout handles user logout // @Summary Logout authenticated user // @Description Logout the currently authenticated user by invalidating their access and refresh tokens. This endpoint ensures secure session termination and prevents further use of the user's tokens. -// @Tags Authorization +// @Tags Admin-Authorization // @Accept json // @Produce json // @Security BearerAuth @@ -247,7 +247,7 @@ func (h *Handler) Logout(c echo.Context) error { // CreateUser creates a new user (admin only) // @Summary Create new user account // @Description Create a new user account with specified role and permissions. This endpoint is restricted to administrators only and allows creation of various user types including admins, managers, and operators with appropriate access levels. -// @Tags Users +// @Tags Admin-Users // @Accept json // @Produce json // @Security BearerAuth @@ -289,7 +289,7 @@ func (h *Handler) CreateUser(c echo.Context) error { // ListUsers lists users with search and filters (admin only) // @Summary List users // @Description List users with search and filters (admin only) -// @Tags Users +// @Tags Admin-Users // @Accept json // @Produce json // @Security BearerAuth @@ -330,7 +330,7 @@ func (h *Handler) ListUsers(c echo.Context) error { // GetUserByID gets a user by ID (admin only) // @Summary Get user by ID // @Description Get user details by ID (admin only) -// @Tags Users +// @Tags Admin-Users // @Accept json // @Produce json // @Security BearerAuth @@ -356,7 +356,7 @@ func (h *Handler) GetUserByID(c echo.Context) error { // UpdateUser updates a user (admin only) // @Summary Update user // @Description Update user information (admin only) -// @Tags Users +// @Tags Admin-Users // @Accept json // @Produce json // @Security BearerAuth @@ -400,7 +400,7 @@ func (h *Handler) UpdateUser(c echo.Context) error { // DeleteUser deletes a user (admin only) // @Summary Delete user // @Description Delete a user (admin only) -// @Tags Users +// @Tags Admin-Users // @Accept json // @Produce json // @Security BearerAuth @@ -434,7 +434,7 @@ func (h *Handler) DeleteUser(c echo.Context) error { // UpdateUserStatus updates user status (admin only) // @Summary Update user status // @Description Update user account status (admin only) -// @Tags Users +// @Tags Admin-Users // @Accept json // @Produce json // @Security BearerAuth @@ -479,7 +479,7 @@ func (h *Handler) UpdateUserStatus(c echo.Context) error { // UpdateUserRole updates user role (admin only) // @Summary Update user role // @Description Update user role (admin only) -// @Tags Users +// @Tags Admin-Users // @Accept json // @Produce json // @Security BearerAuth @@ -525,7 +525,7 @@ func (h *Handler) UpdateUserRole(c echo.Context) error { // GetUsersByCompanyID gets users by company ID (admin only) // @Summary Get users by company ID // @Description Get users belonging to a specific company (admin only) -// @Tags Users +// @Tags Admin-Users // @Accept json // @Produce json // @Security BearerAuth @@ -585,7 +585,7 @@ func (h *Handler) GetUsersByCompanyID(c echo.Context) error { // GetUsersByRole gets users by role (admin only) // @Summary Get users by role // @Description Get users with a specific role (admin only) -// @Tags Users +// @Tags Admin-Users // @Accept json // @Produce json // @Security BearerAuth