From 530fed8ec225453572d57b15c200ab062c335457 Mon Sep 17 00:00:00 2001 From: zhangqian <zhangqian@123.com> Date: 星期三, 01 十一月 2023 19:20:21 +0800 Subject: [PATCH] 公海member_id使用0 --- service/client.go | 14 +++++++++++--- 1 files changed, 11 insertions(+), 3 deletions(-) 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