fix: 补全 ShopProfile 和 Post 响应中缺失的后端字段
ShopProfile 补上 allowMultiShop/allowIndependentOrders/dispatchMode,Post 补上 pinned/linkedOrderId。这些字段在 RPC proto、数据库和写入逻辑中均已存在,但 API 响应类型和映射函数遗漏了它们。同时补回 community.api 中 CreateCommentReq 的 PostId 字段定义。
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
// Code generated by goctl. DO NOT EDIT.
|
// Code generated by goctl. DO NOT EDIT.
|
||||||
// goctl 1.9.2
|
// goctl 1.10.1
|
||||||
|
|
||||||
package handler
|
package handler
|
||||||
|
|
||||||
|
|||||||
@@ -44,16 +44,18 @@ func buildUserProfile(ctx context.Context, svcCtx *svc.ServiceContext, userID in
|
|||||||
|
|
||||||
func mapPost(ctx context.Context, svcCtx *svc.ServiceContext, p *communitypb.Posts, liked bool) types.Post {
|
func mapPost(ctx context.Context, svcCtx *svc.ServiceContext, p *communitypb.Posts, liked bool) types.Post {
|
||||||
return types.Post{
|
return types.Post{
|
||||||
Id: p.GetId(),
|
Id: p.GetId(),
|
||||||
Title: p.GetTitle(),
|
Title: p.GetTitle(),
|
||||||
Content: p.GetContent(),
|
Content: p.GetContent(),
|
||||||
Images: append([]string(nil), p.GetImages()...),
|
Images: append([]string(nil), p.GetImages()...),
|
||||||
Tags: append([]string(nil), p.GetTags()...),
|
Tags: append([]string(nil), p.GetTags()...),
|
||||||
LikeCount: p.GetLikeCount(),
|
LinkedOrderId: p.GetLinkedOrderId(),
|
||||||
CommentCount: p.GetCommentCount(),
|
Pinned: p.GetPinned(),
|
||||||
Liked: liked,
|
LikeCount: p.GetLikeCount(),
|
||||||
Author: buildUserProfile(ctx, svcCtx, p.GetAuthorId()),
|
CommentCount: p.GetCommentCount(),
|
||||||
CreatedAt: time.Unix(p.GetCreatedAt(), 0).UTC().Format(time.RFC3339),
|
Liked: liked,
|
||||||
|
Author: buildUserProfile(ctx, svcCtx, p.GetAuthorId()),
|
||||||
|
CreatedAt: time.Unix(p.GetCreatedAt(), 0).UTC().Format(time.RFC3339),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
// Code generated by goctl. DO NOT EDIT.
|
// Code generated by goctl. DO NOT EDIT.
|
||||||
// goctl 1.9.2
|
// goctl 1.10.1
|
||||||
|
|
||||||
package types
|
package types
|
||||||
|
|
||||||
@@ -54,16 +54,18 @@ type PathId struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type Post struct {
|
type Post struct {
|
||||||
Id int64 `json:"id"`
|
Id int64 `json:"id"`
|
||||||
Title string `json:"title"`
|
Title string `json:"title"`
|
||||||
Content string `json:"content"`
|
Content string `json:"content"`
|
||||||
Images []string `json:"images"`
|
Images []string `json:"images"`
|
||||||
Tags []string `json:"tags"`
|
Tags []string `json:"tags"`
|
||||||
LikeCount int64 `json:"likeCount"`
|
LinkedOrderId int64 `json:"linkedOrderId,optional"`
|
||||||
CommentCount int64 `json:"commentCount"`
|
Pinned bool `json:"pinned"`
|
||||||
Liked bool `json:"liked"`
|
LikeCount int64 `json:"likeCount"`
|
||||||
Author UserProfile `json:"author"`
|
CommentCount int64 `json:"commentCount"`
|
||||||
CreatedAt string `json:"createdAt"`
|
Liked bool `json:"liked"`
|
||||||
|
Author UserProfile `json:"author"`
|
||||||
|
CreatedAt string `json:"createdAt"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type PostListReq struct {
|
type PostListReq struct {
|
||||||
|
|||||||
@@ -36,16 +36,19 @@ func toShopProfile(in *pb.Shops) *types.ShopProfile {
|
|||||||
VerificationStatus: map[string]string{},
|
VerificationStatus: map[string]string{},
|
||||||
CreatedAt: "",
|
CreatedAt: "",
|
||||||
},
|
},
|
||||||
Name: in.Name,
|
Name: in.Name,
|
||||||
Banner: in.Banner,
|
Banner: in.Banner,
|
||||||
Description: in.Description,
|
Description: in.Description,
|
||||||
Rating: in.Rating,
|
Rating: in.Rating,
|
||||||
TotalOrders: in.TotalOrders,
|
TotalOrders: in.TotalOrders,
|
||||||
PlayerCount: in.PlayerCount,
|
PlayerCount: in.PlayerCount,
|
||||||
CommissionType: in.CommissionType,
|
CommissionType: in.CommissionType,
|
||||||
CommissionValue: in.CommissionValue,
|
CommissionValue: in.CommissionValue,
|
||||||
Announcements: in.Announcements,
|
AllowMultiShop: in.AllowMultiShop,
|
||||||
TemplateConfig: template,
|
AllowIndependentOrders: in.AllowIndependentOrders,
|
||||||
|
DispatchMode: in.DispatchMode,
|
||||||
|
Announcements: in.Announcements,
|
||||||
|
TemplateConfig: template,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -80,18 +80,21 @@ type ShopListResp struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type ShopProfile struct {
|
type ShopProfile struct {
|
||||||
Id string `json:"id"`
|
Id string `json:"id"`
|
||||||
Owner UserProfile `json:"owner"`
|
Owner UserProfile `json:"owner"`
|
||||||
Name string `json:"name"`
|
Name string `json:"name"`
|
||||||
Banner string `json:"banner,optional"`
|
Banner string `json:"banner,optional"`
|
||||||
Description string `json:"description"`
|
Description string `json:"description"`
|
||||||
Rating string `json:"rating"`
|
Rating string `json:"rating"`
|
||||||
TotalOrders int64 `json:"totalOrders"`
|
TotalOrders int64 `json:"totalOrders"`
|
||||||
PlayerCount int64 `json:"playerCount"`
|
PlayerCount int64 `json:"playerCount"`
|
||||||
CommissionType string `json:"commissionType"`
|
CommissionType string `json:"commissionType"`
|
||||||
CommissionValue string `json:"commissionValue"`
|
CommissionValue string `json:"commissionValue"`
|
||||||
Announcements []string `json:"announcements"`
|
AllowMultiShop bool `json:"allowMultiShop"`
|
||||||
TemplateConfig interface{} `json:"templateConfig"`
|
AllowIndependentOrders bool `json:"allowIndependentOrders"`
|
||||||
|
DispatchMode string `json:"dispatchMode"`
|
||||||
|
Announcements []string `json:"announcements"`
|
||||||
|
TemplateConfig interface{} `json:"templateConfig"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type SimpleUser struct {
|
type SimpleUser struct {
|
||||||
|
|||||||
+13
-10
@@ -7,16 +7,18 @@ type (
|
|||||||
Id int64 `path:"id"`
|
Id int64 `path:"id"`
|
||||||
}
|
}
|
||||||
Post {
|
Post {
|
||||||
Id int64 `json:"id"`
|
Id int64 `json:"id"`
|
||||||
Title string `json:"title"`
|
Title string `json:"title"`
|
||||||
Content string `json:"content"`
|
Content string `json:"content"`
|
||||||
Images []string `json:"images"`
|
Images []string `json:"images"`
|
||||||
Tags []string `json:"tags"`
|
Tags []string `json:"tags"`
|
||||||
LikeCount int64 `json:"likeCount"`
|
LinkedOrderId int64 `json:"linkedOrderId,optional"`
|
||||||
CommentCount int64 `json:"commentCount"`
|
Pinned bool `json:"pinned"`
|
||||||
Liked bool `json:"liked"`
|
LikeCount int64 `json:"likeCount"`
|
||||||
Author UserProfile `json:"author"`
|
CommentCount int64 `json:"commentCount"`
|
||||||
CreatedAt string `json:"createdAt"`
|
Liked bool `json:"liked"`
|
||||||
|
Author UserProfile `json:"author"`
|
||||||
|
CreatedAt string `json:"createdAt"`
|
||||||
}
|
}
|
||||||
CreatePostReq {
|
CreatePostReq {
|
||||||
Title string `json:"title"`
|
Title string `json:"title"`
|
||||||
@@ -47,6 +49,7 @@ type (
|
|||||||
Meta PageMeta `json:"meta"`
|
Meta PageMeta `json:"meta"`
|
||||||
}
|
}
|
||||||
CreateCommentReq {
|
CreateCommentReq {
|
||||||
|
PostId int64 `json:"-"`
|
||||||
Content string `json:"content"`
|
Content string `json:"content"`
|
||||||
}
|
}
|
||||||
ListCommentsReq {
|
ListCommentsReq {
|
||||||
|
|||||||
+15
-12
@@ -4,18 +4,21 @@ import "common.api"
|
|||||||
|
|
||||||
type (
|
type (
|
||||||
ShopProfile {
|
ShopProfile {
|
||||||
Id string `json:"id"`
|
Id string `json:"id"`
|
||||||
Owner UserProfile `json:"owner"`
|
Owner UserProfile `json:"owner"`
|
||||||
Name string `json:"name"`
|
Name string `json:"name"`
|
||||||
Banner string `json:"banner,optional"`
|
Banner string `json:"banner,optional"`
|
||||||
Description string `json:"description"`
|
Description string `json:"description"`
|
||||||
Rating string `json:"rating"`
|
Rating string `json:"rating"`
|
||||||
TotalOrders int64 `json:"totalOrders"`
|
TotalOrders int64 `json:"totalOrders"`
|
||||||
PlayerCount int64 `json:"playerCount"`
|
PlayerCount int64 `json:"playerCount"`
|
||||||
CommissionType string `json:"commissionType"`
|
CommissionType string `json:"commissionType"`
|
||||||
CommissionValue string `json:"commissionValue"`
|
CommissionValue string `json:"commissionValue"`
|
||||||
Announcements []string `json:"announcements"`
|
AllowMultiShop bool `json:"allowMultiShop"`
|
||||||
TemplateConfig interface{} `json:"templateConfig"`
|
AllowIndependentOrders bool `json:"allowIndependentOrders"`
|
||||||
|
DispatchMode string `json:"dispatchMode"`
|
||||||
|
Announcements []string `json:"announcements"`
|
||||||
|
TemplateConfig interface{} `json:"templateConfig"`
|
||||||
}
|
}
|
||||||
ShopListResp {
|
ShopListResp {
|
||||||
Items []ShopProfile `json:"items"`
|
Items []ShopProfile `json:"items"`
|
||||||
|
|||||||
Reference in New Issue
Block a user