Refactor customer domain by removing obsolete files and updating main application structure
- Deleted customer domain files including entities, services, handlers, and forms to streamline the codebase. - Removed customer-related routes and service initializations from the main application. - Updated Swagger documentation to reflect the removal of customer endpoints and definitions. - Cleaned up the project structure to enhance maintainability and focus on user management functionality.
This commit is contained in:
+2
-1053
File diff suppressed because it is too large
Load Diff
+2
-1053
File diff suppressed because it is too large
Load Diff
+2
-657
@@ -1,154 +1,5 @@
|
||||
basePath: /api/v1
|
||||
definitions:
|
||||
customer.AddDeviceTokenForm:
|
||||
properties:
|
||||
device_token:
|
||||
type: string
|
||||
device_type:
|
||||
type: string
|
||||
type: object
|
||||
customer.AuthResponse:
|
||||
properties:
|
||||
access_token:
|
||||
type: string
|
||||
customer:
|
||||
$ref: '#/definitions/customer.CustomerResponse'
|
||||
expires_at:
|
||||
type: integer
|
||||
refresh_token:
|
||||
type: string
|
||||
type: object
|
||||
customer.ChangePasswordForm:
|
||||
properties:
|
||||
new_password:
|
||||
type: string
|
||||
old_password:
|
||||
type: string
|
||||
type: object
|
||||
customer.CustomerResponse:
|
||||
properties:
|
||||
birthdate:
|
||||
type: integer
|
||||
company_id:
|
||||
type: string
|
||||
created_at:
|
||||
type: integer
|
||||
device_tokens:
|
||||
items:
|
||||
$ref: '#/definitions/customer.DeviceToken'
|
||||
type: array
|
||||
email:
|
||||
type: string
|
||||
full_name:
|
||||
type: string
|
||||
gender:
|
||||
type: string
|
||||
id:
|
||||
type: string
|
||||
is_verified:
|
||||
type: boolean
|
||||
last_login_at:
|
||||
type: integer
|
||||
mobile:
|
||||
type: string
|
||||
national_id:
|
||||
type: string
|
||||
profile_image:
|
||||
type: string
|
||||
status:
|
||||
type: string
|
||||
updated_at:
|
||||
type: integer
|
||||
username:
|
||||
type: string
|
||||
type: object
|
||||
customer.DeviceToken:
|
||||
properties:
|
||||
createdAt:
|
||||
description: Unix timestamp
|
||||
type: integer
|
||||
deviceType:
|
||||
$ref: '#/definitions/customer.DeviceType'
|
||||
token:
|
||||
type: string
|
||||
updatedAt:
|
||||
description: Unix timestamp
|
||||
type: integer
|
||||
type: object
|
||||
customer.DeviceType:
|
||||
enum:
|
||||
- android
|
||||
- ios
|
||||
type: string
|
||||
x-enum-varnames:
|
||||
- DeviceTypeAndroid
|
||||
- DeviceTypeIOS
|
||||
customer.LoginForm:
|
||||
properties:
|
||||
email_or_mobile:
|
||||
type: string
|
||||
password:
|
||||
type: string
|
||||
type: object
|
||||
customer.RefreshTokenForm:
|
||||
properties:
|
||||
refresh_token:
|
||||
type: string
|
||||
type: object
|
||||
customer.RegisterCustomerForm:
|
||||
properties:
|
||||
birthdate:
|
||||
type: integer
|
||||
company_id:
|
||||
type: string
|
||||
email:
|
||||
type: string
|
||||
full_name:
|
||||
type: string
|
||||
gender:
|
||||
type: string
|
||||
mobile:
|
||||
type: string
|
||||
national_id:
|
||||
type: string
|
||||
password:
|
||||
type: string
|
||||
profile_image:
|
||||
type: string
|
||||
username:
|
||||
type: string
|
||||
type: object
|
||||
customer.RemoveDeviceTokenForm:
|
||||
properties:
|
||||
device_token:
|
||||
type: string
|
||||
type: object
|
||||
customer.UpdateCustomerForm:
|
||||
properties:
|
||||
birthdate:
|
||||
type: integer
|
||||
email:
|
||||
type: string
|
||||
full_name:
|
||||
type: string
|
||||
gender:
|
||||
type: string
|
||||
mobile:
|
||||
type: string
|
||||
national_id:
|
||||
type: string
|
||||
profile_image:
|
||||
type: string
|
||||
status:
|
||||
type: string
|
||||
username:
|
||||
type: string
|
||||
type: object
|
||||
customer.UpdateCustomerStatusForm:
|
||||
properties:
|
||||
status:
|
||||
type: string
|
||||
type: object
|
||||
response.APIError:
|
||||
properties:
|
||||
code:
|
||||
@@ -226,10 +77,10 @@ definitions:
|
||||
type: object
|
||||
user.LoginForm:
|
||||
properties:
|
||||
email_or_username:
|
||||
type: string
|
||||
password:
|
||||
type: string
|
||||
username:
|
||||
type: string
|
||||
type: object
|
||||
user.RefreshTokenForm:
|
||||
properties:
|
||||
@@ -340,512 +191,6 @@ info:
|
||||
title: Tender Management API
|
||||
version: 1.0.0
|
||||
paths:
|
||||
/admin/customers:
|
||||
get:
|
||||
consumes:
|
||||
- application/json
|
||||
description: Retrieve a paginated list of customers (admin only)
|
||||
parameters:
|
||||
- default: 1
|
||||
description: Page number
|
||||
in: query
|
||||
name: page
|
||||
type: integer
|
||||
- default: 20
|
||||
description: Number of items per page
|
||||
in: query
|
||||
name: limit
|
||||
type: integer
|
||||
- description: Search term
|
||||
in: query
|
||||
name: search
|
||||
type: string
|
||||
produces:
|
||||
- application/json
|
||||
responses:
|
||||
"200":
|
||||
description: Customers retrieved successfully
|
||||
schema:
|
||||
allOf:
|
||||
- $ref: '#/definitions/response.APIResponse'
|
||||
- properties:
|
||||
data:
|
||||
items:
|
||||
$ref: '#/definitions/customer.CustomerResponse'
|
||||
type: array
|
||||
type: object
|
||||
"400":
|
||||
description: Bad request
|
||||
schema:
|
||||
$ref: '#/definitions/response.APIResponse'
|
||||
"401":
|
||||
description: Unauthorized
|
||||
schema:
|
||||
$ref: '#/definitions/response.APIResponse'
|
||||
"500":
|
||||
description: Internal server error
|
||||
schema:
|
||||
$ref: '#/definitions/response.APIResponse'
|
||||
security:
|
||||
- BearerAuth: []
|
||||
summary: List customers
|
||||
tags:
|
||||
- customers
|
||||
/admin/customers/{id}:
|
||||
get:
|
||||
consumes:
|
||||
- application/json
|
||||
description: Retrieve customer information by ID (admin only)
|
||||
parameters:
|
||||
- description: Customer ID
|
||||
in: path
|
||||
name: id
|
||||
required: true
|
||||
type: string
|
||||
produces:
|
||||
- application/json
|
||||
responses:
|
||||
"200":
|
||||
description: Customer retrieved successfully
|
||||
schema:
|
||||
allOf:
|
||||
- $ref: '#/definitions/response.APIResponse'
|
||||
- properties:
|
||||
data:
|
||||
$ref: '#/definitions/customer.CustomerResponse'
|
||||
type: object
|
||||
"400":
|
||||
description: Bad request
|
||||
schema:
|
||||
$ref: '#/definitions/response.APIResponse'
|
||||
"401":
|
||||
description: Unauthorized
|
||||
schema:
|
||||
$ref: '#/definitions/response.APIResponse'
|
||||
"404":
|
||||
description: Customer not found
|
||||
schema:
|
||||
$ref: '#/definitions/response.APIResponse'
|
||||
"500":
|
||||
description: Internal server error
|
||||
schema:
|
||||
$ref: '#/definitions/response.APIResponse'
|
||||
security:
|
||||
- BearerAuth: []
|
||||
summary: Get customer by ID
|
||||
tags:
|
||||
- customers
|
||||
/admin/customers/{id}/status:
|
||||
put:
|
||||
consumes:
|
||||
- application/json
|
||||
description: Update customer status (admin only)
|
||||
parameters:
|
||||
- description: Customer ID
|
||||
in: path
|
||||
name: id
|
||||
required: true
|
||||
type: string
|
||||
- description: Status update information
|
||||
in: body
|
||||
name: status
|
||||
required: true
|
||||
schema:
|
||||
$ref: '#/definitions/customer.UpdateCustomerStatusForm'
|
||||
produces:
|
||||
- application/json
|
||||
responses:
|
||||
"200":
|
||||
description: Customer status updated successfully
|
||||
schema:
|
||||
$ref: '#/definitions/response.APIResponse'
|
||||
"400":
|
||||
description: Bad request
|
||||
schema:
|
||||
$ref: '#/definitions/response.APIResponse'
|
||||
"401":
|
||||
description: Unauthorized
|
||||
schema:
|
||||
$ref: '#/definitions/response.APIResponse'
|
||||
"404":
|
||||
description: Customer not found
|
||||
schema:
|
||||
$ref: '#/definitions/response.APIResponse'
|
||||
"500":
|
||||
description: Internal server error
|
||||
schema:
|
||||
$ref: '#/definitions/response.APIResponse'
|
||||
security:
|
||||
- BearerAuth: []
|
||||
summary: Update customer status
|
||||
tags:
|
||||
- customers
|
||||
/admin/customers/device-tokens:
|
||||
get:
|
||||
consumes:
|
||||
- application/json
|
||||
description: Retrieve all device tokens (admin only)
|
||||
produces:
|
||||
- application/json
|
||||
responses:
|
||||
"200":
|
||||
description: Device tokens retrieved successfully
|
||||
schema:
|
||||
allOf:
|
||||
- $ref: '#/definitions/response.APIResponse'
|
||||
- properties:
|
||||
data:
|
||||
items:
|
||||
type: string
|
||||
type: array
|
||||
type: object
|
||||
"401":
|
||||
description: Unauthorized
|
||||
schema:
|
||||
$ref: '#/definitions/response.APIResponse'
|
||||
"500":
|
||||
description: Internal server error
|
||||
schema:
|
||||
$ref: '#/definitions/response.APIResponse'
|
||||
security:
|
||||
- BearerAuth: []
|
||||
summary: Get all device tokens
|
||||
tags:
|
||||
- customers
|
||||
/admin/customers/register:
|
||||
post:
|
||||
consumes:
|
||||
- application/json
|
||||
description: Register a new customer with the provided information
|
||||
parameters:
|
||||
- description: Customer registration information
|
||||
in: body
|
||||
name: customer
|
||||
required: true
|
||||
schema:
|
||||
$ref: '#/definitions/customer.RegisterCustomerForm'
|
||||
produces:
|
||||
- application/json
|
||||
responses:
|
||||
"201":
|
||||
description: Customer registered successfully
|
||||
schema:
|
||||
allOf:
|
||||
- $ref: '#/definitions/response.APIResponse'
|
||||
- properties:
|
||||
data:
|
||||
$ref: '#/definitions/customer.CustomerResponse'
|
||||
type: object
|
||||
"400":
|
||||
description: Bad request
|
||||
schema:
|
||||
$ref: '#/definitions/response.APIResponse'
|
||||
"409":
|
||||
description: Customer already exists
|
||||
schema:
|
||||
$ref: '#/definitions/response.APIResponse'
|
||||
"500":
|
||||
description: Internal server error
|
||||
schema:
|
||||
$ref: '#/definitions/response.APIResponse'
|
||||
summary: Register a new customer
|
||||
tags:
|
||||
- customers
|
||||
/customers/change-password:
|
||||
put:
|
||||
consumes:
|
||||
- application/json
|
||||
description: Change the authenticated customer's password
|
||||
parameters:
|
||||
- description: Password change information
|
||||
in: body
|
||||
name: password
|
||||
required: true
|
||||
schema:
|
||||
$ref: '#/definitions/customer.ChangePasswordForm'
|
||||
produces:
|
||||
- application/json
|
||||
responses:
|
||||
"200":
|
||||
description: Password changed successfully
|
||||
schema:
|
||||
$ref: '#/definitions/response.APIResponse'
|
||||
"400":
|
||||
description: Bad request
|
||||
schema:
|
||||
$ref: '#/definitions/response.APIResponse'
|
||||
"401":
|
||||
description: Unauthorized
|
||||
schema:
|
||||
$ref: '#/definitions/response.APIResponse'
|
||||
"500":
|
||||
description: Internal server error
|
||||
schema:
|
||||
$ref: '#/definitions/response.APIResponse'
|
||||
security:
|
||||
- BearerAuth: []
|
||||
summary: Change customer password
|
||||
tags:
|
||||
- customers
|
||||
/customers/device-token:
|
||||
delete:
|
||||
consumes:
|
||||
- application/json
|
||||
description: Remove a device token for push notifications
|
||||
parameters:
|
||||
- description: Device token information
|
||||
in: body
|
||||
name: device_token
|
||||
required: true
|
||||
schema:
|
||||
$ref: '#/definitions/customer.RemoveDeviceTokenForm'
|
||||
produces:
|
||||
- application/json
|
||||
responses:
|
||||
"200":
|
||||
description: Device token removed successfully
|
||||
schema:
|
||||
$ref: '#/definitions/response.APIResponse'
|
||||
"400":
|
||||
description: Bad request
|
||||
schema:
|
||||
$ref: '#/definitions/response.APIResponse'
|
||||
"401":
|
||||
description: Unauthorized
|
||||
schema:
|
||||
$ref: '#/definitions/response.APIResponse'
|
||||
"500":
|
||||
description: Internal server error
|
||||
schema:
|
||||
$ref: '#/definitions/response.APIResponse'
|
||||
security:
|
||||
- BearerAuth: []
|
||||
summary: Remove device token
|
||||
tags:
|
||||
- customers
|
||||
post:
|
||||
consumes:
|
||||
- application/json
|
||||
description: Add a device token for push notifications
|
||||
parameters:
|
||||
- description: Device token information
|
||||
in: body
|
||||
name: device_token
|
||||
required: true
|
||||
schema:
|
||||
$ref: '#/definitions/customer.AddDeviceTokenForm'
|
||||
produces:
|
||||
- application/json
|
||||
responses:
|
||||
"200":
|
||||
description: Device token added successfully
|
||||
schema:
|
||||
$ref: '#/definitions/response.APIResponse'
|
||||
"400":
|
||||
description: Bad request
|
||||
schema:
|
||||
$ref: '#/definitions/response.APIResponse'
|
||||
"401":
|
||||
description: Unauthorized
|
||||
schema:
|
||||
$ref: '#/definitions/response.APIResponse'
|
||||
"500":
|
||||
description: Internal server error
|
||||
schema:
|
||||
$ref: '#/definitions/response.APIResponse'
|
||||
security:
|
||||
- BearerAuth: []
|
||||
summary: Add device token
|
||||
tags:
|
||||
- customers
|
||||
/customers/login:
|
||||
post:
|
||||
consumes:
|
||||
- application/json
|
||||
description: Authenticate customer with email and password
|
||||
parameters:
|
||||
- description: Login credentials
|
||||
in: body
|
||||
name: credentials
|
||||
required: true
|
||||
schema:
|
||||
$ref: '#/definitions/customer.LoginForm'
|
||||
produces:
|
||||
- application/json
|
||||
responses:
|
||||
"200":
|
||||
description: Login successful
|
||||
schema:
|
||||
allOf:
|
||||
- $ref: '#/definitions/response.APIResponse'
|
||||
- properties:
|
||||
data:
|
||||
$ref: '#/definitions/customer.AuthResponse'
|
||||
type: object
|
||||
"400":
|
||||
description: Bad request
|
||||
schema:
|
||||
$ref: '#/definitions/response.APIResponse'
|
||||
"401":
|
||||
description: Invalid credentials
|
||||
schema:
|
||||
$ref: '#/definitions/response.APIResponse'
|
||||
"500":
|
||||
description: Internal server error
|
||||
schema:
|
||||
$ref: '#/definitions/response.APIResponse'
|
||||
summary: Customer login
|
||||
tags:
|
||||
- customers
|
||||
/customers/logout:
|
||||
post:
|
||||
consumes:
|
||||
- application/json
|
||||
description: Logout customer and invalidate device token
|
||||
parameters:
|
||||
- description: Logout request with device token
|
||||
in: body
|
||||
name: logout
|
||||
required: true
|
||||
schema:
|
||||
type: object
|
||||
produces:
|
||||
- application/json
|
||||
responses:
|
||||
"200":
|
||||
description: Logged out successfully
|
||||
schema:
|
||||
$ref: '#/definitions/response.APIResponse'
|
||||
"400":
|
||||
description: Bad request
|
||||
schema:
|
||||
$ref: '#/definitions/response.APIResponse'
|
||||
"401":
|
||||
description: Unauthorized
|
||||
schema:
|
||||
$ref: '#/definitions/response.APIResponse'
|
||||
"500":
|
||||
description: Internal server error
|
||||
schema:
|
||||
$ref: '#/definitions/response.APIResponse'
|
||||
security:
|
||||
- BearerAuth: []
|
||||
summary: Customer logout
|
||||
tags:
|
||||
- customers
|
||||
/customers/profile:
|
||||
get:
|
||||
consumes:
|
||||
- application/json
|
||||
description: Retrieve the authenticated customer's profile information
|
||||
produces:
|
||||
- application/json
|
||||
responses:
|
||||
"200":
|
||||
description: Profile retrieved successfully
|
||||
schema:
|
||||
allOf:
|
||||
- $ref: '#/definitions/response.APIResponse'
|
||||
- properties:
|
||||
data:
|
||||
$ref: '#/definitions/customer.CustomerResponse'
|
||||
type: object
|
||||
"401":
|
||||
description: Unauthorized
|
||||
schema:
|
||||
$ref: '#/definitions/response.APIResponse'
|
||||
"404":
|
||||
description: Customer not found
|
||||
schema:
|
||||
$ref: '#/definitions/response.APIResponse'
|
||||
"500":
|
||||
description: Internal server error
|
||||
schema:
|
||||
$ref: '#/definitions/response.APIResponse'
|
||||
security:
|
||||
- BearerAuth: []
|
||||
summary: Get customer profile
|
||||
tags:
|
||||
- customers
|
||||
put:
|
||||
consumes:
|
||||
- application/json
|
||||
description: Update the authenticated customer's profile information
|
||||
parameters:
|
||||
- description: Profile update information
|
||||
in: body
|
||||
name: profile
|
||||
required: true
|
||||
schema:
|
||||
$ref: '#/definitions/customer.UpdateCustomerForm'
|
||||
produces:
|
||||
- application/json
|
||||
responses:
|
||||
"200":
|
||||
description: Profile updated successfully
|
||||
schema:
|
||||
allOf:
|
||||
- $ref: '#/definitions/response.APIResponse'
|
||||
- properties:
|
||||
data:
|
||||
$ref: '#/definitions/customer.CustomerResponse'
|
||||
type: object
|
||||
"400":
|
||||
description: Bad request
|
||||
schema:
|
||||
$ref: '#/definitions/response.APIResponse'
|
||||
"401":
|
||||
description: Unauthorized
|
||||
schema:
|
||||
$ref: '#/definitions/response.APIResponse'
|
||||
"500":
|
||||
description: Internal server error
|
||||
schema:
|
||||
$ref: '#/definitions/response.APIResponse'
|
||||
security:
|
||||
- BearerAuth: []
|
||||
summary: Update customer profile
|
||||
tags:
|
||||
- customers
|
||||
/customers/refresh-token:
|
||||
post:
|
||||
consumes:
|
||||
- application/json
|
||||
description: Refresh the access token using a refresh token
|
||||
parameters:
|
||||
- description: Refresh token information
|
||||
in: body
|
||||
name: token
|
||||
required: true
|
||||
schema:
|
||||
$ref: '#/definitions/customer.RefreshTokenForm'
|
||||
produces:
|
||||
- application/json
|
||||
responses:
|
||||
"200":
|
||||
description: Token refreshed successfully
|
||||
schema:
|
||||
allOf:
|
||||
- $ref: '#/definitions/response.APIResponse'
|
||||
- properties:
|
||||
data:
|
||||
$ref: '#/definitions/customer.AuthResponse'
|
||||
type: object
|
||||
"400":
|
||||
description: Bad request
|
||||
schema:
|
||||
$ref: '#/definitions/response.APIResponse'
|
||||
"401":
|
||||
description: Invalid refresh token
|
||||
schema:
|
||||
$ref: '#/definitions/response.APIResponse'
|
||||
"500":
|
||||
description: Internal server error
|
||||
schema:
|
||||
$ref: '#/definitions/response.APIResponse'
|
||||
summary: Refresh access token
|
||||
tags:
|
||||
- customers
|
||||
/users/admin:
|
||||
get:
|
||||
consumes:
|
||||
|
||||
+1
-5
@@ -56,7 +56,6 @@ import (
|
||||
"fmt"
|
||||
"net/http"
|
||||
"time"
|
||||
"tm/internal/customer"
|
||||
"tm/internal/user"
|
||||
|
||||
_ "tm/cmd/web/docs" // This is generated by swag
|
||||
@@ -92,8 +91,8 @@ func main() {
|
||||
|
||||
// Initialize authorization service
|
||||
authService := initAuthorizationService(conf.Auth.JWT, redisClient, logger)
|
||||
|
||||
// Initialize repositories with MongoDB connection manager
|
||||
customerRepository := customer.NewCustomerRepository(mongoManager, logger)
|
||||
userRepository := user.NewUserRepository(mongoManager, logger)
|
||||
|
||||
logger.Info("Repositories initialized successfully", map[string]interface{}{
|
||||
@@ -104,7 +103,6 @@ func main() {
|
||||
userValidator := user.NewValidationService()
|
||||
|
||||
// Initialize services with repositories
|
||||
customerService := customer.NewCustomerService(customerRepository, logger)
|
||||
userService := user.NewUserService(userRepository, logger, authService, userValidator)
|
||||
|
||||
logger.Info("Services initialized successfully", map[string]interface{}{
|
||||
@@ -112,7 +110,6 @@ func main() {
|
||||
})
|
||||
|
||||
// Initialize handlers with services
|
||||
customerHandler := customer.NewHandler(customerService)
|
||||
userHandler := user.NewUserHandler(userService, logger, userValidator, authService)
|
||||
|
||||
logger.Info("Handlers initialized successfully", map[string]interface{}{
|
||||
@@ -123,7 +120,6 @@ func main() {
|
||||
e := initHTTPServer(conf, logger)
|
||||
|
||||
// Register routes
|
||||
customerHandler.RegisterRoutes(e)
|
||||
userHandler.RegisterRoutes(e)
|
||||
|
||||
// Start server
|
||||
|
||||
Reference in New Issue
Block a user