package core

import (
	"context"

	"gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc"
	"gitlink.org.cn/JointCloud/pcm-coordinator/internal/types"

	"github.com/zeromicro/go-zero/core/logx"
)

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

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

func (l *CancelResourceSpecAlarmLogic) CancelResourceSpecAlarm(req *types.IdReq) (resp *types.CommonResp, err error) {
	db := l.svcCtx.DbEngin.Model(&types.ResourceSpec{}).Table("t_resource_spec")
	err = db.Where("t_resource_spec.deleted_at is null and t_resource_spec.id = ?", req.Id).Update("change_type", 0).Error
	if err != nil {
		return nil, err
	}

	return
}
