9119e2383e
- Introduced a new `config.yaml` file for managing server, database, cache, queue, AI, scraping, logging, and rate limiting configurations. - Updated `docker-compose.yml` to reflect the new server port (8081) and adjusted health check endpoints accordingly. - Modified `Dockerfile` to expose the new server port. - Updated `README.md` to reflect changes in server configuration and added documentation for the new configuration structure. - Added test scripts for server and Swagger documentation testing. - Refactored customer domain structure to align with new configuration settings and improve maintainability.
135 lines
5.0 KiB
Go
135 lines
5.0 KiB
Go
package customer
|
|
|
|
// Customer Registration DTOs
|
|
type RegisterCustomerForm struct {
|
|
FullName string `json:"full_name" valid:"required,length(2|100)"`
|
|
Username string `json:"username" valid:"required,alphanum,length(3|30)"`
|
|
Email string `json:"email" valid:"required,email"`
|
|
Mobile string `json:"mobile" valid:"required,length(10|15)"`
|
|
Password string `json:"password" valid:"required,length(8|128)"`
|
|
NationalID *string `json:"national_id,omitempty" valid:"optional,length(5|20)"`
|
|
Gender *string `json:"gender,omitempty" valid:"optional,in(male|female|other)"`
|
|
Birthdate *int64 `json:"birthdate,omitempty" valid:"optional,unix_timestamp"`
|
|
ProfileImage *string `json:"profile_image,omitempty" valid:"optional,url"`
|
|
CompanyID *string `json:"company_id,omitempty" valid:"optional,uuid"`
|
|
}
|
|
|
|
type UpdateCustomerForm struct {
|
|
FullName *string `json:"full_name,omitempty" valid:"optional,length(2|100)"`
|
|
Username *string `json:"username,omitempty" valid:"optional,alphanum,length(3|30)"`
|
|
Email *string `json:"email,omitempty" valid:"optional,email"`
|
|
Mobile *string `json:"mobile,omitempty" valid:"optional,length(10|15)"`
|
|
NationalID *string `json:"national_id,omitempty" valid:"optional,length(5|20)"`
|
|
Gender *string `json:"gender,omitempty" valid:"optional,in(male|female|other)"`
|
|
Birthdate *int64 `json:"birthdate,omitempty" valid:"optional,unix_timestamp"`
|
|
ProfileImage *string `json:"profile_image,omitempty" valid:"optional,url"`
|
|
Status *string `json:"status,omitempty" valid:"optional,in(active|inactive)"`
|
|
}
|
|
|
|
// Customer Authentication DTOs
|
|
type LoginForm struct {
|
|
EmailOrMobile string `json:"email_or_mobile" valid:"required"`
|
|
Password string `json:"password" valid:"required"`
|
|
}
|
|
|
|
type RefreshTokenForm struct {
|
|
RefreshToken string `json:"refresh_token" valid:"required"`
|
|
}
|
|
|
|
type ChangePasswordForm struct {
|
|
OldPassword string `json:"old_password" valid:"required"`
|
|
NewPassword string `json:"new_password" valid:"required,length(8|128)"`
|
|
}
|
|
|
|
// Device Token DTOs
|
|
type AddDeviceTokenForm struct {
|
|
DeviceToken string `json:"device_token" valid:"required,length(32|255)"`
|
|
DeviceType string `json:"device_type" valid:"required,in(android|ios)"`
|
|
}
|
|
|
|
type RemoveDeviceTokenForm struct {
|
|
DeviceToken string `json:"device_token" valid:"required"`
|
|
}
|
|
|
|
// Admin DTOs
|
|
type ListCustomersForm struct {
|
|
Search *string `query:"search" valid:"optional"`
|
|
Status *string `query:"status" valid:"optional,in(active|inactive)"`
|
|
Gender *string `query:"gender" valid:"optional,in(male|female|other)"`
|
|
CompanyID *string `query:"company_id" valid:"optional,uuid"`
|
|
Limit *int `query:"limit" valid:"optional,range(1|100)"`
|
|
Offset *int `query:"offset" valid:"optional,min(0)"`
|
|
SortBy *string `query:"sort_by" valid:"optional,in(full_name|email|mobile|created_at|last_login_at)"`
|
|
SortOrder *string `query:"sort_order" valid:"optional,in(asc|desc)"`
|
|
}
|
|
|
|
type UpdateCustomerStatusForm struct {
|
|
Status string `json:"status" valid:"required,in(active|inactive)"`
|
|
}
|
|
|
|
// Response DTOs
|
|
type CustomerResponse struct {
|
|
ID string `json:"id"`
|
|
FullName string `json:"full_name"`
|
|
Username string `json:"username"`
|
|
Email string `json:"email"`
|
|
Mobile string `json:"mobile"`
|
|
NationalID *string `json:"national_id,omitempty"`
|
|
Gender *string `json:"gender,omitempty"`
|
|
Birthdate *int64 `json:"birthdate,omitempty"`
|
|
ProfileImage *string `json:"profile_image,omitempty"`
|
|
Status string `json:"status"`
|
|
CompanyID *string `json:"company_id,omitempty"`
|
|
IsVerified bool `json:"is_verified"`
|
|
DeviceTokens []DeviceToken `json:"device_tokens"`
|
|
LastLoginAt *int64 `json:"last_login_at,omitempty"`
|
|
CreatedAt int64 `json:"created_at"`
|
|
UpdatedAt int64 `json:"updated_at"`
|
|
}
|
|
|
|
type AuthResponse struct {
|
|
Customer *CustomerResponse `json:"customer"`
|
|
AccessToken string `json:"access_token"`
|
|
RefreshToken string `json:"refresh_token"`
|
|
ExpiresAt int64 `json:"expires_at"`
|
|
}
|
|
|
|
type DeviceTokenResponse struct {
|
|
Token string `json:"token"`
|
|
DeviceType string `json:"device_type"`
|
|
CreatedAt int64 `json:"created_at"`
|
|
UpdatedAt int64 `json:"updated_at"`
|
|
}
|
|
|
|
// Helper function to convert Customer to CustomerResponse
|
|
func (c *Customer) ToResponse() *CustomerResponse {
|
|
gender := ""
|
|
if c.Gender != nil {
|
|
gender = string(*c.Gender)
|
|
}
|
|
|
|
companyID := ""
|
|
if c.CompanyID != nil {
|
|
companyID = c.CompanyID.String()
|
|
}
|
|
|
|
return &CustomerResponse{
|
|
ID: c.ID.String(),
|
|
FullName: c.FullName,
|
|
Username: c.Username,
|
|
Email: c.Email,
|
|
Mobile: c.Mobile,
|
|
NationalID: c.NationalID,
|
|
Gender: &gender,
|
|
Birthdate: c.Birthdate,
|
|
ProfileImage: c.ProfileImage,
|
|
Status: string(c.Status),
|
|
CompanyID: &companyID,
|
|
IsVerified: c.IsVerified,
|
|
DeviceTokens: c.DeviceTokens,
|
|
LastLoginAt: c.LastLoginAt,
|
|
CreatedAt: c.CreatedAt,
|
|
UpdatedAt: c.UpdatedAt,
|
|
}
|
|
}
|