From 198c761063917de4a558615fc5a05f483034c44a Mon Sep 17 00:00:00 2001 From: zetaloop Date: Thu, 23 Apr 2026 20:36:44 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E8=A1=A5=E5=85=A8=20ShopProfile=20?= =?UTF-8?q?=E5=92=8C=20Post=20=E5=93=8D=E5=BA=94=E4=B8=AD=E7=BC=BA?= =?UTF-8?q?=E5=A4=B1=E7=9A=84=E5=90=8E=E7=AB=AF=E5=AD=97=E6=AE=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ShopProfile 补上 allowMultiShop/allowIndependentOrders/dispatchMode,Post 补上 pinned/linkedOrderId。这些字段在 RPC proto、数据库和写入逻辑中均已存在,但 API 响应类型和映射函数遗漏了它们。同时补回 community.api 中 CreateCommentReq 的 PostId 字段定义。 --- app/community/api/internal/handler/routes.go | 2 +- .../api/internal/logic/community/helpers.go | 22 ++++++++------- app/community/api/internal/types/types.go | 24 +++++++++-------- app/shop/api/internal/logic/shop/helpers.go | 23 +++++++++------- app/shop/api/internal/types/types.go | 27 ++++++++++--------- desc/api/community.api | 23 +++++++++------- desc/api/shop.api | 27 ++++++++++--------- 7 files changed, 82 insertions(+), 66 deletions(-) diff --git a/app/community/api/internal/handler/routes.go b/app/community/api/internal/handler/routes.go index ccbf8a0..dc96a34 100644 --- a/app/community/api/internal/handler/routes.go +++ b/app/community/api/internal/handler/routes.go @@ -1,5 +1,5 @@ // Code generated by goctl. DO NOT EDIT. -// goctl 1.9.2 +// goctl 1.10.1 package handler diff --git a/app/community/api/internal/logic/community/helpers.go b/app/community/api/internal/logic/community/helpers.go index 91d7be4..8d20c45 100644 --- a/app/community/api/internal/logic/community/helpers.go +++ b/app/community/api/internal/logic/community/helpers.go @@ -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 { return types.Post{ - Id: p.GetId(), - Title: p.GetTitle(), - Content: p.GetContent(), - Images: append([]string(nil), p.GetImages()...), - Tags: append([]string(nil), p.GetTags()...), - LikeCount: p.GetLikeCount(), - CommentCount: p.GetCommentCount(), - Liked: liked, - Author: buildUserProfile(ctx, svcCtx, p.GetAuthorId()), - CreatedAt: time.Unix(p.GetCreatedAt(), 0).UTC().Format(time.RFC3339), + Id: p.GetId(), + Title: p.GetTitle(), + Content: p.GetContent(), + Images: append([]string(nil), p.GetImages()...), + Tags: append([]string(nil), p.GetTags()...), + LinkedOrderId: p.GetLinkedOrderId(), + Pinned: p.GetPinned(), + LikeCount: p.GetLikeCount(), + CommentCount: p.GetCommentCount(), + Liked: liked, + Author: buildUserProfile(ctx, svcCtx, p.GetAuthorId()), + CreatedAt: time.Unix(p.GetCreatedAt(), 0).UTC().Format(time.RFC3339), } } diff --git a/app/community/api/internal/types/types.go b/app/community/api/internal/types/types.go index b7b9fbf..123dc3e 100644 --- a/app/community/api/internal/types/types.go +++ b/app/community/api/internal/types/types.go @@ -1,5 +1,5 @@ // Code generated by goctl. DO NOT EDIT. -// goctl 1.9.2 +// goctl 1.10.1 package types @@ -54,16 +54,18 @@ type PathId struct { } type Post struct { - Id int64 `json:"id"` - Title string `json:"title"` - Content string `json:"content"` - Images []string `json:"images"` - Tags []string `json:"tags"` - LikeCount int64 `json:"likeCount"` - CommentCount int64 `json:"commentCount"` - Liked bool `json:"liked"` - Author UserProfile `json:"author"` - CreatedAt string `json:"createdAt"` + Id int64 `json:"id"` + Title string `json:"title"` + Content string `json:"content"` + Images []string `json:"images"` + Tags []string `json:"tags"` + LinkedOrderId int64 `json:"linkedOrderId,optional"` + Pinned bool `json:"pinned"` + LikeCount int64 `json:"likeCount"` + CommentCount int64 `json:"commentCount"` + Liked bool `json:"liked"` + Author UserProfile `json:"author"` + CreatedAt string `json:"createdAt"` } type PostListReq struct { diff --git a/app/shop/api/internal/logic/shop/helpers.go b/app/shop/api/internal/logic/shop/helpers.go index b7fa32a..c5040f4 100644 --- a/app/shop/api/internal/logic/shop/helpers.go +++ b/app/shop/api/internal/logic/shop/helpers.go @@ -36,16 +36,19 @@ func toShopProfile(in *pb.Shops) *types.ShopProfile { VerificationStatus: map[string]string{}, CreatedAt: "", }, - Name: in.Name, - Banner: in.Banner, - Description: in.Description, - Rating: in.Rating, - TotalOrders: in.TotalOrders, - PlayerCount: in.PlayerCount, - CommissionType: in.CommissionType, - CommissionValue: in.CommissionValue, - Announcements: in.Announcements, - TemplateConfig: template, + Name: in.Name, + Banner: in.Banner, + Description: in.Description, + Rating: in.Rating, + TotalOrders: in.TotalOrders, + PlayerCount: in.PlayerCount, + CommissionType: in.CommissionType, + CommissionValue: in.CommissionValue, + AllowMultiShop: in.AllowMultiShop, + AllowIndependentOrders: in.AllowIndependentOrders, + DispatchMode: in.DispatchMode, + Announcements: in.Announcements, + TemplateConfig: template, } } diff --git a/app/shop/api/internal/types/types.go b/app/shop/api/internal/types/types.go index dfe4ee6..be92690 100644 --- a/app/shop/api/internal/types/types.go +++ b/app/shop/api/internal/types/types.go @@ -80,18 +80,21 @@ type ShopListResp struct { } type ShopProfile struct { - Id string `json:"id"` - Owner UserProfile `json:"owner"` - Name string `json:"name"` - Banner string `json:"banner,optional"` - Description string `json:"description"` - Rating string `json:"rating"` - TotalOrders int64 `json:"totalOrders"` - PlayerCount int64 `json:"playerCount"` - CommissionType string `json:"commissionType"` - CommissionValue string `json:"commissionValue"` - Announcements []string `json:"announcements"` - TemplateConfig interface{} `json:"templateConfig"` + Id string `json:"id"` + Owner UserProfile `json:"owner"` + Name string `json:"name"` + Banner string `json:"banner,optional"` + Description string `json:"description"` + Rating string `json:"rating"` + TotalOrders int64 `json:"totalOrders"` + PlayerCount int64 `json:"playerCount"` + CommissionType string `json:"commissionType"` + CommissionValue string `json:"commissionValue"` + AllowMultiShop bool `json:"allowMultiShop"` + AllowIndependentOrders bool `json:"allowIndependentOrders"` + DispatchMode string `json:"dispatchMode"` + Announcements []string `json:"announcements"` + TemplateConfig interface{} `json:"templateConfig"` } type SimpleUser struct { diff --git a/desc/api/community.api b/desc/api/community.api index 9b8e3a1..9c8fdbe 100644 --- a/desc/api/community.api +++ b/desc/api/community.api @@ -7,16 +7,18 @@ type ( Id int64 `path:"id"` } Post { - Id int64 `json:"id"` - Title string `json:"title"` - Content string `json:"content"` - Images []string `json:"images"` - Tags []string `json:"tags"` - LikeCount int64 `json:"likeCount"` - CommentCount int64 `json:"commentCount"` - Liked bool `json:"liked"` - Author UserProfile `json:"author"` - CreatedAt string `json:"createdAt"` + Id int64 `json:"id"` + Title string `json:"title"` + Content string `json:"content"` + Images []string `json:"images"` + Tags []string `json:"tags"` + LinkedOrderId int64 `json:"linkedOrderId,optional"` + Pinned bool `json:"pinned"` + LikeCount int64 `json:"likeCount"` + CommentCount int64 `json:"commentCount"` + Liked bool `json:"liked"` + Author UserProfile `json:"author"` + CreatedAt string `json:"createdAt"` } CreatePostReq { Title string `json:"title"` @@ -47,6 +49,7 @@ type ( Meta PageMeta `json:"meta"` } CreateCommentReq { + PostId int64 `json:"-"` Content string `json:"content"` } ListCommentsReq { diff --git a/desc/api/shop.api b/desc/api/shop.api index ae2a2b8..d9aff29 100644 --- a/desc/api/shop.api +++ b/desc/api/shop.api @@ -4,18 +4,21 @@ import "common.api" type ( ShopProfile { - Id string `json:"id"` - Owner UserProfile `json:"owner"` - Name string `json:"name"` - Banner string `json:"banner,optional"` - Description string `json:"description"` - Rating string `json:"rating"` - TotalOrders int64 `json:"totalOrders"` - PlayerCount int64 `json:"playerCount"` - CommissionType string `json:"commissionType"` - CommissionValue string `json:"commissionValue"` - Announcements []string `json:"announcements"` - TemplateConfig interface{} `json:"templateConfig"` + Id string `json:"id"` + Owner UserProfile `json:"owner"` + Name string `json:"name"` + Banner string `json:"banner,optional"` + Description string `json:"description"` + Rating string `json:"rating"` + TotalOrders int64 `json:"totalOrders"` + PlayerCount int64 `json:"playerCount"` + CommissionType string `json:"commissionType"` + CommissionValue string `json:"commissionValue"` + AllowMultiShop bool `json:"allowMultiShop"` + AllowIndependentOrders bool `json:"allowIndependentOrders"` + DispatchMode string `json:"dispatchMode"` + Announcements []string `json:"announcements"` + TemplateConfig interface{} `json:"templateConfig"` } ShopListResp { Items []ShopProfile `json:"items"`