From 23cae4c63e1e49accc7bcf3245bee88420145430 Mon Sep 17 00:00:00 2001 From: ychao_1983 Date: Thu, 16 Dec 2021 10:08:02 +0800 Subject: [PATCH 1/2] =?UTF-8?q?fix-1052=20=E5=8C=BA=E5=9D=97=E9=93=BE?= =?UTF-8?q?=E6=9B=B4=E6=96=B0=E4=B8=8D=E4=BF=AE=E6=94=B9=E9=A1=B9=E7=9B=AE?= =?UTF-8?q?=E6=9B=B4=E6=96=B0=E6=97=B6=E9=97=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- models/repo.go | 17 +++++++++++++++++ routers/repo/blockchain.go | 2 +- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/models/repo.go b/models/repo.go index a4417e4bd..a0acc2ef4 100755 --- a/models/repo.go +++ b/models/repo.go @@ -2470,6 +2470,23 @@ func GetBlockChainUnSuccessRepos() ([]*Repository, error) { Find(&repos) } +func (repo *Repository) UpdateBlockChain() error { + sess := x.NewSession() + defer sess.Close() + if err := sess.Begin(); err != nil { + return err + } + if _, err := sess.Exec("UPDATE `repository` SET block_chain_status = ?, contract_address=? WHERE id = ?", repo.BlockChainStatus, repo.ContractAddress, repo.ID); err != nil { + return err + } + + if err := sess.Commit(); err != nil { + return err + } + + return nil +} + func (repo *Repository) IncreaseCloneCnt() { sess := x.NewSession() defer sess.Close() diff --git a/routers/repo/blockchain.go b/routers/repo/blockchain.go index dc3fcd848..6bd546ce6 100755 --- a/routers/repo/blockchain.go +++ b/routers/repo/blockchain.go @@ -72,7 +72,7 @@ func HandleBlockChainInitNotify(ctx *context.Context) { repo.BlockChainStatus = models.RepoBlockChainSuccess repo.ContractAddress = req.ContractAddress - if err = models.UpdateRepositoryCols(repo, "block_chain_status", "contract_address"); err != nil { + if err = repo.UpdateBlockChain(); err != nil { log.Error("UpdateRepositoryCols failed:%v", err.Error(), ctx.Data["msgID"]) ctx.JSON(200, map[string]string{ "code": "-1", From 4c60434dd7b054d8af77bdd5062e8043fb1b23a4 Mon Sep 17 00:00:00 2001 From: ychao_1983 Date: Thu, 16 Dec 2021 10:28:59 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E4=BC=98=E5=8C=96=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- models/repo.go | 15 ++------------- 1 file changed, 2 insertions(+), 13 deletions(-) diff --git a/models/repo.go b/models/repo.go index a0acc2ef4..8070d7442 100755 --- a/models/repo.go +++ b/models/repo.go @@ -2471,20 +2471,9 @@ func GetBlockChainUnSuccessRepos() ([]*Repository, error) { } func (repo *Repository) UpdateBlockChain() error { - sess := x.NewSession() - defer sess.Close() - if err := sess.Begin(); err != nil { - return err - } - if _, err := sess.Exec("UPDATE `repository` SET block_chain_status = ?, contract_address=? WHERE id = ?", repo.BlockChainStatus, repo.ContractAddress, repo.ID); err != nil { - return err - } - if err := sess.Commit(); err != nil { - return err - } - - return nil + _, err := x.Exec("UPDATE `repository` SET block_chain_status = ?, contract_address=? WHERE id = ?", repo.BlockChainStatus, repo.ContractAddress, repo.ID) + return err } func (repo *Repository) IncreaseCloneCnt() {