Commit 029eac2f authored by shajiaiming's avatar shajiaiming

逻辑调整

parent c8ae67fb
......@@ -25,7 +25,22 @@ func (c WalletCoinRelation) TableName() string {
*/
func GetWalletCoinRelationTotal(maps interface{}) (int, error) {
var count int
if err := db.Model(&WalletCoinRelation{}).Where(maps).Count(&count).Error; err != nil {
relation_map := make(map[string]interface{})
coin_map := make(map[string]interface{})
for key, value := range maps.(map[string]interface{}) {
if ("platform_id" == key || "coin_id" == key) {
relation_map[key] = value
}
if ("condition" == key) {
for k, v := range value.(map[string]interface{}) {
coin_map[k] = v
}
}
}
if err := db.Model(&WalletCoinRelation{}).Where(relation_map).Count(&count).Error; err != nil {
return 0, err
}
......
......@@ -8,6 +8,7 @@ import (
"bwallet/service/coin_service"
"bwallet/service/recommend_coin_service"
"bwallet/validate_service"
"fmt"
"github.com/Unknwon/com"
"github.com/astaxie/beego/validation"
"github.com/gin-gonic/gin"
......@@ -102,13 +103,16 @@ func AddRecommendCoin(c *gin.Context) {
continue
}
existsRecommendCoinService := recommend_coin_service.RecommendCoin{
Cid: coin_id,
PlatformId: platform_id,
recommendCoinValidate := recommend_coin_service.RecommendCoin{
CategoryId: recommend_coin.CategoryId,
PlatformId: platform_id,
Cid: coin_id,
}
existsRecommendCoinService.DeleteByCondition()
total, err := recommendCoinValidate.Count()
if err != nil || total > 0 {
continue
}
recommendCoinService := recommend_coin_service.RecommendCoin{
Cid: coin_id,
Sort: recommend_coin.Sort,
......
......@@ -8,6 +8,7 @@ import (
"bwallet/service/coin_service"
"bwallet/service/wallet_coin_relation_service"
"bwallet/validate_service"
"fmt"
"github.com/Unknwon/com"
"github.com/gin-gonic/gin"
"strconv"
......@@ -106,11 +107,16 @@ func AddWalletCoinRelationCoinRelation(c *gin.Context) {
if err != nil || !exists {
continue
}
relationService := wallet_coin_relation_service.WalletCoinRelation{
PlatformId: coin_relation.PlatformId,
CoinId: coin_id,
PlatformId: coin_relation.PlatformId,
}
relationService.Delete()
total, err := relationService.Count()
if err != nil || total > 0 {
continue
}
relationService.Add()
}
......
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