Files
full/module/social/feed/internal/logic/post/delete_comment.go

39 lines
913 B
Go
Raw Normal View History

package post
import (
"context"
"time"
2026-08-10 11:42:45 +08:00
"bsm/full/module/social/feed/internal/models"
pb "bsm/full/module/social/feed/pb"
"git.apinb.com/bsm-sdk/core/errcode"
"git.apinb.com/bsm-sdk/core/printer"
"git.apinb.com/bsm-sdk/core/service"
"git.apinb.com/bsm-sdk/core/vars"
)
// 删除评论
func DeleteComment(ctx context.Context, in *pb.IdentRequest) (reply *pb.DataStatusReply, err error) {
2026-09-22 21:15:34 +08:00
auth, err := service.ParseMetaCtx(ctx, nil)
if err != nil {
return nil, err
}
if in.GetId() == 0 && in.GetIdentity() == "" {
return nil, errcode.ErrInvalidArgument
}
2026-09-22 21:15:34 +08:00
// 只能删除自己发表的评论
affected, err := models.DeleteComment(in.Identity, auth.Identity)
if err != nil {
printer.Error(err.Error())
return nil, errcode.ErrDB
}
2026-09-22 21:15:34 +08:00
if affected == 0 {
return nil, errcode.ErrPermissionDenied
}
return &pb.DataStatusReply{
Data: vars.OK,
Timeseq: time.Now().UnixNano(),
}, nil
}