Merge pull request '数据上链成功时,将tx_hash返回' (#1) from zm-dev into master

This commit is contained in:
xxq250 2025-05-28 11:32:19 +08:00
commit f5e78e9bda
3 changed files with 33 additions and 4 deletions

View File

@ -17,6 +17,11 @@ type ResponseUserBalanceList struct {
UserBalanceList
}
type ResponseTxHash struct {
Response
TxHash string `json:"tx_hash"`
}
type ResponseUserBalanceListByPage struct {
Response
UserBalanceList

View File

@ -63,7 +63,13 @@ func UploadCommitInfo(ctx *macaron.Context, opt api.UploadCommitOption, logger *
}
if code.Int64() > 0 {
logger.Printf("inserted lines: %v\n", code)
ctx.JSON(http.StatusOK, structs.ResCommitUploadSucc)
ctx.JSON(http.StatusOK, &structs.ResponseTxHash{
Response: structs.Response{
Status: 0,
Message: "commit upload successfully!",
},
TxHash: tx.Hash().Hex(),
})
return
}
ctx.JSON(http.StatusOK, structs.ResCommitUploadUnsucc)
@ -165,7 +171,13 @@ func UploadPullRequestInfo(ctx *macaron.Context, opt api.UploadPullReuqestOption
}
if code.Int64() > 0 {
logger.Printf("inserted lines: %v\n", code)
ctx.JSON(http.StatusOK, structs.ResPullRequestUploadSucc)
ctx.JSON(http.StatusOK, &structs.ResponseTxHash{
Response: structs.Response{
Status: 0,
Message: "pull request upload successfully!",
},
TxHash: tx.Hash().Hex(),
})
return
}
ctx.JSON(http.StatusOK, structs.ResPullRequestUploadUnsucc)
@ -267,7 +279,13 @@ func UploadIssueInfo(ctx *macaron.Context, opt api.UploadIssueOption, logger *lo
}
if code.Int64() > 0 {
logger.Printf("inserted lines: %v\n", code)
ctx.JSON(http.StatusOK, structs.ResIssueUploadSucc)
ctx.JSON(http.StatusOK, &structs.ResponseTxHash{
Response: structs.Response{
Status: 0,
Message: "issue upload successfully!",
},
TxHash: tx.Hash().Hex(),
})
return
}
ctx.JSON(http.StatusOK, structs.ResIssueUploadUnsucc)

View File

@ -502,7 +502,13 @@ func TransferAmount(ctx *macaron.Context, payer string, payee string, tokenName
}
if code.Int64() > 0 {
logger.Printf("inserted lines: %v\n", code)
ctx.JSON(http.StatusOK, structs.ResUserTransferAmountSucc)
ctx.JSON(http.StatusOK, &structs.ResponseTxHash{
Response: structs.Response{
Status: 0,
Message: "user transfers amount successfully!",
},
TxHash: tx.Hash().Hex(),
})
return
} else if code.Int64() == contract.RepoUnexisted {
logger.Printf("error code: %v, message: %v\n", code, structs.ResRepoNotExisted)