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 {