// Package method 业务逻辑方法包，实现反馈相关的业务操作
package method

import (
	"context"
	"time"

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

// Delete 删除反馈记录
// ctx: 上下文
// in: 删除请求参数，包含记录ID
// 返回: 删除操作结果
func Delete(ctx context.Context, in *pb.DeleteRequest) (reply *pb.StatusReply, err error) {
	// 验证请求参数
	if in.GetIdentity() == "" {
		return nil, errcode.ErrInvalidArgument
	}

	// 删除记录（GORM会自动处理关联的图片和附件删除）
	err = impl.DBService.Where("identity = ?", in.GetIdentity()).Delete(new(models.FeedbackItem)).Error
	if err != nil {
		return nil, err
	}

	return &pb.StatusReply{
		Message: vars.OK,
		Timeseq: time.Now().UnixMilli(),
	}, nil
}
