From c60d971f9bf50e364cc50f0699249217ef9bbb6b Mon Sep 17 00:00:00 2001
From: wangpengfei <274878379@qq.com>
Date: 星期二, 15 八月 2023 20:07:46 +0800
Subject: [PATCH] fix
---
api/v1/client.go | 2
service/client.go | 14 +++++-
model/request/client.go | 1
docs/swagger.yaml | 12 ++++++
docs/docs.go | 16 ++++++++
docs/swagger.json | 16 ++++++++
6 files changed, 57 insertions(+), 4 deletions(-)
diff --git a/api/v1/client.go b/api/v1/client.go
index c4da6b7..b439fc6 100644
--- a/api/v1/client.go
+++ b/api/v1/client.go
@@ -166,7 +166,7 @@
client.Id = params.Id
- errCode = clientService.UpdateClient(client)
+ errCode = clientService.UpdateClient(client, params.ContactId)
if errCode != ecode.OK {
ctx.Fail(errCode)
return
diff --git a/docs/docs.go b/docs/docs.go
index 6282947..f0a0ff5 100644
--- a/docs/docs.go
+++ b/docs/docs.go
@@ -13025,6 +13025,10 @@
"contact": {
"$ref": "#/definitions/request.Contact"
},
+ "contact_id": {
+ "description": "鑱旂郴浜篒D",
+ "type": "integer"
+ },
"country_id": {
"type": "integer"
},
@@ -14176,6 +14180,10 @@
},
"contact": {
"$ref": "#/definitions/request.Contact"
+ },
+ "contact_id": {
+ "description": "鑱旂郴浜篒D",
+ "type": "integer"
},
"country_id": {
"type": "integer"
@@ -15701,6 +15709,10 @@
},
"contact": {
"$ref": "#/definitions/request.Contact"
+ },
+ "contact_id": {
+ "description": "鑱旂郴浜篒D",
+ "type": "integer"
},
"country_id": {
"type": "integer"
@@ -17414,6 +17426,10 @@
"contact": {
"$ref": "#/definitions/request.Contact"
},
+ "contact_id": {
+ "description": "鑱旂郴浜篒D",
+ "type": "integer"
+ },
"country_id": {
"type": "integer"
},
diff --git a/docs/swagger.json b/docs/swagger.json
index 68d2743..e6f4bb8 100644
--- a/docs/swagger.json
+++ b/docs/swagger.json
@@ -13013,6 +13013,10 @@
"contact": {
"$ref": "#/definitions/request.Contact"
},
+ "contact_id": {
+ "description": "鑱旂郴浜篒D",
+ "type": "integer"
+ },
"country_id": {
"type": "integer"
},
@@ -14164,6 +14168,10 @@
},
"contact": {
"$ref": "#/definitions/request.Contact"
+ },
+ "contact_id": {
+ "description": "鑱旂郴浜篒D",
+ "type": "integer"
},
"country_id": {
"type": "integer"
@@ -15689,6 +15697,10 @@
},
"contact": {
"$ref": "#/definitions/request.Contact"
+ },
+ "contact_id": {
+ "description": "鑱旂郴浜篒D",
+ "type": "integer"
},
"country_id": {
"type": "integer"
@@ -17402,6 +17414,10 @@
"contact": {
"$ref": "#/definitions/request.Contact"
},
+ "contact_id": {
+ "description": "鑱旂郴浜篒D",
+ "type": "integer"
+ },
"country_id": {
"type": "integer"
},
diff --git a/docs/swagger.yaml b/docs/swagger.yaml
index cafe058..1bbd234 100644
--- a/docs/swagger.yaml
+++ b/docs/swagger.yaml
@@ -2058,6 +2058,9 @@
type: integer
contact:
$ref: '#/definitions/request.Contact'
+ contact_id:
+ description: 鑱旂郴浜篒D
+ type: integer
country_id:
type: integer
detail_address:
@@ -2828,6 +2831,9 @@
type: integer
contact:
$ref: '#/definitions/request.Contact'
+ contact_id:
+ description: 鑱旂郴浜篒D
+ type: integer
country_id:
type: integer
detail_address:
@@ -3895,6 +3901,9 @@
type: integer
contact:
$ref: '#/definitions/request.Contact'
+ contact_id:
+ description: 鑱旂郴浜篒D
+ type: integer
country_id:
type: integer
detail_address:
@@ -5042,6 +5051,9 @@
type: integer
contact:
$ref: '#/definitions/request.Contact'
+ contact_id:
+ description: 鑱旂郴浜篒D
+ type: integer
country_id:
type: integer
detail_address:
diff --git a/model/request/client.go b/model/request/client.go
index 29303bf..540f3f3 100644
--- a/model/request/client.go
+++ b/model/request/client.go
@@ -19,6 +19,7 @@
LatestServiceTime string `json:"latest_service_time"` // 鏈�鏅氭湇鍔℃椂闂�
Contact Contact `json:"contact"`
SalesLeadsId int `json:"sales_leads_id"` // 閿�鍞嚎绱D
+ ContactId int `json:"contact_id"` // 鑱旂郴浜篒D
Address
Business
}
diff --git a/service/client.go b/service/client.go
index e889606..20cd752 100644
--- a/service/client.go
+++ b/service/client.go
@@ -44,7 +44,7 @@
return ecode.OK
}
-func (ClientService) UpdateClient(client *model.Client) int {
+func (ClientService) UpdateClient(client *model.Client, conId int) int {
// check client exist
errCode := CheckClientExist(client.Id)
if errCode != ecode.OK {
@@ -67,13 +67,21 @@
for _, contact := range client.Contacts {
contact.ClientId = client.Id
- if contact.Id == 0 {
- err := model.NewContactSearch(tx).Create(&contact)
+
+ // check isFirst
+ errCode = setFirstContact(tx, &contact)
+ if errCode != ecode.OK {
+ return errCode
+ }
+
+ if conId == 0 {
+ err = model.NewContactSearch(tx).Create(&contact)
if err != nil {
tx.Rollback()
return ecode.ClientUpdateErr
}
} else {
+ contact.Id = conId
err = model.NewContactSearch(tx).SetId(contact.Id).Update(&contact)
if err != nil {
tx.Rollback()
--
Gitblit v1.8.0