From cb685877d466379f311e734fb51db92a73a65448 Mon Sep 17 00:00:00 2001 From: liangjies <1139629972@qq.com> Date: Fri, 2 Aug 2024 23:10:37 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E5=90=88=E9=9B=86=20Badge=20Token=20ID?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- internal/app/dao/collection.go | 6 ++++-- internal/app/model/response/collection.go | 4 +++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/internal/app/dao/collection.go b/internal/app/dao/collection.go index c50a564..b757a85 100644 --- a/internal/app/dao/collection.go +++ b/internal/app/dao/collection.go @@ -52,7 +52,8 @@ func (d *Dao) GetCollectionQuest(r request.GetCollectionQuestRequest) (questList collectionID, idErr := cast.ToUintE(r.ID) if idErr == nil { // 查询合辑信息 - err = d.db.Model(&model.Collection{}).Select("collection.*,COALESCE(tr.title,collection.title) as title,COALESCE(tr.description,collection.description) as description"). + err = d.db.Model(&model.Collection{}).Select("collection.*,COALESCE(tr.title,collection.title) as title,COALESCE(tr.description,collection.description) as description,b.badge_token_id,b.chain_id as badge_chain_id"). + Joins("left join user_challenges b ON collection.token_id=b.token_id AND b.address= ?", r.Address). Joins("LEFT JOIN collection_translated as tr ON collection.id = tr.collection_id AND tr.language = ?", r.Language). Where("collection.id", collectionID).First(&collection).Error if err != nil { @@ -60,7 +61,8 @@ func (d *Dao) GetCollectionQuest(r request.GetCollectionQuestRequest) (questList } } else { // 查询合辑信息 - err = d.db.Model(&model.Collection{}).Select("collection.*,COALESCE(tr.title,collection.title) as title,COALESCE(tr.description,collection.description) as description"). + err = d.db.Model(&model.Collection{}).Select("collection.*,COALESCE(tr.title,collection.title) as title,COALESCE(tr.description,collection.description) as description,b.badge_token_id,b.chain_id as badge_chain_id"). + Joins("left join user_challenges b ON collection.token_id=b.token_id AND b.address= ?", r.Address). Joins("LEFT JOIN collection_translated as tr ON collection.id = tr.collection_id AND tr.language = ?", r.Language). Where("collection.uuid", r.ID).First(&collection).Error if err != nil { diff --git a/internal/app/model/response/collection.go b/internal/app/model/response/collection.go index 8c44708..9922ad0 100644 --- a/internal/app/model/response/collection.go +++ b/internal/app/model/response/collection.go @@ -27,7 +27,9 @@ type GetCollectionChallengeUserPageDataResult struct { type GetCollectionRes struct { model.Collection - Claimed bool `gorm:"-" json:"claimed"` + Claimed bool `gorm:"-" json:"claimed"` + BadgeTokenID string `gorm:"column:badge_token_id" json:"badge_token_id"` + BadgeChainID int64 `gorm:"column:badge_chain_id" json:"badge_chain_id"` } type CheckQuestInCollectionRes struct {