批量更新功能
This commit is contained in:
@@ -63,6 +63,8 @@ type erpContactDTO struct {
|
||||
ContactName string `json:"contact_name"`
|
||||
Gender int8 `json:"gender"`
|
||||
Phone string `json:"phone"`
|
||||
// 手机号可登记多个(有的人有多个号码):JSON 数组,最多 5 个;phone 保留为第一个
|
||||
Mobiles string `json:"mobiles"`
|
||||
WorkPhone string `json:"work_phone"`
|
||||
Email string `json:"email"`
|
||||
Wechat string `json:"wechat"`
|
||||
@@ -188,6 +190,11 @@ func (c *BackendErpContactController) Create() {
|
||||
contactType, _ := c.contactGetIntValue(body, "contact_type")
|
||||
gender, _ := c.contactGetIntValue(body, "gender")
|
||||
phone, _ := c.contactGetStringValue(body, "phone")
|
||||
mobilesJSON, _ := c.contactGetStringValue(body, "mobiles")
|
||||
// 多手机号:优先使用 mobiles 字段;未传手机号时从 mobiles 取第一个回填 phone(兼容旧调用方)
|
||||
if strings.TrimSpace(phone) == "" {
|
||||
phone = firstMobile(strings.TrimSpace(mobilesJSON))
|
||||
}
|
||||
workPhone, _ := c.contactGetStringValue(body, "work_phone")
|
||||
email, _ := c.contactGetStringValue(body, "email")
|
||||
wechat, _ := c.contactGetStringValue(body, "wechat")
|
||||
@@ -211,6 +218,7 @@ func (c *BackendErpContactController) Create() {
|
||||
ContactName: contactName,
|
||||
Gender: int8(gender),
|
||||
Phone: contactStrPtr(phone),
|
||||
Mobiles: contactStrPtr(mobilesJSON),
|
||||
WorkPhone: contactStrPtr(workPhone),
|
||||
Email: contactStrPtr(email),
|
||||
Wechat: contactStrPtr(wechat),
|
||||
@@ -276,6 +284,13 @@ func (c *BackendErpContactController) Update() {
|
||||
if v, has := c.contactGetStringValue(body, "phone"); has {
|
||||
update["phone"] = contactNullableString(v)
|
||||
}
|
||||
if v, has := c.contactGetStringValue(body, "mobiles"); has {
|
||||
update["mobiles"] = contactNullableString(v)
|
||||
// 多手机号下,phone 始终为第一个号码,保持两者一致
|
||||
if p := firstMobile(strings.TrimSpace(v)); p != "" {
|
||||
update["phone"] = contactNullableString(p)
|
||||
}
|
||||
}
|
||||
if v, has := c.contactGetStringValue(body, "work_phone"); has {
|
||||
update["work_phone"] = contactNullableString(v)
|
||||
}
|
||||
@@ -559,6 +574,7 @@ func (c *BackendErpContactController) contactDTO(row models.BackendErpContact) e
|
||||
ContactName: row.ContactName,
|
||||
Gender: row.Gender,
|
||||
Phone: contactDerefString(row.Phone),
|
||||
Mobiles: contactDerefString(row.Mobiles),
|
||||
WorkPhone: contactDerefString(row.WorkPhone),
|
||||
Email: contactDerefString(row.Email),
|
||||
Wechat: contactDerefString(row.Wechat),
|
||||
|
||||
Reference in New Issue
Block a user