From 956be17a4e27c36242e8e9e9779b76e617d12a58 Mon Sep 17 00:00:00 2001 From: zerosaturation Date: Tue, 21 Apr 2026 13:26:54 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=96=B0=E5=A2=9E=E8=BD=AF=E5=88=A0?= =?UTF-8?q?=E9=99=A4=EF=BC=8C=E7=95=99=E6=9C=89=E8=AE=B0=E5=BD=95=E4=BF=9D?= =?UTF-8?q?=E5=AD=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/pkg/models/gallery.go | 21 +++++------ .../repository/ranking_repository.go | 16 ++++----- .../repository/gallery_repository.go | 36 ++++++++++++------- frontend/pages/components/NftCard.vue | 4 +-- frontend/pages/square/square.vue | 3 ++ 5 files changed, 48 insertions(+), 32 deletions(-) diff --git a/backend/pkg/models/gallery.go b/backend/pkg/models/gallery.go index 4d123d1..f7b4b2e 100644 --- a/backend/pkg/models/gallery.go +++ b/backend/pkg/models/gallery.go @@ -22,16 +22,17 @@ func (BoothSlot) TableName() string { // Exhibition 展品展示表 type Exhibition struct { - ID int64 `gorm:"primaryKey;column:id;autoIncrement"` - AssetID int64 `gorm:"column:asset_id;not null;uniqueIndex:uk_asset"` - SlotID int64 `gorm:"column:slot_id;not null;index:idx_slot"` - HostProfileID int64 `gorm:"column:host_profile_id;not null;index:idx_host"` - OccupierUID int64 `gorm:"column:occupier_uid;not null;index:idx_occupier"` - OccupierStarID int64 `gorm:"column:occupier_star_id;not null;index:idx_occupier"` - StartTime int64 `gorm:"column:start_time;not null"` - ExpireAt int64 `gorm:"column:expire_at;not null;index:idx_expire"` - CreatedAt int64 `gorm:"column:created_at;not null"` - UpdatedAt int64 `gorm:"column:updated_at;not null"` + ID int64 `gorm:"primaryKey;column:id;autoIncrement"` + AssetID int64 `gorm:"column:asset_id;not null;uniqueIndex:uk_asset"` + SlotID int64 `gorm:"column:slot_id;not null;index:idx_slot"` + HostProfileID int64 `gorm:"column:host_profile_id;not null;index:idx_host"` + OccupierUID int64 `gorm:"column:occupier_uid;not null;index:idx_occupier"` + OccupierStarID int64 `gorm:"column:occupier_star_id;not null;index:idx_occupier"` + StartTime int64 `gorm:"column:start_time;not null"` + ExpireAt int64 `gorm:"column:expire_at;not null;index:idx_expire"` + CreatedAt int64 `gorm:"column:created_at;not null"` + UpdatedAt int64 `gorm:"column:updated_at;not null"` + DeletedAt *int64 `gorm:"column:deleted_at"` } // TableName 指定表名 diff --git a/backend/services/assetService/repository/ranking_repository.go b/backend/services/assetService/repository/ranking_repository.go index 88b8355..5079b0c 100644 --- a/backend/services/assetService/repository/ranking_repository.go +++ b/backend/services/assetService/repository/ranking_repository.go @@ -118,9 +118,9 @@ func (r *rankingRepository) getHotRankingByDimension(starID int64, dimension str Where("exhibitions.expire_at > ?", now). Where("fan_profiles.star_id = ?", starID) case "month": - // 本月:本月内开始的展览,按点赞数排序 + // 本月:本月内展览过的(未下架或本月内下架的) db = db.Joins("INNER JOIN exhibitions ON exhibitions.asset_id = assets.id"). - Where("exhibitions.start_time >= ?", startOfMonth) + Where("exhibitions.expire_at >= ?", startOfMonth) case "total": // 全部:直接使用 assets 表的 like_count,无需额外条件 } @@ -141,9 +141,9 @@ func (r *rankingRepository) getHotRankingByDimension(starID int64, dimension str Where("exhibitions.expire_at > ?", now). Where("host_fp.star_id = ?", starID) case "month": - // 本月:本月内开始的展览 + // 本月:本月内展览过的(未下架或本月内下架的) countDB = countDB.Joins("INNER JOIN exhibitions ON exhibitions.asset_id = assets.id"). - Where("exhibitions.start_time >= ?", startOfMonth) + Where("exhibitions.expire_at >= ?", startOfMonth) } if err := countDB.Count(&total).Error; err != nil { return nil, 0, err @@ -193,9 +193,9 @@ func (r *rankingRepository) GetMyBestRanking(userID, starID int64, dimension str Where("exhibitions.expire_at > ?", now). Where("host_fp.star_id = ?", starID) case "month": - // 本月:本月内开始的展览 + // 本月:本月内展览过的(未下架或本月内下架的) db = db.Joins("INNER JOIN exhibitions ON exhibitions.asset_id = assets.id"). - Where("exhibitions.start_time >= ?", startOfMonth) + Where("exhibitions.expire_at >= ?", startOfMonth) } // 获取用户在该star下点赞数最高的藏品 @@ -236,9 +236,9 @@ func (r *rankingRepository) GetMyBestRanking(userID, starID int64, dimension str Where("exhibitions.expire_at > ?", now). Where("host_fp.star_id = ?", starID) case "month": - // 本月:本月内开始的展览 + // 本月:本月内展览过的(未下架或本月内下架的) rankingDB = rankingDB.Joins("INNER JOIN exhibitions ON exhibitions.asset_id = assets.id"). - Where("exhibitions.start_time >= ?", startOfMonth) + Where("exhibitions.expire_at >= ?", startOfMonth) } if err := rankingDB.Count(&rank).Error; err != nil { diff --git a/backend/services/galleryService/repository/gallery_repository.go b/backend/services/galleryService/repository/gallery_repository.go index 9a929b9..72dd41b 100644 --- a/backend/services/galleryService/repository/gallery_repository.go +++ b/backend/services/galleryService/repository/gallery_repository.go @@ -136,10 +136,10 @@ func (r *galleryRepository) UnlockSlot(slotID int64) error { // ==================== 展品相关 ==================== -// GetExhibitionByAsset 根据资产ID获取展品展示记录 +// GetExhibitionByAsset 根据资产ID获取展品展示记录(不含已删除) func (r *galleryRepository) GetExhibitionByAsset(assetID int64) (*models.Exhibition, error) { var exhibition models.Exhibition - err := r.db.Where("asset_id = ?", assetID).First(&exhibition).Error + err := r.db.Where("asset_id = ? AND deleted_at IS NULL", assetID).First(&exhibition).Error if err != nil { if errors.Is(err, gorm.ErrRecordNotFound) { return nil, nil // 未找到记录,返回 nil(不是错误) @@ -149,10 +149,10 @@ func (r *galleryRepository) GetExhibitionByAsset(assetID int64) (*models.Exhibit return &exhibition, nil } -// GetExhibitionBySlot 根据展位ID获取展品展示记录 +// GetExhibitionBySlot 根据展位ID获取展品展示记录(不含已删除) func (r *galleryRepository) GetExhibitionBySlot(slotID int64) (*models.Exhibition, error) { var exhibition models.Exhibition - err := r.db.Where("slot_id = ?", slotID).First(&exhibition).Error + err := r.db.Where("slot_id = ? AND deleted_at IS NULL", slotID).First(&exhibition).Error if err != nil { if errors.Is(err, gorm.ErrRecordNotFound) { return nil, nil // 未找到记录,返回 nil(不是错误) @@ -162,10 +162,10 @@ func (r *galleryRepository) GetExhibitionBySlot(slotID int64) (*models.Exhibitio return &exhibition, nil } -// GetExhibitionsByUser 获取用户的所有展品展示记录 +// GetExhibitionsByUser 获取用户的所有展品展示记录(不含已删除) func (r *galleryRepository) GetExhibitionsByUser(userID, starID int64) ([]*models.Exhibition, error) { var exhibitions []*models.Exhibition - err := r.db.Where("occupier_uid = ? AND occupier_star_id = ?", userID, starID). + err := r.db.Where("occupier_uid = ? AND occupier_star_id = ? AND deleted_at IS NULL", userID, starID). Find(&exhibitions).Error return exhibitions, err } @@ -178,20 +178,32 @@ func (r *galleryRepository) CreateExhibition(exhibition *models.Exhibition) erro return r.db.Create(exhibition).Error } -// DeleteExhibition 删除展品展示记录(根据ID) +// DeleteExhibition 软删除展品展示记录(根据ID) func (r *galleryRepository) DeleteExhibition(exhibitionID int64) error { - return r.db.Where("id = ?", exhibitionID).Delete(&models.Exhibition{}).Error + now := time.Now().UnixMilli() + return r.db.Model(&models.Exhibition{}). + Where("id = ?", exhibitionID). + Updates(map[string]interface{}{ + "deleted_at": now, + "updated_at": now, + }).Error } -// DeleteExhibitionByAsset 删除展品展示记录(根据资产ID) +// DeleteExhibitionByAsset 软删除展品展示记录(根据资产ID) func (r *galleryRepository) DeleteExhibitionByAsset(assetID int64) error { - return r.db.Where("asset_id = ?", assetID).Delete(&models.Exhibition{}).Error + now := time.Now().UnixMilli() + return r.db.Model(&models.Exhibition{}). + Where("asset_id = ?", assetID). + Updates(map[string]interface{}{ + "deleted_at": now, + "updated_at": now, + }).Error } -// GetExpiredExhibitions 获取过期的展品展示记录 +// GetExpiredExhibitions 获取过期的展品展示记录(不含已删除) func (r *galleryRepository) GetExpiredExhibitions(beforeTime int64) ([]*models.Exhibition, error) { var exhibitions []*models.Exhibition - err := r.db.Where("expire_at <= ?", beforeTime).Find(&exhibitions).Error + err := r.db.Where("expire_at <= ? AND deleted_at IS NULL", beforeTime).Find(&exhibitions).Error return exhibitions, err } diff --git a/frontend/pages/components/NftCard.vue b/frontend/pages/components/NftCard.vue index 12e3dca..b1a13ce 100644 --- a/frontend/pages/components/NftCard.vue +++ b/frontend/pages/components/NftCard.vue @@ -196,8 +196,8 @@ const handleAddClick = () => { top: 50%; left: 50%; transform: translate(-50%, -50%); - width: 40%; - height: 40%; + width: 25%; + height: 25%; display: flex; align-items: center; justify-content: center; diff --git a/frontend/pages/square/square.vue b/frontend/pages/square/square.vue index df7a063..e00fbb2 100644 --- a/frontend/pages/square/square.vue +++ b/frontend/pages/square/square.vue @@ -182,6 +182,9 @@ const handleCabinClick = (cabin) => { const handleTabChange = (newTab) => { if (newTab === 0) { navExpanded.value = false + uni.navigateTo({ + url: '/pages/square/square' + }) return }