Add functionality to manage external links for companies
continuous-integration/drone/push Build is passing
continuous-integration/drone/push Build is passing
- Introduced the ability to append external links to company profiles through a new API endpoint. - Enhanced the `Company` entity to include a `Links` field for storing external resource links. - Created `AddLinksForm` for validating incoming link data and implemented corresponding logic in the service layer. - Added error handling for link validation, ensuring only valid URLs are accepted and limiting the number of links to 20. - Implemented unit tests for link management functions, including sanitization and merging of links. - Updated relevant API documentation to reflect the new functionality. This update significantly enhances the company management capabilities by allowing the addition of external links, improving the overall user experience and data richness in company profiles.
This commit is contained in:
@@ -24,7 +24,8 @@ type (
|
||||
// Contact information
|
||||
Phone *string `json:"phone,omitempty" valid:"optional,length(10|20)" example:"+1234567890"`
|
||||
Email *string `json:"email,omitempty" valid:"optional,email" example:"info@opplens.com"`
|
||||
DocumentFileIDs []string `json:"document_file_ids,omitempty" valid:"optional"`
|
||||
DocumentFileIDs []string `json:"document_file_ids,omitempty" valid:"optional"`
|
||||
Links []CompanyLinkForm `json:"links,omitempty" valid:"optional"`
|
||||
|
||||
// Tags for categorization and search
|
||||
Tags *CompanyTagsForm `json:"tags,omitempty"`
|
||||
@@ -35,6 +36,12 @@ type (
|
||||
Timezone *string `json:"timezone,omitempty" valid:"optional,length(3|50)" example:"UTC"`
|
||||
}
|
||||
|
||||
// CompanyLinkForm represents the form for a company link.
|
||||
CompanyLinkForm struct {
|
||||
URL string `json:"url" valid:"required,url" example:"https://example.com/profile"`
|
||||
Title *string `json:"title,omitempty" valid:"optional,length(1|200)" example:"Company profile"`
|
||||
}
|
||||
|
||||
// AddressForm represents the form for company address
|
||||
AddressForm struct {
|
||||
Street string `json:"street" valid:"required,length(5|200)" example:"123 Main St"`
|
||||
@@ -90,6 +97,11 @@ type StatusForm struct {
|
||||
Reason *string `json:"reason" valid:"optional,length(10|500)"`
|
||||
}
|
||||
|
||||
// AddLinksForm is the request body for appending links to a company.
|
||||
type AddLinksForm struct {
|
||||
Links []CompanyLinkForm `json:"links" valid:"required"`
|
||||
}
|
||||
|
||||
// VerificationForm represents the form for updating company verification status
|
||||
type VerificationForm struct {
|
||||
IsVerified bool `json:"is_verified"`
|
||||
@@ -128,6 +140,7 @@ type (
|
||||
Phone *string `json:"phone,omitempty"`
|
||||
Email *string `json:"email,omitempty"`
|
||||
DocumentFileIDs []string `json:"document_file_ids,omitempty"`
|
||||
Links []CompanyLink `json:"links,omitempty"`
|
||||
Tags *CompanyTagsResponse `json:"tags,omitempty"`
|
||||
IsVerified bool `json:"is_verified"`
|
||||
IsCompliant bool `json:"is_compliant"`
|
||||
@@ -167,6 +180,7 @@ func (c *Company) ToResponse(categories []*CategoryResponse) *CompanyResponse {
|
||||
Phone: c.Phone,
|
||||
Email: c.Email,
|
||||
DocumentFileIDs: c.DocumentFileIDs,
|
||||
Links: c.Links,
|
||||
Tags: c.Tags.ToResponse(categories),
|
||||
IsVerified: c.IsVerified,
|
||||
IsCompliant: c.IsCompliant,
|
||||
@@ -208,8 +222,9 @@ type CompanyProfileResponse struct {
|
||||
RegistrationNumber string `json:"registration_number"`
|
||||
Industry string `json:"industry"`
|
||||
FoundedYear *int `json:"founded_year,omitempty"`
|
||||
DocumentFileIDs []string `json:"document_file_ids,omitempty"`
|
||||
CreatedAt int64 `json:"created_at"`
|
||||
DocumentFileIDs []string `json:"document_file_ids,omitempty"`
|
||||
Links []CompanyLink `json:"links,omitempty"`
|
||||
CreatedAt int64 `json:"created_at"`
|
||||
}
|
||||
|
||||
// ToResponse converts Company to CompanyResponse
|
||||
@@ -221,6 +236,7 @@ func (c *Company) ToProfileResponse() *CompanyProfileResponse {
|
||||
Industry: c.Industry,
|
||||
FoundedYear: c.FoundedYear,
|
||||
DocumentFileIDs: c.DocumentFileIDs,
|
||||
Links: c.Links,
|
||||
CreatedAt: c.CreatedAt,
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user