Align backend company registration and notification routes with frontend
This commit is contained in:
parent
aa544426a5
commit
4544a1d5b2
3 changed files with 161 additions and 142 deletions
|
|
@ -13,11 +13,15 @@ type CreateCompanyRequest struct {
|
|||
Phone string `json:"phone"`
|
||||
Website *string `json:"website,omitempty"`
|
||||
Address *string `json:"address,omitempty"`
|
||||
City *string `json:"city,omitempty"`
|
||||
State *string `json:"state,omitempty"`
|
||||
ZipCode *string `json:"zip_code,omitempty"`
|
||||
EmployeeCount *string `json:"employeeCount,omitempty"`
|
||||
FoundedYear *int `json:"foundedYear,omitempty"`
|
||||
Description *string `json:"description,omitempty"`
|
||||
YearsInMarket *string `json:"years_in_market,omitempty"`
|
||||
BirthDate *string `json:"birth_date,omitempty"`
|
||||
AdminBirthDate *string `json:"admin_birth_date,omitempty"`
|
||||
}
|
||||
|
||||
type CompanyResponse struct {
|
||||
|
|
|
|||
|
|
@ -27,6 +27,10 @@ func NewCreateCompanyUseCase(cRepo ports.CompanyRepository, uRepo ports.UserRepo
|
|||
}
|
||||
|
||||
func (uc *CreateCompanyUseCase) Execute(ctx context.Context, input dto.CreateCompanyRequest) (*dto.CompanyResponse, error) {
|
||||
if input.Name == "" && input.CompanyName != "" {
|
||||
input.Name = input.CompanyName
|
||||
}
|
||||
|
||||
// 0. Sanitize inputs
|
||||
sanitizer := utils.DefaultSanitizer()
|
||||
input.Name = sanitizer.SanitizeName(input.Name)
|
||||
|
|
@ -96,10 +100,19 @@ func (uc *CreateCompanyUseCase) Execute(ctx context.Context, input dto.CreateCom
|
|||
|
||||
adminUser := entity.NewUser("", savedCompany.ID, "Admin", input.AdminEmail)
|
||||
adminUser.PasswordHash = hashedPassword
|
||||
adminUser.Address = input.Address
|
||||
adminUser.City = input.City
|
||||
adminUser.State = input.State
|
||||
adminUser.ZipCode = input.ZipCode
|
||||
|
||||
if input.BirthDate != nil {
|
||||
birthDate := input.BirthDate
|
||||
if birthDate == nil {
|
||||
birthDate = input.AdminBirthDate
|
||||
}
|
||||
|
||||
if birthDate != nil {
|
||||
layout := "2006-01-02"
|
||||
if parsed, err := time.Parse(layout, *input.BirthDate); err == nil {
|
||||
if parsed, err := time.Parse(layout, *birthDate); err == nil {
|
||||
adminUser.BirthDate = &parsed
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -358,6 +358,8 @@ func NewRouter() http.Handler {
|
|||
notificationHandler := handlers.NewNotificationHandler(notificationService)
|
||||
mux.Handle("PUT /api/v1/notifications/read-all", authMiddleware.HeaderAuthGuard(http.HandlerFunc(notificationHandler.MarkAllAsRead)))
|
||||
mux.Handle("PUT /api/v1/notifications/{id}/read", authMiddleware.HeaderAuthGuard(http.HandlerFunc(notificationHandler.MarkAsRead)))
|
||||
mux.Handle("PATCH /api/v1/notifications/read-all", authMiddleware.HeaderAuthGuard(http.HandlerFunc(notificationHandler.MarkAllAsRead)))
|
||||
mux.Handle("PATCH /api/v1/notifications/{id}/read", authMiddleware.HeaderAuthGuard(http.HandlerFunc(notificationHandler.MarkAsRead)))
|
||||
mux.Handle("POST /api/v1/notifications/fcm-token", authMiddleware.HeaderAuthGuard(http.HandlerFunc(notificationHandler.RegisterFCMToken)))
|
||||
|
||||
// Swagger Route - available at /docs
|
||||
|
|
|
|||
Loading…
Reference in a new issue