package commentservicelogic import ( "app-cloudep-tweeting-service/internal/domain" "context" "app-cloudep-tweeting-service/gen_result/pb/tweeting" "app-cloudep-tweeting-service/internal/svc" "github.com/zeromicro/go-zero/core/logx" ) type DeleteCommentLogic struct { ctx context.Context svcCtx *svc.ServiceContext logx.Logger } func NewDeleteCommentLogic(ctx context.Context, svcCtx *svc.ServiceContext) *DeleteCommentLogic { return &DeleteCommentLogic{ ctx: ctx, svcCtx: svcCtx, Logger: logx.WithContext(ctx), } } // DeleteComment 刪除評論 func (l *DeleteCommentLogic) DeleteComment(in *tweeting.DeleteCommentReq) (*tweeting.OKResp, error) { _, err := l.svcCtx.CommentModel.DeleteMany(l.ctx, in.GetCommentId()...) if err != nil { e := domain.CommentErrorL( domain.CommentDeleteErrorCode, logx.WithContext(l.ctx), []logx.LogField{ {Key: "req", Value: in}, {Key: "func", Value: "CommentModel.DeleteMany"}, {Key: "err", Value: err}, }, "failed to del comment").Wrap(err) return nil, e } return &tweeting.OKResp{}, nil }