397 lines
14 KiB
Protocol Buffer
397 lines
14 KiB
Protocol Buffer
syntax = "proto3";
|
||
|
||
package topfans.asset;
|
||
|
||
option go_package = "github.com/topfans/backend/pkg/proto/asset;asset";
|
||
|
||
import "proto/common.proto";
|
||
import "google/api/annotations.proto";
|
||
|
||
// ==================== 资产域 ====================
|
||
|
||
// 资产信息
|
||
message Asset {
|
||
int64 asset_id = 1; // 资产ID
|
||
int64 owner_uid = 2; // 当前持有者
|
||
int64 star_id = 3; // 所属星球
|
||
string name = 4; // 藏品名称
|
||
string cover_url = 5; // 封面图URL
|
||
string material_url = 6; // 用户上传的素材URL
|
||
string description = 7; // 藏品描述(可选)
|
||
int32 grade = 8; // 星册等级(可选)
|
||
repeated string tags = 9; // 标签数组(可选)
|
||
string visibility = 10; // 可见性:private, friends, public(预留)
|
||
int32 status = 11; // 状态:0=Pending, 1=Active
|
||
string tx_hash = 12; // 交易哈希(可选)
|
||
int64 block_number = 13; // 区块号(可选)
|
||
int32 like_count = 14; // 点赞数
|
||
int64 created_at = 15; // 创建时间(毫秒时间戳)
|
||
int64 updated_at = 16; // 更新时间(毫秒时间戳)
|
||
int64 minted_at = 17; // 上链成功时间(毫秒时间戳,可选)
|
||
|
||
// 扩展字段:持有者信息(用于详情展示)
|
||
OwnerInfo owner = 18; // 持有者信息(保留用于兼容性)
|
||
string owner_nickname = 19; // 持有者昵称(在该star下的昵称)
|
||
bool is_liked = 20; // 当前用户是否已点赞
|
||
string info = 21; // 藏品信息
|
||
}
|
||
|
||
// 持有者信息
|
||
message OwnerInfo {
|
||
int64 user_id = 1; // 用户ID
|
||
string nickname = 2; // 昵称
|
||
string avatar = 3; // 头像URL
|
||
}
|
||
|
||
// 铸造订单信息
|
||
message MintOrder {
|
||
string order_id = 1; // 订单ID(UUID)
|
||
int64 user_id = 2; // 用户ID
|
||
int64 asset_id = 3; // 关联资产ID(可选,创建后回填)
|
||
int64 star_id = 4; // 明星ID
|
||
string status = 5; // 状态:PENDING, PROCESSING, SUCCESS, FAILED
|
||
int64 cost_crystal = 6; // 消耗的水晶数量
|
||
string error_message = 7; // 错误信息(可选)
|
||
int32 retry_count = 8; // 重试次数
|
||
string material_url = 9; // 阶段一保存的素材URL(可选)
|
||
string name = 10; // 阶段一保存的藏品名称(可选)
|
||
string description = 11; // 阶段一保存的藏品描述(可选)
|
||
string material_type = 12; // 素材类型(可选)
|
||
string event = 13; // 藏品事件(可选)
|
||
int64 created_at = 14; // 创建时间(毫秒时间戳)
|
||
int64 updated_at = 15; // 更新时间(毫秒时间戳)
|
||
int64 minted_at = 16; // 上链成功时间(毫秒时间戳,可选)
|
||
string info = 17; // 藏品信息(必填)
|
||
}
|
||
|
||
// ==================== 铸造相关消息 ====================
|
||
|
||
// 阶段一:初始化铸造订单(仅生成并落库 order_id,status=PENDING)
|
||
message InitMintOrderRequest {
|
||
string order_id = 1; // 订单ID(必填,gateway生成或前端传入)
|
||
}
|
||
|
||
message InitMintOrderResponse {
|
||
topfans.common.BaseResponse base = 1;
|
||
MintOrder order = 2; // 订单信息(status=PENDING)
|
||
}
|
||
|
||
// 创建铸造订单请求
|
||
message CreateMintOrderRequest {
|
||
string order_id = 2; // 阶段一生成的订单ID(必填)
|
||
string name = 1; // 藏品名称(可选)
|
||
string material_url = 3; // 用户上传的素材URL(必填,前端已上传到OSS)
|
||
string description = 4; // 藏品描述(可选)
|
||
int32 grade = 5; // 星册等级(可选)
|
||
repeated string tags = 6; // 标签列表(可选)
|
||
string material_type = 7; // 素材类型(可选)
|
||
string info = 8; // 藏品信息(必填)
|
||
// cover_url 不再需要前端传入,由后端 AI 处理完成后自动生成
|
||
}
|
||
|
||
// ==================== 阶段一:预创建订单(返回 order_id) ====================
|
||
|
||
message PreCreateMintOrderRequest {
|
||
string name = 1; // 藏品名称(可选)
|
||
string material_url = 2; // 素材URL(必填)
|
||
string description = 3; // 描述(可选)
|
||
string material_type = 4; // 素材类型(可选)
|
||
string event = 5; // 藏品事件(可选)
|
||
}
|
||
|
||
message PreCreateMintOrderResponse {
|
||
topfans.common.BaseResponse base = 1;
|
||
MintOrder order = 2; // 预创建的订单信息(status=PENDING)
|
||
}
|
||
|
||
// 创建铸造订单响应
|
||
message CreateMintOrderResponse {
|
||
topfans.common.BaseResponse base = 1;
|
||
MintOrder order = 2; // 创建的订单信息
|
||
Asset asset = 3; // 创建的资产信息
|
||
}
|
||
|
||
// ==================== 资产查询相关消息 ====================
|
||
|
||
// 获取我的藏品列表请求
|
||
message GetMyAssetsRequest {
|
||
int32 page = 1; // 页码(默认1)
|
||
int32 page_size = 2; // 每页数量(默认20,最大100)
|
||
string status = 3; // 状态筛选:all, pending, minted, failed(可选)
|
||
string keyword = 4; // 关键词搜索(资产名称,可选)
|
||
string sort = 5; // 排序方式:created_at_desc, created_at_asc, name_asc(可选,默认created_at_desc)
|
||
}
|
||
|
||
// 获取我的藏品列表响应
|
||
message GetMyAssetsResponse {
|
||
topfans.common.BaseResponse base = 1;
|
||
AssetListData data = 2; // 分组后的藏品数据
|
||
}
|
||
|
||
// 藏品列表数据(与星册home一致的结构)
|
||
message AssetListData {
|
||
repeated AssetGroup groups = 1; // 分组列表
|
||
int64 total = 2; // 总数
|
||
int32 page = 3; // 当前页码
|
||
int32 page_size = 4; // 每页数量
|
||
bool has_more = 5; // 是否有更多
|
||
}
|
||
|
||
// 资产分组(与星册home一致)
|
||
message AssetGroup {
|
||
string type = 1; // 'regular' / 'collection' / 'activity'
|
||
string category = 2; // 'castlove'(regular) / collection_category / activity_type
|
||
string category_name = 3;
|
||
repeated GradeSection grades = 4; // 仅 regular 时有效
|
||
repeated AssetItem items = 5; // collection / activity 时有效
|
||
int32 total_count = 6;
|
||
bool has_more = 7;
|
||
}
|
||
|
||
// 等级分组(仅 regular 类型使用)
|
||
message GradeSection {
|
||
int32 grade = 1; // 等级:1/2/3/4/5...
|
||
repeated AssetItem items = 2;
|
||
int32 total_count = 3;
|
||
bool has_more = 4;
|
||
}
|
||
|
||
// 资产项(与星册home一致)
|
||
message AssetItem {
|
||
int64 asset_id = 1;
|
||
string name = 2;
|
||
string cover_url_signed = 3; // 预签名封面URL
|
||
int32 like_count = 4;
|
||
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=已展示
|
||
}
|
||
|
||
// 资产列表项(简化版,用于列表展示 - 保留兼容)
|
||
message AssetListItem {
|
||
int64 asset_id = 1; // 资产ID
|
||
string name = 2; // 藏品名称
|
||
string cover_url = 3; // 封面图URL
|
||
string status = 4; // 状态:pending, minting, minted, failed
|
||
string tx_hash = 5; // 交易哈希(可选)
|
||
int64 created_at = 6; // 创建时间(毫秒时间戳)
|
||
int64 minted_at = 7; // 上链成功时间(毫秒时间戳,可选)
|
||
int32 like_count = 8; // 点赞数
|
||
}
|
||
|
||
// 获取资产详情请求
|
||
message GetAssetRequest {
|
||
int64 asset_id = 1; // 资产ID
|
||
}
|
||
|
||
// 获取资产详情响应
|
||
message GetAssetResponse {
|
||
topfans.common.BaseResponse base = 1;
|
||
Asset asset = 2; // 资产详细信息(包含is_liked字段)
|
||
}
|
||
|
||
// 查询上链状态请求
|
||
message GetAssetStatusRequest {
|
||
int64 asset_id = 1; // 资产ID
|
||
}
|
||
|
||
// 查询上链状态响应
|
||
message GetAssetStatusResponse {
|
||
topfans.common.BaseResponse base = 1;
|
||
int64 asset_id = 2; // 资产ID
|
||
string status = 3; // 状态:pending, minting, minted, failed
|
||
string tx_hash = 4; // 交易哈希(可选)
|
||
int64 block_number = 5; // 区块号(可选)
|
||
int64 minted_at = 6; // 上链成功时间(毫秒时间戳,可选)
|
||
string error_message = 7; // 错误信息(如果失败,可选)
|
||
}
|
||
|
||
// 查询铸造订单状态请求
|
||
message GetMintOrderRequest {
|
||
string order_id = 1; // 订单ID(必填)
|
||
}
|
||
|
||
// 查询铸造订单状态响应
|
||
message GetMintOrderResponse {
|
||
topfans.common.BaseResponse base = 1;
|
||
MintOrder order = 2; // 订单信息
|
||
Asset asset = 3; // 关联的资产信息(如果存在)
|
||
}
|
||
|
||
// 取消铸造订单请求
|
||
message CancelMintOrderRequest {
|
||
string order_id = 1; // 订单ID(必填)
|
||
}
|
||
|
||
// 取消铸造订单响应
|
||
message CancelMintOrderResponse {
|
||
topfans.common.BaseResponse base = 1;
|
||
string order_id = 2; // 订单ID
|
||
string status = 3; // 订单状态(CANCELLED)
|
||
}
|
||
|
||
// ==================== 点赞相关消息 ====================
|
||
|
||
// 点赞资产请求(内部RPC,供Social Service调用)
|
||
message LikeAssetRequest {
|
||
int64 asset_id = 1; // 资产ID
|
||
}
|
||
|
||
// 点赞资产响应
|
||
message LikeAssetResponse {
|
||
topfans.common.BaseResponse base = 1;
|
||
int32 like_count = 2; // 点赞后的总数
|
||
}
|
||
|
||
// 取消点赞资产请求(内部RPC,供Social Service调用)
|
||
message UnlikeAssetRequest {
|
||
int64 asset_id = 1; // 资产ID
|
||
}
|
||
|
||
// 取消点赞资产响应
|
||
message UnlikeAssetResponse {
|
||
topfans.common.BaseResponse base = 1;
|
||
int32 like_count = 2; // 取消点赞后的总数
|
||
}
|
||
|
||
// 检查是否已点赞请求(内部RPC,供Social Service调用)
|
||
message CheckAssetLikeRequest {
|
||
int64 asset_id = 1; // 资产ID
|
||
}
|
||
|
||
// 检查是否已点赞响应
|
||
message CheckAssetLikeResponse {
|
||
topfans.common.BaseResponse base = 1;
|
||
bool is_liked = 2; // 是否已点赞
|
||
}
|
||
|
||
// 点赞记录信息
|
||
message AssetLike {
|
||
int64 id = 1; // 点赞记录ID
|
||
int64 asset_id = 2; // 资产ID
|
||
int64 user_id = 3; // 用户ID
|
||
int64 star_id = 4; // 明星ID
|
||
int64 created_at = 5; // 点赞时间(毫秒时间戳)
|
||
}
|
||
|
||
// 获取资产点赞列表请求(内部RPC,供Social Service调用)
|
||
message GetAssetLikesRequest {
|
||
int64 asset_id = 1; // 资产ID
|
||
int32 page = 2; // 页码(默认1)
|
||
int32 page_size = 3; // 每页数量(默认20,最大100)
|
||
}
|
||
|
||
// 获取资产点赞列表响应
|
||
message GetAssetLikesResponse {
|
||
topfans.common.BaseResponse base = 1;
|
||
repeated AssetLike likes = 2; // 点赞列表
|
||
int64 total = 3; // 总数
|
||
int32 page = 4; // 当前页码
|
||
int32 page_size = 5; // 每页数量
|
||
bool has_more = 6; // 是否有更多
|
||
}
|
||
|
||
// ==================== 内部RPC消息(供其他服务调用)====================
|
||
|
||
// 获取资产信息请求(内部RPC,供Social Service调用)
|
||
message GetAssetForRPCRequest {
|
||
int64 asset_id = 1; // 资产ID
|
||
}
|
||
|
||
// 获取资产信息响应(内部RPC)
|
||
message GetAssetForRPCResponse {
|
||
topfans.common.BaseResponse base = 1;
|
||
int64 asset_id = 2; // 资产ID
|
||
int64 owner_uid = 3; // 持有者ID
|
||
int64 star_id = 4; // 明星ID
|
||
int32 status = 5; // 状态:0=Pending, 1=Active
|
||
bool is_active = 6; // 是否激活
|
||
}
|
||
|
||
// ==================== 资产服务 ====================
|
||
|
||
service AssetService {
|
||
// 阶段一:初始化订单(生成并落库 order_id;由 /api/v1/assets/oss/signature 触发)
|
||
rpc InitMintOrder(InitMintOrderRequest) returns (InitMintOrderResponse);
|
||
|
||
// 阶段一:预创建订单(生成 order_id,让前端决定是否继续铸造)
|
||
rpc PreCreateMintOrder(PreCreateMintOrderRequest) returns (PreCreateMintOrderResponse) {
|
||
option (google.api.http) = {
|
||
post: "/api/v1/assets/mints/precreate"
|
||
body: "*"
|
||
};
|
||
}
|
||
|
||
// 创建铸造订单
|
||
rpc CreateMintOrder(CreateMintOrderRequest) returns (CreateMintOrderResponse) {
|
||
option (google.api.http) = {
|
||
post: "/api/v1/assets/mints"
|
||
body: "*"
|
||
};
|
||
}
|
||
|
||
// 获取我的藏品列表
|
||
rpc GetMyAssets(GetMyAssetsRequest) returns (GetMyAssetsResponse) {
|
||
option (google.api.http) = {
|
||
get: "/api/v1/assets/me"
|
||
};
|
||
}
|
||
|
||
// 获取资产详情
|
||
rpc GetAsset(GetAssetRequest) returns (GetAssetResponse) {
|
||
option (google.api.http) = {
|
||
get: "/api/v1/assets/{asset_id}"
|
||
};
|
||
}
|
||
|
||
// 查询上链状态
|
||
rpc GetAssetStatus(GetAssetStatusRequest) returns (GetAssetStatusResponse) {
|
||
option (google.api.http) = {
|
||
get: "/api/v1/assets/{asset_id}/status"
|
||
};
|
||
}
|
||
|
||
// 查询铸造订单状态
|
||
rpc GetMintOrder(GetMintOrderRequest) returns (GetMintOrderResponse) {
|
||
option (google.api.http) = {
|
||
get: "/api/v1/assets/mints/{order_id}"
|
||
};
|
||
}
|
||
|
||
// 取消铸造订单
|
||
rpc CancelMintOrder(CancelMintOrderRequest) returns (CancelMintOrderResponse) {
|
||
option (google.api.http) = {
|
||
delete: "/api/v1/assets/mints/{order_id}"
|
||
};
|
||
}
|
||
|
||
// 内部RPC:获取资产信息(供Social Service调用,用于验证资产是否存在)
|
||
rpc GetAssetForRPC(GetAssetForRPCRequest) returns (GetAssetForRPCResponse);
|
||
|
||
// 内部RPC:点赞资产(供Social Service调用)
|
||
rpc LikeAsset(LikeAssetRequest) returns (LikeAssetResponse);
|
||
|
||
// 内部RPC:取消点赞资产(供Social Service调用)
|
||
rpc UnlikeAsset(UnlikeAssetRequest) returns (UnlikeAssetResponse);
|
||
|
||
// 内部RPC:检查是否已点赞(供Social Service调用)
|
||
rpc CheckAssetLike(CheckAssetLikeRequest) returns (CheckAssetLikeResponse);
|
||
|
||
// 内部RPC:获取资产点赞列表(供Social Service调用)
|
||
rpc GetAssetLikes(GetAssetLikesRequest) returns (GetAssetLikesResponse);
|
||
|
||
// 内部RPC:清除资产点赞记录(供Gallery Service调用,下架时清除记录以便下次展出可再次点赞)
|
||
rpc ClearAssetLikeRecords(ClearAssetLikeRecordsRequest) returns (ClearAssetLikeRecordsResponse);
|
||
}
|
||
|
||
// 清除资产点赞记录请求(内部RPC,供Gallery Service调用)
|
||
message ClearAssetLikeRecordsRequest {
|
||
int64 asset_id = 1; // 资产ID
|
||
}
|
||
|
||
// 清除资产点赞记录响应
|
||
message ClearAssetLikeRecordsResponse {
|
||
topfans.common.BaseResponse base = 1;
|
||
}
|