package post

import (
	"context"
	"fmt"

	"git.apinb.com/bsm-sdk/core/errcode"
	"git.apinb.com/bsm-sdk/core/service"

	"bsm/full/module/base/cms/internal/models"
	pb "bsm/full/module/base/cms/pb"
)

// DeleteComment 删除评论
func DeleteComment(ctx context.Context, in *pb.DeleteCommentRequest) (*pb.StatusReply, error) {
	_, err := service.ParseMetaCtx(ctx, nil)
	if err != nil {
		return nil, err
	}

	if in.GetIdentity() == "" {
		return nil, errcode.ErrInvalidArgument
	}
	err = models.DeleteComment(in.Identity)
	if err != nil {
		fmt.Println()
		return nil, errcode.ErrDB
	}
	return &pb.StatusReply{}, nil
}
