app-cloudep-tweeting-service/internal/logic/postservice/delete_post_logic.go

44 lines
1021 B
Go
Raw Permalink Normal View History

2024-08-28 09:09:01 +00:00
package postservicelogic
import (
2024-08-29 02:41:34 +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 DeletePostLogic struct {
ctx context.Context
svcCtx *svc.ServiceContext
logx.Logger
}
func NewDeletePostLogic(ctx context.Context, svcCtx *svc.ServiceContext) *DeletePostLogic {
return &DeletePostLogic{
ctx: ctx,
svcCtx: svcCtx,
Logger: logx.WithContext(ctx),
}
}
// DeletePost 刪除貼文
2024-08-28 14:24:47 +00:00
func (l *DeletePostLogic) DeletePost(in *tweeting.DeletePostsReq) (*tweeting.OKResp, error) {
2024-08-29 02:41:34 +00:00
_, err := l.svcCtx.PostModel.DeleteMany(l.ctx, in.GetPostId()...)
if err != nil {
e := domain.PostMongoErrorL(
logx.WithContext(l.ctx),
[]logx.LogField{
{Key: "req", Value: in},
{Key: "func", Value: "PostModel.DeletePost"},
{Key: "err", Value: err},
},
"failed to add del post").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
}