package tags

import (
	"context"
	"time"

	"bsm/full/module/base/cms/internal/impl"
	"bsm/full/module/base/cms/internal/models"
	pb "bsm/full/module/base/cms/pb"
	"git.apinb.com/bsm-sdk/core/errcode"
	"git.apinb.com/bsm-sdk/core/service"
)

// 删除标签
func Delete(ctx context.Context, in *pb.IdentRequest) (reply *pb.StatusReply, err error) {
	_, err = service.ParseMetaCtx(ctx, nil)
	if err != nil {
		return nil, err
	}

	if in.GetIdentity() == "" {
		return nil, errcode.ErrInvalidArgument
	}
	if err := impl.DBService.Where("identity = ?", in.GetIdentity()).Delete(&models.CmsTags{}).Error; err != nil {
		return nil, errcode.ErrDB
	}

	return &pb.StatusReply{
		Code:    0,
		Message: "OK",
		Timeseq: time.Now().Unix(),
	}, nil

}
