2024-08-28 09:09:01 +00:00
|
|
|
package commentservicelogic
|
|
|
|
|
|
|
|
import (
|
2024-08-30 07:08:43 +00:00
|
|
|
"app-cloudep-tweeting-service/internal/domain"
|
2024-08-28 09:09:01 +00:00
|
|
|
"context"
|
|
|
|
|
2024-08-28 14:29:42 +00:00
|
|
|
"app-cloudep-tweeting-service/gen_result/pb/tweeting"
|
|
|
|
"app-cloudep-tweeting-service/internal/svc"
|
2024-08-28 09:09:01 +00:00
|
|
|
|
|
|
|
"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 刪除評論
|
2024-08-28 14:24:47 +00:00
|
|
|
func (l *DeleteCommentLogic) DeleteComment(in *tweeting.DeleteCommentReq) (*tweeting.OKResp, error) {
|
2024-08-30 07:08:43 +00:00
|
|
|
_, 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
|
|
|
|
}
|
2024-08-28 09:09:01 +00:00
|
|
|
|
2024-08-28 14:24:47 +00:00
|
|
|
return &tweeting.OKResp{}, nil
|
2024-08-28 09:09:01 +00:00
|
|
|
}
|