From 6bf364ec0b48be4fbdbfa279effea9c974dc1cbf Mon Sep 17 00:00:00 2001 From: richjohnrambo Date: Sat, 19 Sep 2026 22:33:33 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E5=85=BB=E6=88=90?= =?UTF-8?q?=E7=AE=A1=E7=90=86=E6=8E=A5=E5=8F=A3=E5=8F=82=E6=95=B0=E8=BF=87?= =?UTF-8?q?=E6=BB=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../internal/logic/sys/cultivate_content.go | 29 ++++++++++++++++--- server/internal/logic/sys/cultivate_flower.go | 3 ++ 2 files changed, 28 insertions(+), 4 deletions(-) diff --git a/server/internal/logic/sys/cultivate_content.go b/server/internal/logic/sys/cultivate_content.go index e9ed0af..63b24d9 100644 --- a/server/internal/logic/sys/cultivate_content.go +++ b/server/internal/logic/sys/cultivate_content.go @@ -71,6 +71,9 @@ func (s *sSysCultivateContent) Dashboard(ctx context.Context, _ *sysin.Cultivate } func (s *sSysCultivateContent) List(ctx context.Context, in *sysin.CultivateContentListInp) (list []*sysin.CultivateContentListModel, totalCount int, err error) { + if err = in.Filter(ctx); err != nil { + return nil, 0, err + } tenantID := cultivateTenantID(ctx) if in.ObjectType == "feed_comment" { columns := dao.FeedComment.Columns() @@ -125,12 +128,15 @@ func (s *sSysCultivateContent) List(ctx context.Context, in *sysin.CultivateCont } func (s *sSysCultivateContent) View(ctx context.Context, in *sysin.CultivateContentViewInp) (*sysin.CultivateContentViewModel, error) { + if err := in.Filter(ctx); err != nil { + return nil, err + } tenantID := cultivateTenantID(ctx) base := &sysin.CultivateContentViewModel{Media: []*sysin.CultivateMediaModel{}, Audits: []*sysin.CultivateAuditModel{}, RelatedReports: []*sysin.CultivateReportListModel{}} if in.ObjectType == "feed_comment" { c := dao.FeedComment.Columns() var row entity.FeedComment - if err := dao.FeedComment.Ctx(ctx).Where(g.Map{c.Id: in.ObjectId, c.TenantId: tenantID}).Scan(&row); err != nil { + if err := dao.FeedComment.Ctx(ctx).Where(g.Map{c.Id: in.ObjectId, c.TenantId: tenantID}).Scan(&row); err != nil && !errors.Is(err, sql.ErrNoRows) { return nil, err } if row.Id == 0 { @@ -140,7 +146,7 @@ func (s *sSysCultivateContent) View(ctx context.Context, in *sysin.CultivateCont } else { c := dao.FeedPost.Columns() var row entity.FeedPost - if err := dao.FeedPost.Ctx(ctx).Where(g.Map{c.Id: in.ObjectId, c.TenantId: tenantID}).Scan(&row); err != nil { + if err := dao.FeedPost.Ctx(ctx).Where(g.Map{c.Id: in.ObjectId, c.TenantId: tenantID}).Scan(&row); err != nil && !errors.Is(err, sql.ErrNoRows) { return nil, err } if row.Id == 0 { @@ -149,7 +155,7 @@ func (s *sSysCultivateContent) View(ctx context.Context, in *sysin.CultivateCont base.CultivateContentListModel = sysin.CultivateContentListModel{Id: in.Id, ObjectType: in.ObjectType, AuthorId: strconv.FormatUint(row.AuthorId, 10), ContentText: row.ContentText, FlowerCode: row.FlowerCode, Visibility: row.Visibility, Status: row.Status, AuditStatus: row.AuditStatus, RejectReason: row.RejectReasonCode, LikeCount: row.LikeCount, CommentCount: row.CommentCount, CreatedAt: row.CreatedAt, UpdatedAt: row.UpdatedAt} mc := dao.FeedMedia.Columns() var media []*entity.FeedMedia - if err := dao.FeedMedia.Ctx(ctx).Where(g.Map{mc.TenantId: tenantID, mc.PostId: in.ObjectId}).OrderAsc(mc.SortNo).Scan(&media); err != nil { + if err := dao.FeedMedia.Ctx(ctx).Where(g.Map{mc.TenantId: tenantID, mc.PostId: in.ObjectId}).OrderAsc(mc.SortNo).Scan(&media); err != nil && !errors.Is(err, sql.ErrNoRows) { return nil, err } for _, m := range media { @@ -158,7 +164,7 @@ func (s *sSysCultivateContent) View(ctx context.Context, in *sysin.CultivateCont } ac := dao.ContentAuditLog.Columns() var audits []*entity.ContentAuditLog - if err := dao.ContentAuditLog.Ctx(ctx).Where(g.Map{ac.TenantId: tenantID, ac.ObjectType: in.ObjectType, ac.ObjectId: in.ObjectId}).OrderDesc(ac.Id).Scan(&audits); err != nil { + if err := dao.ContentAuditLog.Ctx(ctx).Where(g.Map{ac.TenantId: tenantID, ac.ObjectType: in.ObjectType, ac.ObjectId: in.ObjectId}).OrderDesc(ac.Id).Scan(&audits); err != nil && !errors.Is(err, sql.ErrNoRows) { return nil, err } for _, a := range audits { @@ -180,6 +186,9 @@ func (s *sSysCultivateContent) View(ctx context.Context, in *sysin.CultivateCont } func (s *sSysCultivateContent) Review(ctx context.Context, in *sysin.CultivateContentReviewInp) error { + if err := in.Filter(ctx); err != nil { + return err + } tenantID, operatorID := cultivateTenantID(ctx), contexts.GetUserId(ctx) var authorID uint64 err := dao.FeedPost.Transaction(ctx, func(txCtx context.Context, tx gdb.TX) error { @@ -210,6 +219,9 @@ func (s *sSysCultivateContent) Review(ctx context.Context, in *sysin.CultivateCo } func (s *sSysCultivateContent) BatchReview(ctx context.Context, in *sysin.CultivateContentBatchReviewInp) (*sysin.CultivateContentBatchReviewModel, error) { + if err := in.Filter(ctx); err != nil { + return nil, err + } result := &sysin.CultivateContentBatchReviewModel{Failures: make(map[string]string)} for _, id := range in.Ids { item := &sysin.CultivateContentReviewInp{ObjectType: in.ObjectType, Id: id, Action: in.Action, Reason: in.Reason} @@ -367,6 +379,9 @@ func writeContentAudit(ctx context.Context, tx gdb.TX, tenantID, operatorID int6 } func (s *sSysCultivateContent) ReportList(ctx context.Context, in *sysin.CultivateReportListInp) (list []*sysin.CultivateReportListModel, totalCount int, err error) { + if err = in.Filter(ctx); err != nil { + return nil, 0, err + } columns := dao.FeedReport.Columns() mod := dao.FeedReport.Ctx(ctx).Where(columns.TenantId, cultivateTenantID(ctx)) if in.ObjectType != "" { @@ -397,6 +412,9 @@ func reportModel(row *entity.FeedReport) *sysin.CultivateReportListModel { } func (s *sSysCultivateContent) ReportView(ctx context.Context, in *sysin.CultivateReportViewInp) (*sysin.CultivateReportViewModel, error) { + if err := in.Filter(ctx); err != nil { + return nil, err + } tenantID := cultivateTenantID(ctx) c := dao.FeedReport.Columns() var row entity.FeedReport @@ -430,6 +448,9 @@ func (s *sSysCultivateContent) ReportView(ctx context.Context, in *sysin.Cultiva } func (s *sSysCultivateContent) ReportHandle(ctx context.Context, in *sysin.CultivateReportHandleInp) error { + if err := in.Filter(ctx); err != nil { + return err + } tenantID, operatorID := cultivateTenantID(ctx), contexts.GetUserId(ctx) columns := dao.FeedReport.Columns() var report entity.FeedReport diff --git a/server/internal/logic/sys/cultivate_flower.go b/server/internal/logic/sys/cultivate_flower.go index 61dabb4..e25f369 100644 --- a/server/internal/logic/sys/cultivate_flower.go +++ b/server/internal/logic/sys/cultivate_flower.go @@ -89,6 +89,9 @@ func (s *sSysCultivateFlower) View(ctx context.Context, in *sysin.CultivateFlowe } func (s *sSysCultivateFlower) Edit(ctx context.Context, in *sysin.CultivateFlowerEditInp) (err error) { + if err = in.Filter(ctx); err != nil { + return err + } tenantID := cultivateTenantID(ctx) if err = validateCultivateAssets(ctx, tenantID, in); err != nil { return err