feat: 新增星册藏品展示

This commit is contained in:
zerosaturation 2026-04-20 18:26:13 +08:00
parent 35ebfa337e
commit 5931040057
8 changed files with 78 additions and 11 deletions

View File

@ -23,6 +23,7 @@ type AssetRegistry struct {
// 公共字段
Status int32 `gorm:"default:0;column:status"`
LikeCount int32 `gorm:"default:0;column:like_count"`
DisplayStatus int32 `gorm:"default:0;column:display_status"` // 展示状态0=待展示, 1=已展示
CreatedAt int64 `gorm:"not null;column:created_at"`
UpdatedAt int64 `gorm:"not null;column:updated_at"`
}

View File

@ -329,8 +329,9 @@ type AssetItem struct {
CoverUrlSigned string `protobuf:"bytes,3,opt,name=cover_url_signed,json=coverUrlSigned,proto3" json:"cover_url_signed,omitempty"` // 预签名封面URL
LikeCount int32 `protobuf:"varint,4,opt,name=like_count,json=likeCount,proto3" json:"like_count,omitempty"`
CreatedAt int64 `protobuf:"varint,5,opt,name=created_at,json=createdAt,proto3" json:"created_at,omitempty"`
Category string `protobuf:"bytes,6,opt,name=category,proto3" json:"category,omitempty"` // regular: 'castlove' / collection: category / activity: activity_type
Grade int32 `protobuf:"varint,7,opt,name=grade,proto3" json:"grade,omitempty"` // 仅 regular 时有效1/2/3...),其他类型为 0
Category string `protobuf:"bytes,6,opt,name=category,proto3" json:"category,omitempty"` // regular: 'castlove' / collection: category / activity: activity_type
Grade int32 `protobuf:"varint,7,opt,name=grade,proto3" json:"grade,omitempty"` // 仅 regular 时有效1/2/3...),其他类型为 0
DisplayStatus int32 `protobuf:"varint,8,opt,name=display_status,json=displayStatus,proto3" json:"display_status,omitempty"` // 展示状态0=待展示, 1=已展示
unknownFields protoimpl.UnknownFields
sizeCache protoimpl.SizeCache
}
@ -414,6 +415,13 @@ func (x *AssetItem) GetGrade() int32 {
return 0
}
func (x *AssetItem) GetDisplayStatus() int32 {
if x != nil {
return x.DisplayStatus
}
return 0
}
// 藏品列表请求
type GetStarbookItemsRequest struct {
state protoimpl.MessageState `protogen:"open.v1"`
@ -647,7 +655,7 @@ const file_starbook_proto_rawDesc = "" +
"\x05items\x18\x02 \x03(\v2\x1b.topfans.starbook.AssetItemR\x05items\x12\x1f\n" +
"\vtotal_count\x18\x03 \x01(\x05R\n" +
"totalCount\x12\x19\n" +
"\bhas_more\x18\x04 \x01(\bR\ahasMore\"\xd4\x01\n" +
"\bhas_more\x18\x04 \x01(\bR\ahasMore\"\xfb\x01\n" +
"\tAssetItem\x12\x19\n" +
"\basset_id\x18\x01 \x01(\x03R\aassetId\x12\x12\n" +
"\x04name\x18\x02 \x01(\tR\x04name\x12(\n" +
@ -657,7 +665,8 @@ const file_starbook_proto_rawDesc = "" +
"\n" +
"created_at\x18\x05 \x01(\x03R\tcreatedAt\x12\x1a\n" +
"\bcategory\x18\x06 \x01(\tR\bcategory\x12\x14\n" +
"\x05grade\x18\a \x01(\x05R\x05grade\"\x90\x01\n" +
"\x05grade\x18\a \x01(\x05R\x05grade\x12%\n" +
"\x0edisplay_status\x18\b \x01(\x05R\rdisplayStatus\"\x90\x01\n" +
"\x17GetStarbookItemsRequest\x12\x12\n" +
"\x04type\x18\x01 \x01(\tR\x04type\x12\x1a\n" +
"\bcategory\x18\x02 \x01(\tR\bcategory\x12\x14\n" +

View File

@ -70,6 +70,7 @@ message AssetItem {
int64 created_at = 5;
string category = 6; // regular: 'castlove' / collection: category / activity: activity_type
int32 grade = 7; // regular 1/2/3... 0
int32 display_status = 8; // 0=, 1=
}
// ==================== ====================

View File

@ -53,7 +53,7 @@ echo ""
# 预先创建目标目录
echo "📁 创建目标目录..."
for name in common user social asset gallery ranking activity task; do
for name in common user social asset gallery ranking activity task starbook; do
mkdir -p "pkg/proto/$name"
done
echo ""
@ -159,6 +159,19 @@ protoc --proto_path=proto \
echo "✅ task.proto 编译完成"
echo ""
# 编译 starbook.proto
echo "📦 编译 starbook.proto ..."
protoc --proto_path=proto \
--proto_path=. \
--go_out=pkg/proto/starbook \
--go_opt=paths=source_relative \
--go-triple_out=pkg/proto/starbook \
--go-triple_opt=paths=source_relative \
starbook.proto
echo "✅ starbook.proto 编译完成"
echo ""
# 清理可能存在的冗余目录和文件
echo "🔄 清理冗余文件..."
@ -169,7 +182,7 @@ if [ -d "github.com" ]; then
fi
# 删除 proto 目录下的生成文件(如果存在)
for name in common user social asset gallery ranking activity task; do
for name in common user social asset gallery ranking activity task starbook; do
if [ -f "proto/$name.pb.go" ]; then
rm "proto/$name.pb.go"
echo " ✅ proto/$name.pb.go 已清理"

View File

@ -71,6 +71,7 @@ CREATE TABLE IF NOT EXISTS asset_registry (
-- 公共字段
status SMALLINT NOT NULL DEFAULT 0,
like_count INT NOT NULL DEFAULT 0,
display_status SMALLINT NOT NULL DEFAULT 0, -- 展示状态0=待展示, 1=已展示
created_at BIGINT NOT NULL,
updated_at BIGINT NOT NULL,

View File

@ -28,6 +28,9 @@ type GalleryRepository interface {
DeleteExhibition(exhibitionID int64) error
DeleteExhibitionByAsset(assetID int64) error
GetExpiredExhibitions(beforeTime int64) ([]*models.Exhibition, error)
// 资产注册表相关
UpdateAssetRegistryDisplayStatus(assetID int64, displayStatus int32) error
}
// galleryRepository Repository实现
@ -192,6 +195,13 @@ func (r *galleryRepository) GetExpiredExhibitions(beforeTime int64) ([]*models.E
return exhibitions, err
}
// UpdateAssetRegistryDisplayStatus 更新资产注册表的展示状态
func (r *galleryRepository) UpdateAssetRegistryDisplayStatus(assetID int64, displayStatus int32) error {
return r.db.Model(&models.AssetRegistry{}).
Where("asset_id = ?", assetID).
Update("display_status", displayStatus).Error
}
// ==================== 辅助函数 ====================
// generateHostProfileID 生成 host_profile_id

View File

@ -321,11 +321,12 @@ func (s *starbookService) buildAssetItemsFromRegistries(registries []*models.Ass
// 构建 items
for _, reg := range registries {
item := &pb.AssetItem{
AssetId: reg.AssetID,
LikeCount: reg.LikeCount,
CreatedAt: reg.CreatedAt,
Category: CastloveCategory,
Grade: 0,
AssetId: reg.AssetID,
LikeCount: reg.LikeCount,
CreatedAt: reg.CreatedAt,
Category: CastloveCategory,
Grade: 0,
DisplayStatus: reg.DisplayStatus,
}
// grade 处理

View File

@ -69,6 +69,9 @@
:src="item.coverUrl"
mode="aspectFill"
/>
<view class="status-badge" :class="item.display_status === 1 ? 'status-badge-active' : 'status-badge-pending'">
<text class="status-text">{{ item.display_status === 1 ? '已展示' : '待展示' }}</text>
</view>
<view class="nft-info">
<text class="nft-name">{{ item.name }}</text>
</view>
@ -108,6 +111,9 @@
:src="item.coverUrl"
mode="aspectFill"
/>
<view class="status-badge" :class="item.display_status === 1 ? 'status-badge-active' : 'status-badge-pending'">
<text class="status-text">{{ item.display_status === 1 ? '已展示' : '待展示' }}</text>
</view>
<view class="nft-info">
<text class="nft-name">{{ item.name }}</text>
<text class="nft-likes">{{ item.like_count }}</text>
@ -147,6 +153,9 @@
:src="item.coverUrl"
mode="aspectFill"
/>
<view class="status-badge" :class="item.display_status === 1 ? 'status-badge-active' : 'status-badge-pending'">
<text class="status-text">{{ item.display_status === 1 ? '已展示' : '待展示' }}</text>
</view>
<view class="nft-info">
<text class="nft-name">{{ item.name }}</text>
<text class="nft-likes">{{ item.like_count }}</text>
@ -550,6 +559,28 @@ watch(() => props.isActive, (newVal) => {
text-align: center;
}
/* 展示状态标签 */
.status-badge {
position: absolute;
top: 8rpx;
right: 8rpx;
border-radius: 8rpx;
padding: 4rpx 8rpx;
z-index: 1;
}
.status-badge-active {
background: linear-gradient(135deg, #FFD700, #FFA500);
box-shadow: 0 0 12rpx rgba(255, 215, 0, 0.6);
}
.status-badge-pending {
background: rgba(0, 0, 0, 0.6);
}
.status-text {
font-size: 18rpx;
color: #fff;
font-weight: bold;
}
.nft-name {
display: block;
font-size: 22rpx;