Commit 23d20daa authored by shajiaiming's avatar shajiaiming

Merge branch 'feature/optimize' into 'master'

fix See merge request !31
parents d16254ad e5bb8042
......@@ -146,7 +146,7 @@ func AddCoin(c *gin.Context) {
Decimals: coin.Decimals,
Address: coin.Address,
Treaty: coin.Treaty,
PlatformId: "1",
PlatformId: "[1]",
}
if err := coinService.Add(); err != nil {
......
......@@ -108,15 +108,21 @@ func AddWalletCoinRelationCoinRelation(c *gin.Context) {
}
coin_exist, _ := coinService.Get()
platform_id_arr := strings.Split(coin_exist.PlatformId, ",")
is_exist := false
temp_exist_platform_ids := strings.Replace(coin_exist.PlatformId, "[", "", -1)
temp_exist_platform_ids = strings.Replace(temp_exist_platform_ids, "]", "", -1)
temp_exist_platform_ids = strings.Replace(temp_exist_platform_ids, " ", "", -1)
platform_id_arr := strings.Split(temp_exist_platform_ids, ",")
for _, exist_platform_id := range platform_id_arr {
if util.ToInt(exist_platform_id) == coin_relation.PlatformId {
is_exist = true
}
}
if is_exist == false {
coinService.PlatformId = coin_exist.PlatformId + "," + strconv.Itoa(coin_relation.PlatformId)
coinService.PlatformId = strings.Replace(coin_exist.PlatformId, "]", ",", -1) + strconv.Itoa(coin_relation.PlatformId) + "]"
coinService.UpdateCoinRelation()
}
}
......@@ -163,7 +169,11 @@ func DeleteWalletCoinRelationCoinRelation(c *gin.Context) {
}
coin_exist, _ := coinService.Get()
platform_id_arr := strings.Split(coin_exist.PlatformId, ",")
temp_exist_platform_ids := strings.Replace(coin_exist.PlatformId, "[", "", -1)
temp_exist_platform_ids = strings.Replace(temp_exist_platform_ids, "]", "", -1)
temp_exist_platform_ids = strings.Replace(temp_exist_platform_ids, " ", "", -1)
platform_id_arr := strings.Split(temp_exist_platform_ids, ",")
var new_platform_id string
for _, exist_platform_id := range platform_id_arr {
......@@ -173,7 +183,7 @@ func DeleteWalletCoinRelationCoinRelation(c *gin.Context) {
new_platform_id = strings.Join([]string{exist_platform_id, new_platform_id}, ",")
new_platform_id = strings.TrimRight(new_platform_id, ",")
}
coinService.PlatformId = new_platform_id
coinService.PlatformId = "[" + new_platform_id + "]"
coinService.UpdateCoinRelation()
handler.SendResponse(c, nil, nil)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment