feat: Update LeadCreateRequest to make requirement field optional and set default value in lead creation
This commit is contained in:
1 parent
b5eda1d6d1
commit
e84ae246b4
2 files changed
+8
-2
No files matched your search
@@ -119,7 +119,7 @@ type LeadCreateRequest struct {
|
|||||||
ContactName string `json:"contact_name" binding:"required,min=1,max=100"` // 联系人
|
ContactName string `json:"contact_name" binding:"required,min=1,max=100"` // 联系人
|
||||||
ContactPhone string `json:"contact_phone" binding:"required,min=1,max=20"` // 联系电话
|
ContactPhone string `json:"contact_phone" binding:"required,min=1,max=20"` // 联系电话
|
||||||
ContactEmail string `json:"contact_email" binding:"omitempty,email,max=100"` // 邮箱
|
ContactEmail string `json:"contact_email" binding:"omitempty,email,max=100"` // 邮箱
|
||||||
Requirement string `json:"requirement" binding:"required,min=1"` // 需求描述
|
Requirement string `json:"requirement" binding:"omitempty"` // 需求描述
|
||||||
ExtraInfo string `json:"extra_info"` // 补充信息
|
ExtraInfo string `json:"extra_info"` // 补充信息
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -37,12 +37,18 @@ func NewLeadService(repo repository.LeadRepository, db *gorm.DB) LeadService {
|
|||||||
func (s *leadService) CreateLead(ctx context.Context, req *models.LeadCreateRequest) (*models.Lead, error) {
|
func (s *leadService) CreateLead(ctx context.Context, req *models.LeadCreateRequest) (*models.Lead, error) {
|
||||||
lang := pkgcontext.GetLanguageFromContext(ctx)
|
lang := pkgcontext.GetLanguageFromContext(ctx)
|
||||||
|
|
||||||
|
// 如果 requirement 为空,设置默认值 "Empty"
|
||||||
|
requirement := req.Requirement
|
||||||
|
if requirement == "" {
|
||||||
|
requirement = "Empty"
|
||||||
|
}
|
||||||
|
|
||||||
lead := &models.Lead{
|
lead := &models.Lead{
|
||||||
CompanyName: req.CompanyName,
|
CompanyName: req.CompanyName,
|
||||||
ContactName: req.ContactName,
|
ContactName: req.ContactName,
|
||||||
ContactPhone: req.ContactPhone,
|
ContactPhone: req.ContactPhone,
|
||||||
ContactEmail: req.ContactEmail,
|
ContactEmail: req.ContactEmail,
|
||||||
Requirement: req.Requirement,
|
Requirement: requirement,
|
||||||
ExtraInfo: req.ExtraInfo,
|
ExtraInfo: req.ExtraInfo,
|
||||||
Status: string(models.LeadStatusPending),
|
Status: string(models.LeadStatusPending),
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user