package logic

import (
	"context"
	"fmt"
	"github.com/zeromicro/go-zero/core/logx"
	sysModel "sundynix-micro-go/app/system/model"
	"sundynix-micro-go/app/system/rpc/internal/svc"
	"sundynix-micro-go/app/system/rpc/system"
)

type DeleteOperationRecordLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
	logx.Logger
}

func NewDeleteOperationRecordLogic(ctx context.Context, svcCtx *svc.ServiceContext) *DeleteOperationRecordLogic {
	return &DeleteOperationRecordLogic{ctx: ctx, svcCtx: svcCtx, Logger: logx.WithContext(ctx)}
}

func (l *DeleteOperationRecordLogic) DeleteOperationRecord(in *system.IdsReq) (*system.CommonResp, error) {
	if err := l.svcCtx.DB.Where("id IN ?", in.Ids).Delete(&sysModel.SundynixOperationRecord{}).Error; err != nil {
		return nil, fmt.Errorf("删除操作日志失败")
	}
	return &system.CommonResp{Code: 200, Msg: "success"}, nil
}
